Android. Is it possible to write custom function on C/C++ and use it in SQL query? - c++

SQLite3 doesn't support stored procedures. Is it possible to write custom function on C/C++ and use it in SQL query?
Something like that
SELECT * FROM table WHERE CUST_FUNCTION(name1, name2) = 1
or
SELECT CUST_FUNCTION(name1, name2) FROM table
Maybe you have some good example how to do that.

Sadly, it appears you cannot.
I was looking at something like this for calculating distance from within a sqlite query - it was sometimes mentioned as a method for doing this.
sqlite does support something like this, so documentation and other references will suggest that this is possible. However, after looking at various sources, I came to the conclusion that, while you can do it in several places that use sqlite (like iPhone I believe), you can't do it in Android's sqlite (at least I didn't find anyone able to do this way in Android).
Here are a couple of links that I had found suggesting it wasn't possible in Android and unfortunately I couldn't find any counterexamples. But I'd love to find I'm wrong about this ...
Android sqlite sort on calculated column (co-ordinates distance)
"The technique you describe does not seem to be applicable to Android, which cannot use sqlite3_create_function(). – CommonsWare Jan 9 '10 at 19:00"
Sqlite on Android: How to create a sqlite dist db function - to be used in the app for distance calculation using lat, long
org.sqlite is not an Android API, so that is not relevant. – hackbod Mar 1 '10 at 4:59
1
You are correct, org.sqlite is not an Android API. However, you can use it to implement a Content Provider that does what he asked. – Joshua Smith Mar 1 '10 at 12:39
Actually, I'm rather skeptical on the approach outlined in the content provider answer you link to. org.sqlite is not in Android, and it is unclear if there exists an org.sqlite implementation that will work in concert with Android's SQLite environment. – Pentium10 Jun 27 '10 at 9:12

Yes it might be possible, but that will not be supported officially on Android. We can do that either by writing our shared object in C and SQLite natively. I think, another way would be to java libraries for SQLite instead on relying on Google's libarries

I have not done any Android development , but it certainly is possible on other platforms.
Have a look at the sqlite_create_funciton api
http://www.sqlite.org/c3ref/create_function.html

Related

How can I learn array database Rasdaman easily?

I'm working at VietNam - HaNoi National University and I've a research at BigData satellite raster image by array database.
A solution is using Rasdaman database which has been developed many years. I've installed this server successfully, try to make some query with this by using this guide from rasdaman.org. Everything should be ok but I've known that this has a GUI tool name Rview.
I can't search Rview from any where (may be it's too old), I need some GUI tool because I some time don't really know what is error in my query and I need some tool that can show me the result (2D, 3D) with interractive viewer.
Please tell me how can I get a tool that can have GUI as MS SQL Database management tool, Phpmyadmin,...
Rview (recently renamed to rasdaview actually, to avoid clashing with vim) is a GUI client for rasdaman that allows to send queries and has some cool visualization capabilities for 1D to 3D data.
The problem with rasdaview is that it has been last compiled 10+ years ago against wxWidgets 1.6x and the code is so outdated and incompatible with recent wxWidgets that it's not possible to compile it anymore without significant rewriting.
So rasdaman comes with this rview binary, which amazingly still works on most systems today. However, since it's not possible to compile it, it's a bit tricky to get it running. These guidelines should help you.
Are you looking for a website where you can execute your DDL or DML statements?
If yes then try SQL Fiddle.

Using Databases in C++ and Visual Studio 6

I already did some searching on stackoverflow and as far as I can see there are many ways to use databases in C++. Unfortunately at work my tools are pretty limited. I only get to use visual studio C++ 6 and don't even have boost (although I have learned to cope with that) - I assume that I can only use what is the standard distribution being delivered togather with VS C++ 6.
Now my code generates a lot of data and I would like to store some of it in a simple databse (like an MS Access db). What tools might I be able to use?
My alternative approauch would be to create a database-like object via a struct and vectors/arrays.
I also have office 2010 installed - perhaps I could somehow use Access?
Computation-speed also plays a role - the faster the better.
Another important thing: my PC at work isn't an open client. Thus I can not install any new software. Downloading and moving files works. Basically I must be able to install the tool by just moving the files into a desired folder.
Please let me know if the question is confusing or insufficiently detailed I will do what i can to remedy the situation then.
Thnaks in advance for your help :)
Even though you said 'only standard tools', I'd still say, get SQLite. It ss a public domain software, i.e. no license whatsoever . You can download an 'amalgamation' - one .h file and one .c file and include it into your project. It should compile in VC6 no problem. Very easy to use, you will be up and running in 10 minutes.
It does exactly what you need - a DB in a single file, no servers, zero-setup, etc.
Well, Visual C++ 6 did include MFC which had a suite of classes for the creation and manipulation of databases, I'm fairly certain it would be possible to use these to create a database that is accessible from Access. Unfortunately Microsoft's online help doesn't seem to go back that far, but all the reference material you need should come with the VS 6. (In my opinion VS Help system was better back then anyways.)
On a side note, you could download an old version of boost that would work with VS6. I'm not sure what the last version of boost that supports VS6 is, my guess it's somewhere around 1.3x.
VC6 should work.
Can you use MFC's db objects? (DAO I think back then?).
If your app really generates a lot of data, you might want to look at MySql. I've run into size limitations in older Access tables. Unless it's an extraordinarily simple db, you probably don't want to brew your own (though it might be fun if you have a lot of time).
The key will be finding a driver/db combo that will work. I would install the GA (free) MySql, create a tiny db with 1 table and find the driver ("connector" in MySql terms) that will work. Maybe older ODBC driver?
Also, check out ConnectionStrings.com for info on getting connected to a particular database / driver.

SQLAPI++ Library use

Has anyone have good experience using SQLAPI++ Library? (connecting C++ and SQL)
What do you recommend, I have a local server, SQL server 2008 and Windows XP.
Do you have a funcional example to connect c++ and sql server?, just to do a simple
SELECt * FROM mytable;
in C++?
My first impression is that SQLApi++ is great. Here is a bit of background.
I have been using ADO for a long time, but it's starting to give some COM errors for some users, without any helpful information. Also, msado??.tlb is not backwards-compatible so you have to be careful about all your users being on the same version. I understand this might not apply to you, but I figured I would share this anyway.
I started looking into SQLApi++ a few days ago and have almost only good things to say. The only draw-back I have found so far is that there is no way to know how many rows you get back without going to the result set. Also, it isn't free. On the positive side, the API is intuitive, the documentation is good, and the examples are useful. It is blazingly fast by comparison to ADO. Instead of copy/pasting, take a look at http://www.sqlapi.com/Examples/step4.cpp.
The SQLApi++ is supported since 2000. The last update was few months ago. The site is not updated most probably because it is good enough as it is - couple of useful examples, documentation, history and support. That it is just a plus if they don't update site very often that means their examples and etc. are not changed, which means the api is stable and you don't have to change your code in order to use the latest technologies.
Sounds good, indeed, but the site hasn't been updated for a long time now :(

In native C++, how does one use a SqlCe .sdf database?

Is there a simple way, without .NET?
I've found some libraries but none for SqlCe 3.5. There is http://sqlcehelper.codeplex.com/ but it's far from done, since a major feature like using a password is not yet implemented. I've looked at the source and it uses OLEdb to handle the database.
The official Microsoft Northwind example (that is shipped with SQL Compact 3.1, but not with 3.5) also doesn't work, I've tried setting it up with no success.
Actually I don't have a sample working code. Was anyone able to set it up paired with a passworded .sdf?
What are the alternatives?
Thanks.
Several months ago, I compared certain database implementations for our desktop application. Using SqlCE with native C++ code is awful. If I remember right, some of native examples contains "goto" type jumps, hard to bind data and so on. If you have a choice then use SQLite.

Best full text search alternative to MS SQL, C++ solution

What is the best full text search alternative to Microsoft SQL? (which works with MS SQL)
I'm looking for something similar to Lucene and Lucene.NET but without the .NET and Java requirements. I would also like to find a solution that is usable in commercial applications.
Take a look at CLucene - It's a well maintained C++ port of java Lucene. It's currently licenced under LGPL and we use it in our commercial application.
Performance is incredible, however you do have to get your head around some of the strange API conventions.
Sphinx is one of the best solutions. It's written in C++ and has amazing performance.
DT Search is hands down the best search tool I have used. They have a number of solutions available. Their Engine will run on Native Win32, Linux or .NET. It will index pretty much every kind of document you might have (Excel, PDF, Word, etc.) I did some benchmarks comparisons a while ago and it was the easiest to use and had the best performance.
Solr is based on Lucene, but accessible via HTTP, so it can be used from any platform.
I second Sphinx, but Lucene is also not so bad despite the Java. :) If you are not dealing with too much data spread out etc., then also look into MySQL's FULLTEXT. We are using it to search across a 20 GB database.