Create an HTML page with Oracle's SQL * PLUS tool

zhaozj2021-02-16  44

Create an HTML page with Oracle's SQL * PLUS tool

Author: Fenng

Oracle's SQL * Plus tool has some more interesting options, reasonable use, which can give us unexpected consequences. One of the "-m" options can create use to create an HTML report, which is useful in practical applications. Let's first take a look at some options for SQL * Plus (Oracle 8i):

C: /> SQLPLUS -

Usage: sqlplus [[

Where

:: = [/ ] [@ ] | / | / NOLOG

: = @ [. ] [ ...]

"-" Show used syntax

"-?" Show SQL * PLUS version

"-M " uses HTML flag option

"-R " Uses Restricted Mode

"-S" Uses Silent Mode

"-M" option Specifies to use the HTML tag to output data when the output is output to replace ordinary text.

The syntax of "-M" option is as follows:

[-M [arkup] "html [on | OFF] [Head text] [body text]

[EntMap {on | OFF}] [spool {on | OFF}] [pre [format] {on | OFF}] "

If we are in practical applications, you have to make each month's report HTML, which is easy to do with SQL * PLUS.

For example, as follows:

We prepare to process the DEPT table in Scott mode. DEPT table content:

SQL> SELECT * from dept;

DEPTNO DNAME LOC

---------- ---------------------------

10 Accounting New York

20 Research Dallas

30 Sales Chicago

40 Operations Boston

Output HTML files under the system command:

Save the following line statement to a .sql script (such as Q.SQL):

Set echo off

Set feedback off

SELECT * from dept;

Set echo on

Set feedback on

exit

Then call the command line as follows:

C: /> SQLPLUS -S -M "HTML ON Head DEPT Table" Scott / Tiger @c: /q.sql> Dept.html

A simple explanation of this command: "-s" means Silent mode, "- m" means enable HTML Markup option, "The Head DEPT Table" can be used to customize a simple title. Then the command is followed by the database user name and password, perform scripts, redirect to DePt.html.

Output dePt.html has the following content (already intercepted in the blank):

Output files under SQL * PLUS

You can use the set markup command in SQL * PLUS. Set Markup

Usage: set markup html [on | OFF] [Head text] [body text]

[EntMap {on | OFF}] [spool {on | OFF}] [pre [format] {on | OFF}]

Put the following memory as a .sql script (such as C: /q.sql):

Set echo off

Set feedback off

Set Markup HTML ON Spool on

Spool C: /DEPT.html

SELECT * from dept;

Spool off

Set Markup HTML OFF

Set echo on

Set feedback on

In the SQL * Plus, you can create the content created in C: The HTML page named dept.html is created in C: as shown below:

Attachment: HTML page output sample source file content

DEPT table content

Deptno

DNAME

LOC

10

Accounting

New York

20

Research

Dallas

30

Sales

Chicago

40

Operations

Boston

转载请注明原文地址:https://www.9cbs.com/read-27601.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.050, SQL: 9