It is possible to invoke the procedure to output a data table from a table definition directly from a SQL client. This is useful primarily for debugging and for developers.
Load the updated script
\i /path/to/rpdo_refcursor.sql
Run the procedure
BEGIN;
-- 'cur' is the default cursor name
CALL usp_rpdo2(
p_table_instance_id := 322,
p_result_instance_id := NULL,
p_min_row := NULL,
p_max_row := NULL
);
-- retrieve all rows from the cursor
FETCH ALL FROM cur;
COMMIT;
Notes:
- Because
usp_rpdo2
now uses anINOUT cur REFCURSOR DEFAULT 'cur'
, you don’t need to supply a cursor name.- The
FETCH ALL FROM cur
returns every column of your pivoted result set.
Load the script
@/path/to/your_oracle_script.sql
Bind and call
VAR rc REFCURSOR;
EXEC usp_rpdo2(
p_table_instance_id => 322,
p_result_instance_id => NULL,
p_min_row => NULL,
p_max_row => NULL,
p_refcursor => :rc
);
View the cursor
PRINT rc;
Notes:
VAR rc REFCURSOR
declares a bind variable in SQL*Plus/SQL Developer.PRINT rc
streams the full result set into your grid or console.
Load the script
:r C:\path\to\rpdo2.sql
Execute the procedure
EXEC dbo.usp_rpdo2
@TABLE_INSTANCE_ID = 322,
@RESULT_INSTANCE_ID = NULL,
@MIN_ROW = NULL,
@MAX_ROW = NULL;
View results
Optionally, to capture it in a temp table for further querying:
CREATE TABLE #my_results (... define columns ...);
INSERT INTO #my_results
EXEC dbo.usp_rpdo2
@TABLE_INSTANCE_ID = 322,
@RESULT_INSTANCE_ID = NULL,
@MIN_ROW = NULL,
@MAX_ROW = NULL;
SELECT * FROM #my_results;
DROP TABLE #my_results;
Notes:
- Local
#
tables created inside a proc aren’t accessible afterward, so if you need post‑proc querying, use a global temp table (##…
) or insert the output as shown above.- In SSMS, you’ll also see the rows immediately in the grid after
EXEC
.