Van said:
Generally, Query processing does not have any way for you to customise the
error-handling AFAIK.
Well, can you pay general regard to errors (though in the OP's specific
case if the parameter value is of the wrong type the query won't
actually be executed, of course).
Take for example a table with a UNIQUE constraint:
CREATE TABLE Test (
key_col INTEGER NOT NULL UNIQUE,
data_col INTEGER NOT NULL
)
;
some existing data:
INSERT INTO Test (key_col, data_col)
VALUES (1, 1)
;
and a procedure ('parameter query') to add a new row:
CREATE PROCEDURE Proc1Test (
arg_key_col INTEGER,
arg_data_col INTEGER
) AS
INSERT INTO Test (key_col, data_col)
VALUES (arg_key_col, arg_data_col)
;
Try executing this with data that would fall foul of the unique
constraint:
EXECUTE Proc1Test 1, 2
;
and your get an error, '...were not successful because they would
create duplicate values...'
Now consider a revised procedure that 'handles' the error:
CREATE PROCEDURE Proc2Test (
arg_key_col INTEGER,
arg_data_col INTEGER
) AS
INSERT INTO Test (key_col, data_col)
SELECT DISTINCT arg_key_col, arg_data_col
FROM Test AS T1
WHERE NOT EXISTS (
SELECT *
FROM Test AS T2
WHERE arg_key_col = T2.key_col
)
;
Executing this with data that would fall foul of the unique constraint
does not cause an error:
EXECUTE Proc1Test 1, 2
;
The INSERT fails, a fact that can be detected by examining the 'rows
affected' property.
Personally, I wouldn't do it this way but then I don't have a problem
with this engine messages that have been branded as *ugly* <g>. I'd
rather have an error I can trap, rather than a simple success/failure
flag.
Jamie.
--