|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to get the generator info
Hi Everyone,
I am using Firebird and PHP. I need to get the value of a code that was generated by a generator to insert the value into another table. Any ideas?? This is what I am trying to do: $query = "INSERT INTO TABLE(COD) VALUES (gen_id(cod_cad,1))"; $query = "select gen_id(cod_cad, 1) as cod from RDB$DATABASE;"; But it tell me that the table does not exist. And Also how I am totally lost on that. ![]() Anna |
|
#2
|
|||
|
|||
|
you can use a procedure like this:
CREATE PROCEDURE "getMygen" RETURNS ( "ID" INTEGER ) AS BEGIN ID = gen_id(yourGen,0); SUSPEND; WHEN ANY DO SUSPEND; END |
|
#3
|
|||
|
|||
|
How can I get the procedure value to PHP
Thank you. It worked, but how do I get the value now???
![]() Anna |
|
#4
|
|||
|
|||
|
Quote:
I think it's better to ask on PHP area for this |
|
#5
|
|||
|
|||
|
this works for me
(Delphi ADO)
try qADO_GEN_PK_CONSTITUENTS:=TADOQuery.Create(owner); qADO_GEN_PK_CONSTITUENTS.connection:=dm.Constituent; with qADO_GEN_PK_CONSTITUENTS do begin close; sql.clear; sql.add('SELECT GEN_ID(GEN_PK_CONSTITUENTS,1) AS RESULT'); sql.add('FROM RDB$DATABASE'); open; end; GEN_PK_CONSTITUENTS_ConstituentID:=qADO_GEN_PK_CONSTITUENTS.fieldbyname('RESULT').asinteger; finally qADO_GEN_PK_CONSTITUENTS.Free; qADO_GEN_PK_CONSTITUENTS:=nil; end; GEN_PK_CONSTITUENTS is my generator. there is an insert trigger too on the gen table. Sam H. |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > How to get the generator info |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|