I also wanted a similar functionality but in the end decided to use a
prepared statement w/ sqlite3_column_* methods.  My two main reasons
were a) it didn't seem like there were any methods to dumping the data
to a struct like that and b) I was able to do any sort of validation I
desired such as ensuring equivalent types and validating against column
names.

-----Original Message-----
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik
Sent: Monday, June 29, 2009 8:17 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] SQL result to struct

Mark Flipphi wrote:
> I need some help with storing the result from a query into a struct.
>
> I have a query like :
>
> SELECT Echo.Position, Echo.Depth, Echo.dBLevel, Echo.Time,
> Echo.CommonIdx, Common.ChanNr
> FROM Echo JOIN Common ON Echo.CommonIdx = Common.CommonIdx
> ORDER BY Echo.Position ASC
>
> and i need to store the information in a struct like :
>
> typedef struct
> {
>    UINT64     nPosition;
>    UINT16     nDepth;
>    UINT8       ndBLevel;
>    UINT64     nTime;
>    UINT64     nIdx;
>    UINT8       nChannel;
> }
>
> now i use the function :
> rc = sqlite3_exec(m_SqLiteDB, sQuery, callback, 0, &zErrMsg);

You may find it easier to use sqlite3_prepare, sqlite3_step, 
sqlite3_column_* et al. For one thing, you'll avoid conversion from 
integers to strings and back.

Igor Tandetnik



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

Reply via email to