Subject | RE: [IBO] How do I execute a complex script with IBO? |
---|---|
Author | Dmitry Beloshistov |
Post date | 2012-08-23T11:07:33Z |
Hi!
Use TIB_Script instead.
WBR, Dmitry Beloshistov AKA [-=BDS=-]
From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf Of masonwheeler
Sent: Thursday, August 23, 2012 5:14 AM
To: IBObjects@yahoogroups.com
Subject: [IBO] How do I execute a complex script with IBO?
I'm trying to build a script-executor to simplify DB maintenance. The
first thing that needs to be done is to bootstrap the database and set
up a table to record which scripts have already been run against it, so
it will detect if the table exists, and if not, try to run this:
<pre>
CREATE SEQUENCE GEN_DB_HISTORY_ID;
ALTER SEQUENCE GEN_DB_HISTORY_ID RESTART WITH 0;
CREATE TABLE DB_HISTORY (
ID INTEGER NOT NULL,
SCRIPT_TIME TIMESTAMP NOT NULL,
SCRIPT_NAME VARCHAR(255) CHARACTER SET UTF8 NOT NULL,
PRIMARY KEY (ID)
);
SET TERM ^ ;
CREATE TRIGGER DB_HISTORY_BI FOR DB_HISTORY
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(GEN_DB_HISTORY_ID,1);
END^
SET TERM ; ^
</pre>
If I try to run the whole thing in a TIBQuery, I get an error on the
second command. Apparently it doesn't like multiple commands in one
Execute call.
So I try to run the four commands one at a time, and the first three
run, but on the fourth one, it gives an error message:
ISC ERROR CODE:335544569
ISC ERROR MESSAGE:
Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 5
TERM
So apparently it doesn't like SET TERM.
I can run this script as one big script from SQL management tools. So
what am I missing? Why doesn't it work from a TIBQuery? What do I have
to do to be able to run a complex script in IBObjects?
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
Use TIB_Script instead.
WBR, Dmitry Beloshistov AKA [-=BDS=-]
From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf Of masonwheeler
Sent: Thursday, August 23, 2012 5:14 AM
To: IBObjects@yahoogroups.com
Subject: [IBO] How do I execute a complex script with IBO?
I'm trying to build a script-executor to simplify DB maintenance. The
first thing that needs to be done is to bootstrap the database and set
up a table to record which scripts have already been run against it, so
it will detect if the table exists, and if not, try to run this:
<pre>
CREATE SEQUENCE GEN_DB_HISTORY_ID;
ALTER SEQUENCE GEN_DB_HISTORY_ID RESTART WITH 0;
CREATE TABLE DB_HISTORY (
ID INTEGER NOT NULL,
SCRIPT_TIME TIMESTAMP NOT NULL,
SCRIPT_NAME VARCHAR(255) CHARACTER SET UTF8 NOT NULL,
PRIMARY KEY (ID)
);
SET TERM ^ ;
CREATE TRIGGER DB_HISTORY_BI FOR DB_HISTORY
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(GEN_DB_HISTORY_ID,1);
END^
SET TERM ; ^
</pre>
If I try to run the whole thing in a TIBQuery, I get an error on the
second command. Apparently it doesn't like multiple commands in one
Execute call.
So I try to run the four commands one at a time, and the first three
run, but on the fourth one, it gives an error message:
ISC ERROR CODE:335544569
ISC ERROR MESSAGE:
Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 5
TERM
So apparently it doesn't like SET TERM.
I can run this script as one big script from SQL management tools. So
what am I missing? Why doesn't it work from a TIBQuery? What do I have
to do to be able to run a complex script in IBObjects?
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]