| |
|
Test the contents of a cursor variable
Cursor variables are variables that point to underlying (Oracle SGA-based) result sets. You can pass a cursor variable from one PL/SQL program to another, or even pass it back to a non-PL/SQL host language, like Java, which can easily and simply fetch rows from the cursor variable. Quest Code Tester for Oracle makes it very easy to test the contents of cursor variables by generating all the code needed to transfer the data to collections which can then be compared to other datasets.
Flash tutorial explaining the topic: A brief video that shows you how to use Quest Code Tester to solve the problem posed by this topic. Step-by-step instructions: Follow these steps to replicate what we show you in the tutorial. StepsFrom the Test Dashboard, ask to create a new test definition. Select qctod# rows_from_table from the list and press OK. Now you are inside Test Builder. All rows and columns
In other words, that is all I have to do to have Quest Code Tester generate all necessary code to compare the contents of the cursor variable to the employees table! Just last name and salary, all rows
select last_name,salary from qctod#employees
In other words, that is all I have to do to have Quest Code Tester generate all necessary code to compare the contents of the cursor variable to a query (subset of a table)! Just last name and salary for all employees in department 10
select last_name,salary from qctod#employees where department_id = 10
Time to run your test!On the bottom right of Test Builder, select Save, Close and Run. Quest Code Tester for Oracle will then save your definition to the repository, and run your test. You should see the Results Viewer and a green flag, indicating a successful run. Source code of program tested: Compile this code in your schema so that you can build your test definition for it. CREATE OR REPLACE FUNCTION qctod#rows_from_table ( table_in IN VARCHAR2 , column_list_in IN VARCHAR2 DEFAULT NULL ) RETURN sys_refcursor IS CV sys_refcursor; BEGIN OPEN CV FOR 'select ' || NVL (column_list_in, '*') || ' from ' || table_in; RETURN CV; END qctod#rows_from_table; / |
|