Well I am a little anoyed as I wanted to write a basic fit for my needs app basded on firebird as I remember a previous employer used interbase a lot but I am stuck making primary keys get values automatically. knowing we have some experts on this list please help
Owen
$isql-fb Use CONNECT or CREATE DATABASE to specify a database SQL> CREATE DATABASE '/tmp/dvb4.fdb'; SQL> CREATE TABLE TABLEA ( CON> TABLEAPK BIGINT NOT NULL PRIMARY KEY , CON> TABLEANAME varchar(20) CON> ); SQL> COMMIT; SQL> CREATE GENERATOR GENPKTABLEA; SQL> COMMIT; SQL> CREATE TRIGGER BEFOREINSERTTABLEA for TABLEA CON> ACTIVE BEFORE INSERT position 0 CON> AS CON> BEGIN CON> IF(NEW.TABLEAPK IS NULL) THEN CON> NEW.TABLEAPK = GEN_ID(GENPKTABLEA, 1); Statement failed, SQLCODE = -104
Dynamic SQL Error -SQL error code = -104 -Unexpected end of command SQL> END CON>
I found the solution after a lot of blind allys
SET TERM ^ ; CREATE PROCEDURE CHANNELS_Count RETURNS ( CustomerCount Integer ) AS BEGIN SELECT COUNT(*) FROM CHANNELS INTO :CustomerCount; SUSPEND; END ^ SET TERM ; ^
Then I discovered that if using kinterbase like me if you put the hole line in one livne yu cann do the same as set term is a isql-fb interpreted issues.
sql="CREATE PROCEDURE CHANNELS_Count RETURNS ( CustomerCount Integer ) AS BEGIN SELECT COUNT(*) FROM CHANNELS INTO :CustomerCount; SUSPEND; END ;"
cursor.execute(sql)
Cool stored procedures are go
Regards
Owen
On Sun, 25 Sep 2005 12:22:42 +0100 Owen Synge owens.singh@ntlworld.com wrote:
Well I am a little anoyed as I wanted to write a basic fit for my needs app basded on firebird as I remember a previous employer used interbase a lot but I am stuck making primary keys get values automatically. knowing we have some experts on this list please help
Owen
$isql-fb Use CONNECT or CREATE DATABASE to specify a database SQL> CREATE DATABASE '/tmp/dvb4.fdb'; SQL> CREATE TABLE TABLEA ( CON> TABLEAPK BIGINT NOT NULL PRIMARY KEY , CON> TABLEANAME varchar(20) CON> ); SQL> COMMIT; SQL> CREATE GENERATOR GENPKTABLEA; SQL> COMMIT; SQL> CREATE TRIGGER BEFOREINSERTTABLEA for TABLEA CON> ACTIVE BEFORE INSERT position 0 CON> AS CON> BEGIN CON> IF(NEW.TABLEAPK IS NULL) THEN CON> NEW.TABLEAPK = GEN_ID(GENPKTABLEA, 1); Statement failed, SQLCODE = -104
Dynamic SQL Error -SQL error code = -104 -Unexpected end of command SQL> END CON>
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!