From: | <operationsengineer1(at)yahoo(dot)com> |
---|---|
To: | "Vishal Kashyap (at) [SaiHertz]" <vishalonlist(at)gmail(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Last ID Problem |
Date: | 2005-01-31 19:36:11 |
Message-ID: | 20050131193611.97235.qmail@web52409.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers 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(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-01-31 19:36:33 | Re: [BUGS] Bug in create operator and/or initdb |
Previous Message | Greg Stark | 2005-01-31 19:35:58 | Re: [BUGS] Bug in create operator and/or initdb |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2005-01-31 19:46:01 | Re: How to learn Postgres? |
Previous Message | Vishal Kashyap @ [SaiHertz] | 2005-01-31 19:25:55 | Re: Last ID Problem |