Generate HTML report for SQL Query using SQL* Plus
SQL* Plus allow us to generate an HTML report using SQLPLUS -MARKUP “HTML ON” or SET MARKUP HTML ON SPOOL ON commands.- set markup html on spool on – specifies that output will be in HTML. You can specify any valid HTML or CSS syntax in the head section.
- set markup html off – stops HTML formatting.
$cat report.sh
#!/bin/bash
user=scott
pass=tiger
sqlplus -s $user/$pass<
set feedback off;
set linesize 600;
set pagesize 1;
set heading off;
!echo "Employee Data"
select * from emp;
!echo "Department Data"
select * from dept;
exit
EOF
Give the executable permission to script by below command
$chmod a+x report.sh
Now run the script and save the output in html file like below
$sh report.sh>myreport.html
Now you can open the "myreport.html" in browser
Note:-You can put any number of queries in script
No comments:
Post a Comment