"Drew, Stephen" <[EMAIL PROTECTED]> wrote:
> Hello all,
>  
> I have written a function to replicate the Oracle DECODE function, which
> I register whenever I open a SQLite3 (3.2.6) connection (see bottom of
> email).
>  
> However it seems that certain decodes fail due to corrupted data.  I
> have stepped through my code and seen that the value is correctly set
> when the decode function is called, but when the value is retrieved
> using sqlite3_column_value, it comes back as gibberish.
>  
> This does not always happen - the particular case involves five decode
> statements in the SELECT list.  If I move some of the DECODE statements
> around or remove them, it works ok.
>  
> So - here are some questions:
>  
> * - Is it safe to call sqlite3_set_result_string( ) as I am doing, i.e.
> with the value returned from sqlite3_value_text on the arguments?  (I
> have included my decode function at the bottom of this email, and
> happily release into the public domain....).


There is no such API as sqlite3_set_result_string().  There was
an API sqlite_set_result_string() in SQLite version 2, which you
appear to be using.  But it is certainly not safe to mix APIs.
I'm surprised this does not segfault on you.

Use sqlite3_result_text() instead.  See

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

for additional information.  And/or use the function implementations
in the func.c source file

  http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/func.c

as examples.

--
D. Richard Hipp   <[EMAIL PROTECTED]>

Reply via email to