Syntax\n------\n\nROW (<field name> <data type> [{, <field name> <data type>}... ])\n\nDescription\n-----------\n\nROW is a data type for stored procedure variables.\n\nFeatures\n\nROW fields as normal variables\n\nROW fields (members) act as normal variables, and are able to appear in all query parts where a stored procedure variable is allowed:\n\n Assignment is using the := operator and the SET command:\n\n``sql\na.x:= 10;\na.x:= b.x;\nSET a.x= 10, a.y=20, a.z= b.z;\n`\n\n Passing to functions and operators:\n\n`sql\nSELECT f1(rec.a), rec.a<10;\n`\n\n Clauses (select list, WHERE, HAVING, LIMIT, etc...,):\n\n`sql\nSELECT var.a, t1.b FROM t1 WHERE t1.b=var.b LIMIT var.c;\n`\n\n INSERT values:\n\n`sql\nINSERT INTO t1 VALUES (rec.a, rec.b, rec.c);\n`\n\n SELECT .. INTO targets:\n\n`sql\nSELECT a,b INTO rec.a, rec.b FROM t1 WHERE t1.id=10;\n`\n\n Dynamic SQL out parameters (EXECUTE and EXECUTE IMMEDIATE)\n\n`sql\nEXECUTE IMMEDIATE 'CALL proc_with_out_param(?)' USING rec.a;\n`\n\nROW type variables as FETCH targets\n\nROW type variables are allowed as FETCH targets:\n\n`sql\nFETCH cur INTO rec;\n`\n\nwhere cur is a CURSOR and rec is a ROW type stored procedure variable.\n\nNote, currently an attempt to use FETCH for a ROW type variable returns this error:\n\n`sql\nERROR 1328 (HY000): Incorrect number of FETCH variables\n`\n\nFETCH from a cursor cur into a ROW variable rec works as follows:\n\n The number of fields in cur must match the number of fields in rec. Otherwise, an error is reported.\n 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.\n Field names in rec are not important and can differ from field names in cur.\n\nSee FETCH Examples (below) for examples of using this withsql_mode=ORACLE and sql_mode=DEFAULT.\n\nROW type variables as SELECT...INTO targets\n\nROW type variables are allowed as SELECT..INTO targets with some differences depending on which sql_mode is in use.\n\n When using sql_mode=ORACLE, table%ROWTYPE and cursor%ROWTYPE variables can be used as SELECT...INTO targets.\n Using multiple ROW variables in the SELECT..INTO list will report an error.\n Using ROW variables with a different column count than in the SELECT..INTO list will report an error.\n\nSee SELECT...INTO Examples (below) for examples of using this with sql_mode=ORACLE and sql_mode=DEFAULT.\n\nFeatures not implemented\n\nThe following features are planned, but not implemented yet:\n\n Returning a ROW type expression from a stored function (see MDEV-12252). This will need some grammar change to support field names after parentheses:\n\n`sql\nSELECT f1().x FROM DUAL;\n`\n\n Returning a ROW type expression from a built-in hybrid type function, such as CASE, IF, etc.\n* ROW of ROW` values\n\nExamples\n--------\n\nDELIMITER $$\nCREATE PROCEDURE p1()\nBEGIN\n  DECLARE r ROW (c1 INT, c2 VARCHAR(10));\n  SET r.c1= 10;\n  SET r.c2= 'test';\n  INSERT INTO t1 VALUES (r.c1, r.c2);\nEND;\n$$\nDELIMITER ;\nCALL p1();\n\nURL: https://mariadb.com/docs/server/reference/data-types/string-data-types/row