I'm trying to execute sql string be executed like this image1
but. when I execute immediate my sql string, it doesn't return to any output like the first one. how can I make it return the output without pass the output into a variable? please help
I'm trying to execute sql string be executed like this image1
but. when I execute immediate my sql string, it doesn't return to any output like the first one. how can I make it return the output without pass the output into a variable? please help
Since you are in 12c, try DBMS_SQL.RETURN_RESULT
using a REFCURSOR
over any dynamic query.
DECLARE
sqlstring VARCHAR2(2000);
cur SYS_REFCURSOR;
tab_name VARCHAR2(100) := 'YOUR_TAB_NAME';
col_name VARCHAR2(32) := 'COL_NAME';
n INT := 5;
m INT := 10;
BEGIN
sqlstring := 'SELECT '||col_name||',col1,col2,col3 FROM ' || tab_name
|| ' OFFSET ' || n || ' ROWS FETCH NEXT '
|| m || ' ROWS ONLY ';
OPEN cur FOR sqlstring;
dbms_sql.return_result(cur);
END;
/