Skip to content

Instantly share code, notes, and snippets.

@agonen
Created May 19, 2014 16:16
Show Gist options
  • Select an option

  • Save agonen/c90821ff4e481aca42c8 to your computer and use it in GitHub Desktop.

Select an option

Save agonen/c90821ff4e481aca42c8 to your computer and use it in GitHub Desktop.
print_table.sql
-- taken from http://orasql.org/2013/04/02/sqlplus-tips-2/
-- show output
set termout on
-- but without echo
set echo off
-- without newpage on start:
set embedded on
-- scrolling control
set pause on
-- two lines between rows:
set newpage 2
-- text for prompt after each page:
set pause "Press Enter to view next row..."
-- new page on new "row_num"
break on row_num skip page
-- main query:
select *
from
xmltable( 'for $a at $i in /ROWSET/ROW
,$r in $a/*
return element ROW{
element ROW_NUM{$i}
,element COL_NAME{$r/name()}
,element COL_VALUE{$r/text()}
}'
passing xmltype(cursor( &1 ))
columns
row_num int
,col_name varchar2(30)
,col_value varchar2(100)
);
-- disabling pause and breaks:
set pause off
clear breaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment