8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:43:03 +01:00

Improvement CORE-5658 : Execute statement with excess parameters

Documentation
This commit is contained in:
hvlad 2019-03-06 13:37:50 +02:00
parent ee3a13d5f6
commit e17bff156b

View File

@ -42,11 +42,13 @@ Syntax and notes :
| <input_parameters>, <named_parameter>
<named_parameter> ::=
<parameter name> := <expression>
[EXCESS] <parameter name> := <expression>
Syntax above introduced new parameter value binding operator ":=" to avoid
clashes with future boolean expressions.
This syntax may be changed in release version.
clashes with boolean expressions.
Optional "EXCESS" mark indicates that given parameter allows to be not
mentioned at query text. Note, all non-excess input parameters must be used
by a query.
- if ON EXTERNAL DATA SOURCE clause is omitted then
a) statement will be executed against current (local) database
@ -259,3 +261,32 @@ BEGIN
SUSPEND;
END
4. Using EXCESS input parameters
CREATE PROCEDURE P_EXCESS (A_ID INT, A_TRAN INT = NULL, A_CONN INT = NULL)
RETURNS (ID INT, TRAN INT, CONN INT)
AS
DECLARE S VARCHAR(255);
DECLARE W VARCHAR(255) = '';
BEGIN
S = 'SELECT * FROM TTT WHERE ID = :ID';
IF (A_TRAN IS NOT NULL)
THEN W = W || ' AND TRAN = :a';
IF (A_CONN IS NOT NULL)
THEN W = W || ' AND CONN = :b';
IF (W <> '')
THEN S = S || W;
-- could raise error if TRAN or CONN is null
-- FOR EXECUTE STATEMENT (:S) (a := :A_TRAN, b := A_CONN, id := A_ID)
-- OK in all cases
FOR EXECUTE STATEMENT (:S) (EXCESS a := :A_TRAN, EXCESS b := A_CONN, id := A_ID)
INTO :ID, :TRAN, :CONN
DO SUSPEND;
END