SQLPLUS -S -M "HTML ON TABLE 'BORDER="2"'" depart.sql contains: ||DEPARTMENT_NAME||'.html'>'||DEPARTMENT_NAMEĮxample 7-2 Creating a Report using the SQLPLUS CommandĮnter the following command at the operating system prompt: View the report.html source in your web browser, or in a text editor to see that the table cells for the Department column contain fully formed hyperlinks as shown: The use of quotes and concatenation characters in the SELECT statement to create hyperlinks by concatenating string and variable elements. This makes sure that any HTML special characters such as quotes and angle brackets are not replaced by their equivalent entities, ', &, < and >.The COLUMN command to set ENTMAP OFF for the DEPARTMENT_NAME column to enable the correct formation of HTML hyperlinks. The TABLE option to set table WIDTH and BORDER attributes. The hyphen used to continue lines in long SQL*Plus commands. The SQL*Plus commands in this example contain several items of usage worth noting: Depending on how you invoke a script, you can use SET ECHO OFF or command-line -SILENT options to do this. In this example, the prompts and query text have not been suppressed. It should appear something like the following:ĭescription of the illustration report.gif The output from report.sql is a file, report.html, that can be loaded into a web browser. The and tags are appended to the spool file, report.html, before it is closed. SELECT ''||DEPARTMENT_NAME||'' DEPARTMENT_NAME, CITY The following SPOOL command triggers the writing of the and tags to the named file:Īfter the SPOOL command, anything entered or displayed on standard output is written to the spool file, report.html. SET MARKUP HTML ON SPOOL ON enables SQL*Plus to write HTML to a spool file. The first command also turns off entity mapping for the DEPARTMENT_NAME column to allow HTML hyperlinks to be correctly created in this column of the output data:ĬOLUMN DEPARTMENT_NAME HEADING 'DEPARTMENT' ENTMAP OFF The following COLUMN commands create new heading names for the SQL query output. You use the COLUMN command to control column output. SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON. Open a SQL*Plus session and enter the following: You can include an embedded style sheet, or any other valid text in the HTML tag. You can create HTML output in an interactive SQL*Plus session using the SET MARKUP command. You can use the SET MARKUP command to enable or disable HTML output as required.Įxample 7-1 Creating a Report Interactively If you enter another SPOOL filename command, the current spool file is closed as for SPOOL OFF or EXIT, and a new HTML spool file with the specified name is created. You use SPOOL OFF or EXIT to append final HTML tags to the spool file and then close it. If no extension is specified, the default SQL*Plus file extension is used. This enables you to easily identify the type of your output files, and also enables web browsers to identify and correctly display your HTML files. htm file extension which are standard file extensions for HTML files. When creating a HTML file, it is important and convenient to specify a. This file then has HTML tags including and. You must use the SQL*Plus SPOOL command to start generation of a spool file. SET MARKUP HTML ON SPOOL ON only specifies that SQL*Plus output will be HTML encoded, it does not create or begin writing to an output file. You can view the output in a web browser. HTML output generated this way has no or tags.ĭuring a SQL*Plus session, use the SET MARKUP command interactively to write HTML to a spool file. You can use SET MARKUP HTML ON SPOOL OFF to generate HTML output suitable for embedding in an existing web page. The HTML tags in a spool file are closed when SPOOL OFF is executed or SQL*Plus exits. SET MARKUP HTML ON SPOOL ON generates an HTML page for each subsequently spooled file. The -SILENT and -RESTRICT command-line options may be effectively used with -MARKUP to suppress the display of SQL*Plus prompt and banner information, and to restrict the use of some commands. All subsequent output is in HTML until SQL*Plus terminates. On starting, it outputs the HTML and BODY tags before executing any commands. SQLPLUS -MARKUP "HTML ON" is useful when embedding SQL*Plus in program scripts. See the SQLPLUS MARKUP Options and the SET MARKUP command for more information about these commands. You can use SQLPLUS -MARKUP "HTML ON" or SET MARKUP HTML ON SPOOL ON to produce complete HTML pages automatically encapsulated with and tags.īy default, data retrieved with MARKUP HTML ON is output in HTML, though you can optionally direct output to the HTML tag so that it displays in a web browser exactly as it appears in SQL*Plus. In addition to plain text output, the SQL*Plus command-line interface enables you to generate either a complete web page, or HTML output which can be embedded in a web page. Creating Reports using Command-line SQL*Plus
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |