Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 26th, 2006, 05:18 PM
apalm apalm is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 3 apalm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 41 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old June 27th, 2006, 01:24 AM
sethRo sethRo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 9 sethRo User rank is Sergeant (500 - 2000 Reputation Level)sethRo User rank is Sergeant (500 - 2000 Reputation Level)sethRo User rank is Sergeant (500 - 2000 Reputation Level)sethRo User rank is Sergeant (500 - 2000 Reputation Level)sethRo User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 21 h 38 m 36 sec
Reputation Power: 0
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

Reply With Quote
  #3  
Old June 27th, 2006, 12:46 PM
apalm apalm is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 3 apalm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 41 sec
Reputation Power: 0
How can I get the procedure value to PHP

Thank you. It worked, but how do I get the value now???






Anna

Reply With Quote
  #4  
Old June 29th, 2006, 03:00 AM
sethRo sethRo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 9 sethRo User rank is Sergeant (500 - 2000 Reputation Level)sethRo User rank is Sergeant (500 - 2000 Reputation Level)sethRo User rank is Sergeant (500 - 2000 Reputation Level)sethRo User rank is Sergeant (500 - 2000 Reputation Level)sethRo User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 21 h 38 m 36 sec
Reputation Power: 0
Quote:
Originally Posted by apalm
Thank you. It worked, but how do I get the value now???






Anna


I think it's better to ask on PHP area for this

Reply With Quote
  #5  
Old July 10th, 2006, 03:54 PM
samh5792 samh5792 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 8 samh5792 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 30 m 52 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > How to get the generator info


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway