| From: | Manuel Diego <manuel(at)radiohead(dot)cl> |
|---|---|
| To: | Julio Cesar Rodriguez Dominguez <jurasec(at)gmail(dot)com> |
| Cc: | Yudelsy Castellón García <yude(at)cav(dot)desoft(dot)cu>, pgsql-es-ayuda(at)postgresql(dot)org |
| Subject: | Re: funcion... |
| Date: | 2009-08-11 14:11:33 |
| Message-ID: | 2D990732-42EF-4272-A53F-0CF81E58FB6B@radiohead.cl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-es-ayuda |
INSERT INTO prueba_serials(id,persona_nombre) VALUES(DEFAULT,'Quenita
Larrain') returning id;
El 11-08-2009, a las 0:59, Julio Cesar Rodriguez Dominguez escribió:
>
>
> El 10 de agosto de 2009 08:18, Yudelsy Castellón García <yude(at)cav(dot)desoft(dot)cu
> > escribió:
> Hola comunidad,
> Necesito saber si en postgres existe alguna función que devuelva en
> php el último id insertado en una tabla. En mysql se puede obtener
> usando la función last_insert_id.
>
> He buscado en Internet y aparece la función pg_last_oid pero no sé
> si esta me servirá.
>
> Asumiendo que tu llave es un entero con un modificador serial:
> - a la hora de insertar un registro puede usar la opción returning.
> - o consultar el valor actual del serial: select
> currval('tabla_id_seq');
>
> http://www.postgresql.org/docs/8.4/interactive/sql-insert.html
> http://www.postgresql.org/docs/8.4/interactive/functions-sequence.html
------------------------
Manuel Diego Paillafil Gamboa
manuel(at)radiohead(dot)cl
Móvil: 06 - 801 60 24
Oficina: 02 - 482 7516
Hogar: 02 - 857 32 24
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2009-08-11 15:25:47 | Re: funcion... |
| Previous Message | Julio Cesar Rodriguez Dominguez | 2009-08-11 04:59:49 | Re: funcion... |