Re: Last ID Problem - Mailing list pgsql-novice

From
Subject Re: Last ID Problem
Date
Msg-id 20050131193611.97235.qmail@web52409.mail.yahoo.com
Whole thread Raw
In response to Re: Last ID Problem  ("Vishal Kashyap @ [SaiHertz]" <vishalonlist@gmail.com>)
Responses Re: Last ID Problem  ("Vishal Kashyap @ [SaiHertz]" <vishalonlist@gmail.com>)
List pgsql-novice
Vishal,

will your suggestion protect my db if I have two
customers with the same name?  does it always return
the highest cust_id and is that *always* the last
cust_id entered?

tia...

--- "Vishal Kashyap @ [SaiHertz]"
<vishalonlist@gmail.com> wrote:

> 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
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

pgsql-novice by date:

Previous
From: "Vishal Kashyap @ [SaiHertz]"
Date:
Subject: Re: Last ID Problem
Next
From: Michael Fuhr
Date:
Subject: Re: How to learn Postgres?