Create an HTML page with Oracle's Sql*plus tool

Source: Internet
Author: User
Tags command line dname html page html tags sqlplus
oracle| Create | page
Create an HTML page with Oracle's Sql*plus tool



Author: fenng



Oracle's Sql*plus tools have some interesting options, reasonable use, can give us unexpected consequences. One of the "-M" options can be created to create HTML reports that are useful in practical applications. Let's take a look at some of the options for Sql*plus (Oracle 8i):



C:\>sqlplus-

Usage: sqlplus [[<option>] [<logon>] [<start>]]

of which <option>:: =-| -? | [[M <o>] [r <n>] [-S]]

< login >:: = < user name >[/< password >][@<connect_string>] | / | /nolog

< startup >:: = @< filename >[.<ext>] [< parameter > ...]

"-" shows use syntax

"-?" Show Sql*plus Version Flag

"-M <o>" uses HTML flag options <o>

"-R <n>" uses restricted mode <n>

"-S" uses silent mode

The "-M" option specifies that HTML tags are used to output data at the time of output in place of normal text.



The syntax for the "-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 the actual application, to the Company's table for each month of the report HTML, with Sql*plus This feature is easy to do.


Examples are as follows:

We are prepared to process the Dept table in Scott Mode. Dept Table contents:



Sql> SELECT * FROM dept;



DEPTNO dname LOC

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

Ten ACCOUNTING NEW YORK

DALLAS

SALES CHICAGO

OPERATIONS BOSTON



To output an HTML file at the system command line:



Save the following lines of statements in a. SQL script (for example, Q.sql):



SET ECHO off

SET FEEDBACK off

SELECT * FROM Dept;

SET ECHO on

SET FEEDBACK on

Exit

Then down at the command line, use the following command:

C:\> sqlplus-s-M "HTML on head Dept table contents" Scott/tiger @c:\q.sql>dept.html



A simple explanation for this command: where "-S" means silent mode, "-M" means the HTML markup option, and the "Head Dept Table content" can be used to customize a simple title. Then the command is followed by the database user name and password, executing the script and redirecting to the dept.html.

The output dept.html has the following contents (the blanks have been truncated):







Output files under Sql*plus

You can do this with 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}]



Save the following memory as a. SQL script (for example, 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



Called in Sql*plus, you can create content to create an HTML page named dept.html in C:, as shown in the following illustration:







Attached: HTML page Output sample source file contents



Dept the contents of the table

<meta name= "generator" content= "Sql*plus 8.1.7" >


<body>



<p>

<table border= "1" width= "90%" >

<tr>

<th>

DEPTNO

</th>

<th>

Dname

</th>

<th>

LOC

</th>

</tr>

<tr>

&LT;TD align= "Right" >

10

</td>

<td>

ACCOUNTING

</td>

<td>

NEW YORK

</td>

</tr>

<tr>

&LT;TD align= "Right" >

20

</td>

<td>

The

</td>

<td>

DALLAS

</td>

</tr>

<tr>

&LT;TD align= "Right" >

30

</td>

<td>

SALES

</td>

<td>

CHICAGO

</td>

</tr>

<tr>

&LT;TD align= "Right" >

40

</td>

<td>

OPERATIONS

</td>

<td>

BOSTON

</td>

</tr>

</table>

<p>

</body>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.