Reference Guide > TDV SQL Script > SQL Script Examples > Example 8 (Prepackaged Query)
 
Example 8 (Prepackaged Query)
This example calls a prepackaged query, and returns the first row of data. It assumes that the user has a prepackaged query named, pqAccess, under the shared folder.
PROCEDURE prepackaged_query_example ()
BEGIN
  -- Declare a cursor to retrieve from the prepackaged query
  DECLARE myRow ROW(a1 INT, a2 VARCHAR, a3 VARCHAR, a4 DECIMAL, a5 INT,                              a6 DECIMAL, a7 VARCHAR, a8 VARCHAR);
  DECLARE crs cursor(a1 int, a2 VARCHAR, a3 VARCHAR, a4 DECIMAL, a5 INT,                              a6 DECIMAL, a7 VARCHAR, a8 VARCHAR);
 
  CALL /shared/pqAccess(crs);
  -- Fetch the first row
  FETCH crs INTO myRow;
END