firebird
firebird copied to clipboard
Local variable as record from table row [CORE2621]
Submitted by: eXandr (i.reg)
Is related to CORE740 Replaces CORE2686 Is duplicated by CORE1998 Relate to CORE3070
Votes: 9
Syntaxis:
DECLARE VARIABLE <varname> RECORD AS [TABLE|VIEW|CURSOR|PROCEDURE[OUTPUT PARAMETERS]] <table_name|view_name|cursor_name|proc_name>;
Example: .. AS DECLARE VARIABLE r RECORD AS TABLE mytable; BEGIN ... SELECT * FROM mytable INTO :r; SELECT fld1 FROM mytable INTO :r.fld1; ... END;
Commented by: Ain Valtin (ain)
Looks like a nice feature :) Suggestion - also support to restrict the record variable to have only listed fields, ie
DECLARE VARIABLE <varname> RECORD[(field1, field2, ...)] AS ...
In that case the compiler should replace "*" in SELECT statement
SELECT * FROM mytable INTO :r;
with the field list from var declaration.