Re: Re: Simple search question
От | Michael Fork |
---|---|
Тема | Re: Re: Simple search question |
Дата | |
Msg-id | Pine.BSI.4.21.0006122227180.11028-100000@glass.toledolink.com обсуждение исходный текст |
Ответ на | Re: Simple search question (Alex <gliathit@ihug.com.au>) |
Список | pgsql-sql |
Judging by the PHP Manual -- http://www.php.net/manual/function.pg-getlastoid.php -- it appears that the pg_GetLastOid command returns the last OID for the given result, and therefore would be unaffected by other inserted records. From the manual: int pg_getlastoid (int result_id) -- can be used to retrieve the Oid assigned to an inserted tuple if the result identifier is used from the last command sent via pg_Exec() and was an SQL INSERT. This function will return a positive integer if there was a valid Oid. It will return -1 if an error occured or the last command sent via pg_Exec() was not an INSERT. Michael Fork - CCNA - MCP - A+ Network Support - Toledo Internet Access - Toledo Ohio On Tue, 13 Jun 2000, Alex wrote: > Hi, > > > What language is your "script" written in? Based on some previous posts, > > I guess you're talking about a PHP script. How did you add the tuple? > > I'd guess with a pg_Exec(connect_id,"INSERT ...."). From reading the doc, > > I think that you can get the row just inserted by using the pg_fetch_row() > > function, passing it the result from the pg_Exec and asking for row 0. > > OK, I just tried pg_fetch_array() and the above didn't work. > > > I have not yet gotten anything running with PHP (lack of time to "play"), > > For someone who hasn't had time to play, you certainly know alot about php :) > > If you need any examples, I'd be willing to post them, time permitting. > I thought libpq was easy to use, this is very straightforward. I have been > 'playing' with it for a few days, and it is my development tool of choice > now. Of course, this is because of faster development time, don't expect > Yahoo! to replace their cgi with PHP just yet. > > > so I can't test this. If it doesn't work, I'd try using pg_GetLastOid() > > to get the OID of the inserted row. The use the pg_Exec and SELECT > > * WHERE OID=oid-value, followed by pg_fetch_row(). > > Thanks John, and the other person that replied to my email (I know it is a > bit of a stupid question, but in such an unpopulated list, I don't think > there's any reason to post privately). > This leads to another question. If someone adds another row during this, > what will happen? > > Thanks, > Alex >
В списке pgsql-sql по дате отправления: