Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-novice

> $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,,

In response to


pgsql-novice by date

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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group