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: 77b69d2105013111251fac2451@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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

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-2014 The PostgreSQL Global Development Group