Hello,

I am using function sqlite3_column_origin_name and friends in my SQLite3 C++ 
wrapper class to get table and column names in SELECT statements. 
I would like to have the same feature for INSERT and UPDATE statements: that 
is, find the table name and column names when writing to the database, not only 
reading.
I think this is impossible with current SQLite3 library, but I may be missing 
something.
The workaround I have implemented is to use some C++11 regular expressions to 
parse the SQL expression outside of SQLite3.
What would be the difficulty to support origin column names also for writing, 
not just reading ?

_______

In background, I will explain the reason I would like such feature.
I know that there are already plenty of C++ wrappers over SQLite3, but I wrote 
another one for our company base framework.
I think it has plenty of qualities:
simple: essentially a single function, executeQuery, using a variadic signature 
like printf (but type safe, thanks to C++11 variadic templates !)
automatic caching of instructions (does not recompile same SQL expression if 
already in the cache)
automatic binding of both input and output arguments
fast: the overhead over calling manually SQLite3 functions is minimum
natively support the C++ base classes of our framework (also a drawback: I 
could not distribute that wrapper by itself)
have a limited support for units in numeric values.

The last point is the reason for my request. For example, if a table was 
created with that command:

CREATE TABLE t1 (speed REAL_m_per_s);

SQLite3 will assign to speed column an affinity of floating point value since 
it has REAL in the type.
And my C++ wrapper then knows that this column is a speed expressed in meters 
per second. 
So when making a SELECT on t1 table, the wrapper will output number objects 
with unit dimension of Speed expressed in m/s !

To be complete, I want to check when writing to database (UPDATE or INSERT) 
that the unit contained in the input values match the expected type of the 
column.
Possibly making unit conversion on the fly (m -> ft).
But for that, I need to find out the column names and table name implied in a 
UPDATE or INSERT statement.

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

Reply via email to