Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: DBI and last_insert_id

by moritz (Cardinal)
on Jan 28, 2009 at 21:11 UTC ( #739705=note: print w/replies, xml ) Need Help??


in reply to DBI and last_insert_id

Do you have RaiseError active? It seems that you pass an SQL string with four placeholders to prepare, but only pass three to execute. If execute fails, I wouldn't be suprised if last_insert_id() returned some garbage (although an error message would be useful).

Replies are listed 'Best First'.
Re^2: DBI and last_insert_id
by cog (Parson) on Jan 29, 2009 at 11:24 UTC
    I wish that would be the problem, but unfortunately it isn't. There are indeed four placeholders and I'm passing three to execute, but that's just because I edited the code to post it here and missed that. The number of arguments I'm passing in the actual code is correct.

    I also have RaiseError active. The INSERT statement definitely works, as later on I can see the row is in the database. It's just that the entry I'm inserting in the other table using the last_insert_id() has the wrong id.

      In future, please test that the code you post here does exhibit the same behaviour as you describe.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://739705]
help
Chatterbox?
[LanX]: oh thank you! :)
[Eily]: partly because I read tsj as /t͡ʃ/, don't know if that's supposed to be the case
[LanX]: Yeah I think thats Dutch spelling rule
[erix]: but we don't sneeze any K's
[choroba]: we do
[Eily]: that was a sneeze overpowering a cough
[choroba]: Czechs sneeze "Hep-cheek"
vrk adds gingerbread cookies to the platter on the sideboard.
[erix]: I'll give that a try next time
vrk takes a cookie from the platter on the sideboard.

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2017-04-24 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (442 votes). Check out past polls.