Subject | Creating Stored Procedures |
---|---|
Author | Tom Suhler |
Post date | 2004-04-06T14:29:03Z |
I am using DSQL tab in IB_SQL.EXE to create Stored Procedures into a
FireBird 1.0.3 database.
I have created several Stored Procedures successfully but have run into some
problems creating the 2 listed below:
The following generates a error "Unsupported Column type: 0." when I select
the Prepare Statement button.
It appears to have a problem with the line: " I = :V_FIRST_HISTORY_ORDER;"
CREATE PROCEDURE DELETE_PRICE_HISTORY_OBJECT (
V_OBJECT_ID INTEGER,
V_FIRST_HISTORY_ORDER SMALLINT,
V_LAST_HISTORY_ORDER SMALLINT
) AS
DECLARE VARIABLE I SMALLINT;
BEGIN
I = :V_FIRST_HISTORY_ORDER;
WHILE ( I <= :V_LAST_HISTORY_ORDER ) DO
BEGIN
DELETE FROM price_history WHERE ( map_object_id = :v_object_id AND
history_order = :I );
I = I + 1;
END
END
With the next stored procedure I can Prepare and Execute with no problem.
When I select the Post Data button I receive the following:
Error Message
"ISC ERROR CODE:335544343
ISC ERROR MESSAGE:
invalid request BLR at offset 363
bad parameter number"
SQL Message
"SQL ERROR CODE:-104
SQL ERROR MESSAGE:
Invalid token"
CREATE PROCEDURE SAVE_PRICE_HISTORY_OBJECT (
V_OBJECT_ID INTEGER,
V_HISTORY_ORDER SMALLINT,
V_HISTORY_STATUS SMALLINT,
V_TOTAL_PRICE NUMERIC(10,2),
V_PRICE_PER_UNIT NUMERIC(10,2),
V_UNIT VARCHAR(20),
V_UNITS NUMERIC(8,4),
V_CONTACT VARCHAR(100),
V_FINAL_DATE DATE,
V_INITIAL_DATE DATE
) AS
DECLARE VARIABLE I INTEGER;
BEGIN
SELECT COUNT(*) FROM price_history WHERE ( map_object_id = :v_object_id AND
history_order = :v_history_order ) INTO I;
/* create record */
IF ( I = 0 ) THEN
BEGIN
INSERT INTO price_history (map_object_id, history_order, history_status,
total_price, price_per_unit, unit, units, contact, final_date,
initial_date )
VALUES (:v_object_id, :v_history_order, :v_history_status,
:v_total_price, :v_price_per_unit, :v_unit, :v_units, :v_contact,
:v_final_date, :v_initial_date);
END
/* update record */
ELSE
BEGIN
UPDATE price_history SET history_status = :v_history_status, total_price
= :v_total_price, price_per_unit = :v_price_per_unit, unit = :v_unit, units
= :v_units, contact = :v_contact, final_date = :v_final_date, initial_date =
:v_initial_date
WHERE ( map_object_id = :v_object_id AND history_order =
:v_history_order );
END
END
The following is the relevant table information
CREATE TABLE PRICE_HISTORY ( MAP_OBJECT_ID INTEGER, HISTORY_ORDER SMALLINT
NOT NULL, HISTORY_STATUS SMALLINT NOT NULL, TOTAL_PRICE NUMERIC(10,2),
PRICE_PER_UNIT NUMERIC(10,2), UNIT VARCHAR(20), UNITS NUMERIC(10,2), CONTACT
VARCHAR(100), NOTES BLOB SUB_TYPE 1, FINAL_DATE DATE, INITIAL_DATE
ATE );Any help would be greatly appreciated.Thnak you.
[Non-text portions of this message have been removed]
FireBird 1.0.3 database.
I have created several Stored Procedures successfully but have run into some
problems creating the 2 listed below:
The following generates a error "Unsupported Column type: 0." when I select
the Prepare Statement button.
It appears to have a problem with the line: " I = :V_FIRST_HISTORY_ORDER;"
CREATE PROCEDURE DELETE_PRICE_HISTORY_OBJECT (
V_OBJECT_ID INTEGER,
V_FIRST_HISTORY_ORDER SMALLINT,
V_LAST_HISTORY_ORDER SMALLINT
) AS
DECLARE VARIABLE I SMALLINT;
BEGIN
I = :V_FIRST_HISTORY_ORDER;
WHILE ( I <= :V_LAST_HISTORY_ORDER ) DO
BEGIN
DELETE FROM price_history WHERE ( map_object_id = :v_object_id AND
history_order = :I );
I = I + 1;
END
END
With the next stored procedure I can Prepare and Execute with no problem.
When I select the Post Data button I receive the following:
Error Message
"ISC ERROR CODE:335544343
ISC ERROR MESSAGE:
invalid request BLR at offset 363
bad parameter number"
SQL Message
"SQL ERROR CODE:-104
SQL ERROR MESSAGE:
Invalid token"
CREATE PROCEDURE SAVE_PRICE_HISTORY_OBJECT (
V_OBJECT_ID INTEGER,
V_HISTORY_ORDER SMALLINT,
V_HISTORY_STATUS SMALLINT,
V_TOTAL_PRICE NUMERIC(10,2),
V_PRICE_PER_UNIT NUMERIC(10,2),
V_UNIT VARCHAR(20),
V_UNITS NUMERIC(8,4),
V_CONTACT VARCHAR(100),
V_FINAL_DATE DATE,
V_INITIAL_DATE DATE
) AS
DECLARE VARIABLE I INTEGER;
BEGIN
SELECT COUNT(*) FROM price_history WHERE ( map_object_id = :v_object_id AND
history_order = :v_history_order ) INTO I;
/* create record */
IF ( I = 0 ) THEN
BEGIN
INSERT INTO price_history (map_object_id, history_order, history_status,
total_price, price_per_unit, unit, units, contact, final_date,
initial_date )
VALUES (:v_object_id, :v_history_order, :v_history_status,
:v_total_price, :v_price_per_unit, :v_unit, :v_units, :v_contact,
:v_final_date, :v_initial_date);
END
/* update record */
ELSE
BEGIN
UPDATE price_history SET history_status = :v_history_status, total_price
= :v_total_price, price_per_unit = :v_price_per_unit, unit = :v_unit, units
= :v_units, contact = :v_contact, final_date = :v_final_date, initial_date =
:v_initial_date
WHERE ( map_object_id = :v_object_id AND history_order =
:v_history_order );
END
END
The following is the relevant table information
CREATE TABLE PRICE_HISTORY ( MAP_OBJECT_ID INTEGER, HISTORY_ORDER SMALLINT
NOT NULL, HISTORY_STATUS SMALLINT NOT NULL, TOTAL_PRICE NUMERIC(10,2),
PRICE_PER_UNIT NUMERIC(10,2), UNIT VARCHAR(20), UNITS NUMERIC(10,2), CONTACT
VARCHAR(100), NOTES BLOB SUB_TYPE 1, FINAL_DATE DATE, INITIAL_DATE
ATE );Any help would be greatly appreciated.Thnak you.
[Non-text portions of this message have been removed]