Re: [gnome-db] SQLite last_insert_id



On 4/18/07, Piotr Pokora <piotrek pokora gmail com> wrote:
"Vivien Malerba" <vmalerba gmail com> wrote:

> No, there is not, but it's easy to do, see the attached patch which
> I'll commit ASAP.

Thanks!

> > If it can not be implemented , how can I check if provider supports this or not?
>
> You can't check if it's implemented, but if it's not, you'll get a
> warning and the returned value will always be NULL.

This is what I know , but the point is to use pseudo code like this:

if(provider_supports(last_insert_id)) {
        return_last_insert_id(cnc);
} else {
        "SELECT id from table WHERE ...."
}

>Moreover I don't
> really like this function since the returned value's interpretation
> and usage depends on the DBMS.

OK, so should I depend on this function or it's better to select this ID when insert is
succesfully  done?

To make code more portable, I would advise that you systematically use
the "SELECT id from table WHERE ...." solution when possible (that is
when you know for sure what to select). This solution will never fail,
but it's very difficult to write such a correct SELECT query.

Cheers,

Vivien



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]