int BindParameter(sqlite3_stmt* stmt, int sqlType, const char* pname,
char* value);
Somewhere before the call(s) to BindParameter, I'll have a string that
looks like this:
(FOO=some text value, BAR=3.141, ZIP=45, TIMESTAMP1=01/17/12
17:54:00, TIMESTAMP2=542312453423)
My parameter values will always be input from a char string (as above),
but the data types in the table are INTEGER, TEXT, REAL and NUMERIC. I
was thinking that there must already be some easy way of getting to the
correct bind call. In the end, I would like to have something like this
inside the BindParameter function:
case INTEGER:
sqlite3_bind_int(stmt, sqlite3_bind_parameter_index(stmt, pname),
data);
case REAL:
sqlite3_bind_double(stmt, sqlite3_bind_parameter_index(stmt,
pname), data);
case TEXT:
sqlite3_bind_text(stmt, sqlite3_bind_parameter_index(stmt, pname),
value);
case NUMERIC:
??? I don't see a bind
This seems like something somebody would have come across before, so
I'd rather not re-invent.
My questions are:
1. Is there already some other way of doing what I want? Or am I already
on the right track?
2. If, is there already some enum or #define that would work for sqlType?
(SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_BLOB, SQLITE_NULL,
SQLITE_TEXT don't seem to cover every DT)
3. What is the correct bind call for a NUMERIC parameter?
Thanks!!!
_______________________________________________
sqlite-users mailing list
sqlite...@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
sqlite does type conversion as needed, so you can just pass the strings
you've parsed out of your larger string to sqlite3_bind_text().
If the issue is that you need to decode your TIMESTAMP1 column to get the
same format as TIMESTAMP2, and you want to use the datatype listed on the
column as a hint, then I can't help you.
--David Garfield
On Tue, Jan 17, 2012 at 19:32, Bill McCormick <wpmcc...@gmail.com> wrote:
> I'm trying to write a function with a sig like this:
>
> int BindParameter(sqlite3_stmt* stmt, int sqlType, const char* pname,
> char* value);
>
> Somewhere before the call(s) to BindParameter, I'll have a string that
> looks like this:
> (FOO=some text value, BAR=3.141, ZIP=45, TIMESTAMP1=01/17/12 17:54:00,
> TIMESTAMP2=542312453423)
>
> My parameter values will always be input from a char string (as above),
> but the data types in the table are INTEGER, TEXT, REAL and NUMERIC. I was
> thinking that there must already be some easy way of getting to the correct
> bind call. In the end, I would like to have something like this inside the
> BindParameter function:
>
> case INTEGER:
> sqlite3_bind_int(stmt, sqlite3_bind_parameter_index(**stmt, pname),
> data);
>
> case REAL:
> sqlite3_bind_double(stmt, sqlite3_bind_parameter_index(**stmt, pname),
> data);
>
> case TEXT:
> sqlite3_bind_text(stmt, sqlite3_bind_parameter_index(**stmt, pname),
> value);
>
> case NUMERIC:
> ??? I don't see a bind
>
> This seems like something somebody would have come across before, so I'd
> rather not re-invent.
>
> My questions are:
> 1. Is there already some other way of doing what I want? Or am I already
> on the right track?
> 2. If, is there already some enum or #define that would work for sqlType?
> (SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_BLOB, SQLITE_NULL, SQLITE_TEXT
> don't seem to cover every DT)
> 3. What is the correct bind call for a NUMERIC parameter?
>
> Thanks!!!
> ______________________________**_________________
> sqlite-users mailing list
> sqlite...@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
At that site they parse your string using regex in c#, though I did't see a
time stamp test, and their is the equivalent regex functions, many, in a c
libs.
On Tue, Jan 17, 2012 at 4:32 PM, Bill McCormick <wpmcc...@gmail.com>wrote:
> I'm trying to write a function with a sig like this:
>
> int BindParameter(sqlite3_stmt* stmt, int sqlType, const char* pname,
> char* value);
>
> Somewhere before the call(s) to BindParameter, I'll have a string that
> looks like this:
> (FOO=some text value, BAR=3.141, ZIP=45, TIMESTAMP1=01/17/12 17:54:00,
> TIMESTAMP2=542312453423)
>
> My parameter values will always be input from a char string (as above),
> but the data types in the table are INTEGER, TEXT, REAL and NUMERIC. I was
> thinking that there must already be some easy way of getting to the correct
> bind call. In the end, I would like to have something like this inside the
> BindParameter function:
>
> case INTEGER:
> sqlite3_bind_int(stmt, sqlite3_bind_parameter_index(**stmt, pname),
> data);
>
> case REAL:
> sqlite3_bind_double(stmt, sqlite3_bind_parameter_index(**stmt, pname),
> data);
>
> case TEXT:
> sqlite3_bind_text(stmt, sqlite3_bind_parameter_index(**stmt, pname),
> value);
>
> case NUMERIC:
> ??? I don't see a bind
>
> This seems like something somebody would have come across before, so I'd
> rather not re-invent.
>
> My questions are:
> 1. Is there already some other way of doing what I want? Or am I already
> on the right track?
> 2. If, is there already some enum or #define that would work for sqlType?
> (SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_BLOB, SQLITE_NULL, SQLITE_TEXT
> don't seem to cover every DT)
> 3. What is the correct bind call for a NUMERIC parameter?
>
> Thanks!!!
> ______________________________**_________________
> sqlite-users mailing list
> sqlite...@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
Compute the date and time given a unix timestamp 1092941466.
SELECT datetime(1092941466, 'unixepoch');