ROW
ROW is a data type used in stored programs to store a complete row of data from a cursor or table.
Syntax
ROW (<field name> <data type> [{, <field name> <data type>}... ])Description
ROW is a data type for stored procedure variables.
Features
ROW fields as normal variables
ROW fields (members) act as normal variables, and are able to appear in all query parts where a stored procedure variable is allowed:
Assignment is using the
:=operator and the SET command:
a.x:= 10;
a.x:= b.x;
SET a.x= 10, a.y=20, a.z= b.z;Passing to functions and operators:
SELECT f1(rec.a), rec.a<10;Clauses (select list, WHERE, HAVING, LIMIT, etc...,):
INSERTvalues:
SELECT .. INTOtargets:
Dynamic SQL out parameters (EXECUTE and EXECUTE IMMEDIATE)
ROW type variables as FETCH targets
ROW type variables are allowed as FETCH targets:
where cur is a CURSOR and rec is a ROW type stored procedure variable.
Note, currently an attempt to use FETCH for a ROW type variable returns this error:
FETCH from a cursor cur into a ROW variable rec works as follows:
The number of fields in
curmust match the number of fields inrec. Otherwise, an error is reported.Assignment is done from left to right. The first cursor field is assigned to the first variable field, the second cursor field is assigned to the second variable field, etc.
Field names in
recare not important and can differ from field names incur.
See FETCH Examples (below) for examples of using this withsql_mode=ORACLE and sql_mode=DEFAULT.
ROW type variables as SELECT...INTO targets
SELECT...INTO targetsROW type variables are allowed as SELECT..INTO targets with some differences depending on which sql_mode is in use.
When using
sql_mode=ORACLE,table%ROWTYPEandcursor%ROWTYPEvariables can be used asSELECT...INTOtargets.Using multiple
ROWvariables in theSELECT..INTOlist will report an error.Using
ROWvariables with a different column count than in theSELECT..INTOlist will report an error.
See SELECT...INTO Examples (below) for examples of using this with sql_mode=ORACLE and sql_mode=DEFAULT.
Features not implemented
The following features are planned, but not implemented yet:
Returning a
ROWtype expression from a stored function (see MDEV-12252). This will need some grammar change to support field names after parentheses:
Returning a
ROWtype expression from a built-in hybrid type function, such asCASE,IF, etc.ROWofROWvalues
Examples
Declaring a ROW in a stored procedure
FETCH Examples
A complete FETCH example for sql_mode=ORACLE:
A complete FETCH example for sql_mode=DEFAULT:
SELECT...INTO Examples
A SELECT...INTO example for sql_mode=DEFAULT:
The above example returns:
A SELECT...INTO example for sql_mode=ORACLE:
The above example returns:
An example for sql_mode=ORACLE using table%ROWTYPE variables as SELECT..INTO targets:
The above example returns:
An example for sql_mode=ORACLE using cursor%ROWTYPE variables as SELECT..INTO targets:
The above example returns:
Row Table example:
See Also
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

