Subject | Using DDL in ib objects |
---|---|
Author | peter@cyionics.com |
Post date | 2003-11-12T18:09:34Z |
Hi all
I am writing an application that will update the structure for mone release to the next.
I plan to include a file with the upgrade info in, the application will check the release of the database it is about to upgrade by looking in a release table, if all is ok it will run the DDL/SQL to modify the tables / procedures etc.
My problem is I am not sure of the syntax
I have been trying to create a dummy procedure as a test, I extracted the DDL using workbench.
I have tried both an IB_DSQL and an IB_Query but I am obviously doing something major wrong.
Could somebody point me in the right direction.
After this I want to modify existing stored procedures and tables.
Rgds
Peter
My delphi code using an IB_Query is
with IB_Query1 do
begin
sql.LoadFromFile('sql\update2-3.sql');
If not prepared then Prepare;
ExecSQL;
close;
end;
or using an IB_DSQL
with IB_DSQL1 do
begin
sql.LoadFromFile('sql\update2-3.sql');
If not prepared then Prepare;
ExecSQL;
close;
end;
The DDL for the stored procedure is (saved in file update203.sql)
SET TERM ^^;
CREATE PROCEDURE P_DUMMY_SELL_PIN (
INDEX_ID Integer)
returns (
RETURN_VAL Integer)
AS
/*
Procedure:
Author : PJC
Date : 14/08/2003
Purpose : alter status of pin to sold
Params
------
<param> : INDEX_ID unique key-id to pin
*/
begin
/* code */
RETURN_VAL = 0;
IF (EXISTS ( SELECT ID FROM PINS WHERE ID = :INDEX_ID and STATUS = 1 )) THEN
BEGIN
UPDATE PINS SET
STATUS = 4,
STATUS_CHANGED = 'NOW'
WHERE ID = :INDEX_ID;
RETURN_VAL = :INDEX_ID;
END
end
^^
SET TERM; ^^
[Non-text portions of this message have been removed]
I am writing an application that will update the structure for mone release to the next.
I plan to include a file with the upgrade info in, the application will check the release of the database it is about to upgrade by looking in a release table, if all is ok it will run the DDL/SQL to modify the tables / procedures etc.
My problem is I am not sure of the syntax
I have been trying to create a dummy procedure as a test, I extracted the DDL using workbench.
I have tried both an IB_DSQL and an IB_Query but I am obviously doing something major wrong.
Could somebody point me in the right direction.
After this I want to modify existing stored procedures and tables.
Rgds
Peter
My delphi code using an IB_Query is
with IB_Query1 do
begin
sql.LoadFromFile('sql\update2-3.sql');
If not prepared then Prepare;
ExecSQL;
close;
end;
or using an IB_DSQL
with IB_DSQL1 do
begin
sql.LoadFromFile('sql\update2-3.sql');
If not prepared then Prepare;
ExecSQL;
close;
end;
The DDL for the stored procedure is (saved in file update203.sql)
SET TERM ^^;
CREATE PROCEDURE P_DUMMY_SELL_PIN (
INDEX_ID Integer)
returns (
RETURN_VAL Integer)
AS
/*
Procedure:
Author : PJC
Date : 14/08/2003
Purpose : alter status of pin to sold
Params
------
<param> : INDEX_ID unique key-id to pin
*/
begin
/* code */
RETURN_VAL = 0;
IF (EXISTS ( SELECT ID FROM PINS WHERE ID = :INDEX_ID and STATUS = 1 )) THEN
BEGIN
UPDATE PINS SET
STATUS = 4,
STATUS_CHANGED = 'NOW'
WHERE ID = :INDEX_ID;
RETURN_VAL = :INDEX_ID;
END
end
^^
SET TERM; ^^
[Non-text portions of this message have been removed]