Subject | Re: [firebird-support] Set term gives Token unknown error |
---|---|
Author | Aage Johansen |
Post date | 2008-04-25T23:02:51Z |
Stevio wrote:
accept a sequence of statements (or just one).
Drop this select. It's out of place here (and probably elsewhere as well)
-- SELECT GEN_ID(GEN_NEW_LETABLE_ID, (SELECT MAX (LETABLE_ID) FROM LETABLE))
-- FROM RDB$DATABASE;
If you need it, run it from the cursor window.
Maybe you won't need the procedure at all. Some component sets (like
IBO) have a function you can call.
E.g. assume your connection component is cnDB:
THEVALUE:=cnDB.Gen_ID('GEN_NEW_LETABLE_ID',1);
(IIRC - untested)
--
Aage J.
> Ah ok I was trying to run it in the DSQL window. (I told you I haven't usedbut it works
> this stuff in quite a while lol!)
> Why does SET TERM ^ ; not work in the DSQL window in IB_SQL, and it also
> does not work in Database Explorer (from the Enter SQL window),
> from within IB_SQL when you select Execute Script from the Connection tab?The DSQL window expects just one statement, the script window will
accept a sequence of statements (or just one).
>Sure, but you're doing too much. Reduce to:
> What I am trying to do is to create a new table and create a primary key
> generator stored procedure. Standard stuff I think?
>I would usually do a commit here.
> /* Create Table */
> CREATE TABLE LETABLE (
> LETABLE_ID INTEGER NOT NULL,
> ...more fields...
> PRIMARY KEY (LETABLE_ID)
> );
>
> /* Primary key generator */
> CREATE GENERATOR GEN_NEW_LETABLE_ID;
Drop this select. It's out of place here (and probably elsewhere as well)
-- SELECT GEN_ID(GEN_NEW_LETABLE_ID, (SELECT MAX (LETABLE_ID) FROM LETABLE))
-- FROM RDB$DATABASE;
If you need it, run it from the cursor window.
>You will need a SUSPEND here!
> SET TERM ^ ;
> CREATE TRIGGER SET_NEW_LETABLE_ID FOR LETABLE
> ACTIVE BEFORE INSERT POSITION 0
> AS
> BEGIN
> IF (NEW.LETABLE_ID IS NULL) THEN NEW.LETABLE_ID =
> GEN_ID(GEN_NEW_LETABLE_ID, 1);
> END ^
>
> CREATE PROCEDURE PROC_NEW_LETABLE_ID
> RETURNS (THE_NEW_LETABLE_ID INTEGER)
> AS
> BEGIN
> THE_NEW_LETABLE_ID = GEN_ID(GEN_NEW_LETABLE_ID, 1);
> END ^Do another commit.
> SET TERM ; ^
Maybe you won't need the procedure at all. Some component sets (like
IBO) have a function you can call.
E.g. assume your connection component is cnDB:
THEVALUE:=cnDB.Gen_ID('GEN_NEW_LETABLE_ID',1);
(IIRC - untested)
--
Aage J.