Question & Answer
Question
How do I use a RECORD variable in stored procedures?
Answer
In a stored procedure execution, you can use the RECORD variable to temporarily store the result set. For more information, refer to the IBM Netezza Stored Procedures Developer's Guide.
The example below provides a supplemental example using the RECORD variable.
CREATE OR REPLACE PROCEDURE my_proc2() RETURNS INT LANGUAGE NZPLSQL ASBEGIN_PROC DECLARE row RECORD; myrecord RECORD; BEGIN FOR row IN SELECT * FROM my_proc1_tab LOOP RAISE NOTICE 'Values are %, % and %', row.col1, row.col2, row.col3; END LOOP; SELECT * INTO myrecord FROM my_proc1_tab; IF NOT FOUND THEN RAISE EXCEPTION 'Unable to load record from table.'; ELSE RAISE NOTICE 'Record loaded from table.'; END IF; END; END_PROC; |
The result of the procedure is the following output:
host(admin)=> CALL my_proc2(); |
[{"Product":{"code":"SSULQD","label":"IBM PureData System"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":null,"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]
Historical Number
NZ716336
Was this topic helpful?
Document Information
Modified date:
17 October 2019
UID
swg21567340