Re: Last ID Problem

From: "Vishal Kashyap (at) [SaiHertz]" <vishalonlist(at)gmail(dot)com>
To: "operationsengineer1(at)yahoo(dot)com" <operationsengineer1(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Last ID Problem
Date: 2005-01-31 19:25:55
Message-ID: 77b69d2105013111251fac2451@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-novice

Hi,

> $id = "SELECT currval('cust_id')"; // used in an
> attempt to get last id (colum 'cust id')entered into
> db.
>
> $result = $db->Execute($sql); // works fine.
>
> $id_result = $db->execute($id); // $id_result has no
> value.

This is because currval fetched data during a transaction process and
not after the process is complete.

the best way I suggest is

$id = "SELECT cust_id from customer where customer_name ='$cust'
order by cust_id desc limit1" ; // used in an

--
With Best Regards,
Vishal Kashyap.
Lead Software Developer,
http://saihertz.com,
http://vishalkashyap.tk

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-01-31 19:26:24 Re: Allow GRANT/REVOKE permissions to be applied to all schema objects with one command
Previous Message Victor Yegorov 2005-01-31 19:15:59 Combining index scans

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2005-01-31 19:36:11 Re: Last ID Problem
Previous Message operationsengineer1 2005-01-31 19:13:58 Last ID Problem