On 2014/07/15 19:42, Edward Ned Harvey (sqlite) wrote:
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
boun...@sqlite.org] On Behalf Of RSmith


System.DBNull is not a native SQLite construct, it is probably one of the third
party connectors.
In C#, using the System.Data.Sqlite.Core package, which is described as "The official SQLite 
database engine" and published by "SQLite Development Team"...  The results of a 
Select statement are returned as an Object().  If the database contents were Null, then the result 
is an instance of System.DBNull() class, rather than returning null.

If this is not using the API directly, I don't know what is.

Yes, you do not know what is.

In the API you may call routines that resemble these:
sqlite3_prepareV2();
sqlite3_openV2();
sqlite3_step();

or more specific to your needs:

int sqlite3_bind_double(sqlite3_stmt*, int, double);
int sqlite3_bind_int(sqlite3_stmt*, int, int);
int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
int sqlite3_bind_null(sqlite3_stmt*, int);
int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));

and retrieving values with...

const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
double sqlite3_column_double(sqlite3_stmt*, int iCol);
int sqlite3_column_int(sqlite3_stmt*, int iCol);
sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
etc.

and finally some more for adding your own functions that will return any form of 
"long?" type or other you need...

In fact, let me get you the very introduction to the wonders of the SQLite API, 
and you will see your problem can be fixed in a few minutes by adding a simple 
function:

http://www.sqlite.org/cintro.html

Please feel free to ask for any advice or pointers or specific question you may 
have regarding using any of it.


I am not sure which development
environment you are using, I am guessing some C or scripting
The subject line says C#

Ah yes - Apologies for not checking the subject line, I have a bad habit of trying to establish the content of a message from the body only.


none of which is a standard or used in a wide
variety of systems - which is why the other poster did not even know what
you meant with "long?".
The official sqlite C# packages, if only counting the ones distributed by NuGet 
(not counting those who download direct from www.sqlite.org or build from 
source) has over 425,000 downloads, and is among the most popular packages 
deployed.

C# is by no means the defacto SQLite environment and 425K is extremely unimpressive, SQLIte is used on over a billion devices currently and many third party SQLite extensions and apps have download numbers that dwarf those, all of them being in no way "official" - I can provide links if needed. This is however not the point I was making at all and indeed very unimportant, I just wanted to let you know that your assumption that you have stumbled on the "one true" SQLite implementation and hence feel it should support data types specific to your platform is rather in need of illumination.


Maybe ask the designers of your connector for such functionality?
That's why I came to post here.

I thought, since there is a direct analogous native type in C# for each of the 
native storage types in SQLite, there was likely a native way to interoperate 
them seamlessly.  It seems I was wrong - but it's ok - the workaround was not 
terribly difficult.  I just felt like I was hacking and kludging my way through 
something that surely there must be a better way.

This is a fair point, and a valid request, as I said previously. Just that there is not a direct relation to those types currently (and probably won't be) in SQLite itself, but the C# Core package might well support it, and if not yet, might be able to. I'd leave it to a Core dev to answer or add a ticket for you.


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to