MySQL Forums
Forum List  »  Newbie

Re: Need a 'mysql_insert_id()' code sample
Posted by: David Johnson
Date: August 17, 2004 11:39AM

I realize you are looking for C code, but here is a Perl example:

$fnames = "(ca_key, ca_net_id, ca_start_dt, ca_status)";
$values = "(\"$sess_key\", \"$id\", \"$cst_time\", \"Pending\")";
$query = "insert into curr_auth $fnames VALUES $values;";
@qres = do_query($query);
if ($numRows == 0) { die "Fatal: Could not insert into CA"; }

$query = "select LAST_INSERT_ID();";
@qres = do_query($query);
if ($numRows == 0) { die "Fatal: No New CA Number."; }
$new_ca_nbr = $qres[0]+0;

$query = "update user_session set us_ca_nbr=\"$new_ca_nbr\" where us_key=\"$sess_key\";";
@qres = do_query($query);
if ($numRows == 0) { die "Fatal: Could not update User Session with new CA nbr=$new_ca_nbr"; }

Options: ReplyQuote


Subject
Written By
Posted
Re: Need a 'mysql_insert_id()' code sample
August 17, 2004 11:39AM
August 18, 2004 12:15PM
August 19, 2004 03:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.