📄 cgml.htm
字号:
<P>and if I wanted to watch the results on the screen in addition to viewing them in the file, I could call CGMLtest
as follows:</P>
<P>
<DIR>
<PRE>SQL> exec PLGCGML.genFile ('chart_of_accounts', 'c:\temp', 'showcols.gdr', TRUE);
</PRE>
</DIR></P>
<P><A HREF="#Top"><B>Return To Top</B></A></P>
<HR ALIGN="CENTER">
<P><A NAME="genstring"></A><FONT SIZE="5" FACE="Arial"><I><B> Use the PLGCGML.genString Procedure</B></I></FONT></P>
<P>The PLGCGML.genString procedure is like PLGCGML.genFile in that it handles all the "routine" steps
of the PL/Generator API to allow you to easily test your CGML and generate text. It is different from PLGCGML.genFile
in that it does not require the UTL_FILE package to perform file I/O. Instead, it accepts a string containing the
CGML commands and deposits the generated text into an in-memory list that you can then programmatically retrieve.</P>
<P><B>Note 1</B>: you are limited to CGML command strings of no more than 32K bytes with genString. There is no such limit
on genFile.</P>
<P><B>Note 2</B>: the genString procedure is designed mainly for use from within GUI interfaces to PL/Generator, but you
can use it as well.</P>
<P>Here is the header for this procedure*:</P>
<PRE> PROCEDURE PLGCGML.genString (
obj IN VARCHAR2,
string IN VARCHAR2,
show IN BOOLEAN :=FALSE,
cleardriver IN BOOLEAN :=TRUE,
sch IN VARCHAR2 :=NULL,
delimIN VARCHAR2 :=NULL,
drvr IN VARCHAR2 :=NULL,
delarray IN BOOLEAN :=TRUE,
single_pass IN BOOLEAN :=FALSE )</PRE>
<P>where the arguments have the following meaning:</P>
<TABLE BORDER="0" CELLPADDING="7" CELLSPACING="1" WIDTH="720" FRAME="BORDER">
<TR>
<TD WIDTH="12%" VALIGN="TOP">obj</TD>
<TD WIDTH="88%" VALIGN="TOP">The name of the table or view against which you will run your CGML file.</TD>
</TR>
<TR>
<TD WIDTH="12%" VALIGN="TOP">string</TD>
<TD WIDTH="88%" VALIGN="TOP">A string of up to 32K characters containing your CGML text. Each individual CGML statement must be separated by
the delimiter you specify, the default being a newline character or CHR(10) in PL/SQL</TD>
</TR>
<TR>
<TD WIDTH="12%" VALIGN="TOP">show</TD>
<TD WIDTH="88%" VALIGN="TOP">A Boolean flag indicating whether or not you want to show the text that is generated from your CGML file.</TD>
</TR>
<TR>
<TD WIDTH="12%" VALIGN="TOP">cleardriver</TD>
<TD WIDTH="88%" VALIGN="TOP">A Boolean flag indicating whether or not you want to the existing driver definition to be cleared. Default is TRUE
and you should stick with the default unless you are defining your own arrays.</TD>
</TR>
<TR>
<TD WIDTH="12%" VALIGN="TOP">sch</TD>
<TD WIDTH="88%" VALIGN="TOP">The schema that contains the table or view; the default is the currently-connected user.</TD>
</TR>
<TR>
<TD WIDTH="12%" VALIGN="TOP">delim</TD>
<TD WIDTH="88%" VALIGN="TOP">The delimiter used to separate individual CGML lines in the string. The default is CHR(10) or the new line character.</TD>
</TR>
<TR>
<TD WIDTH="12%" VALIGN="TOP">drvr</TD>
<TD WIDTH="88%" VALIGN="TOP">The name of the driver which will be created for this execution. Default is TEST. You should keep it that way until
you start building your own drivers.</TD>
</TR>
<TR>
<TD WIDTH="12%" VALIGN="TOP">delarray</TD>
<TD WIDTH="88%" VALIGN="TOP">Pass TRUE if you want to delete any arrays defined for this schema. FALSE will preserve arrays previously defined.</TD>
</TR>
<TR>
<TD WIDTH="12%" VALIGN="TOP">single_pass</TD>
<TD WIDTH="88%" VALIGN="TOP">A value of TRUE means that the generator engine will only run once for your CGML text, regardless of how many objects
are defined in the DBOBJECT array. This is useful when your CGML text is iterating through the DBOBJECT array itself.</TD>
</TR>
</TABLE>
<P>*<B>Note</B>: there is an overloaded version of PLGCGML.genString that does not require passing an object name. This
will be used for generation using your own custom-defined arrays.</P>
<P>Here is an example that loads up a string and then passes it to PLGCGML.genString:</P>
<PRE> DECLARE
string PLGadmin.maxvc2 :=
'[STOREIN]CGML.tst
PROCEDURE insert_row (
[FOREACH]gencol[between],
[colname]_in IN [coldatatype]
);';
BEGIN
PLGCGML.genstring ('employee', string, show=> false);
END;
/ </PRE>
<P>Notice that you do not have to concatenate new-line characters directly into the string like this:</P>
<PRE> '[STOREIN]CGML.tst' || CHR(10) ||
' PROCEDURE insert_row (' </PRE>
<P>Instead, you can just leave your new-line characters within the string and they will be embedded in the variable,
to be passed along to PLGCGML.genString.</P>
<P>After generation, you can retrieve the text using the following programs:</P>
<TABLE BORDER="0" CELLPADDING="7" CELLSPACING="1" WIDTH="765" FRAME="BORDER">
<TR>
<TD WIDTH="29%" VALIGN="TOP" BGCOLOR="#000000"><FONT COLOR="#FFFFFF">Program Header</FONT></TD>
<TD WIDTH="71%" VALIGN="TOP" BGCOLOR="#000000"><FONT COLOR="#FFFFFF">Description</FONT></TD>
</TR>
<TR>
<TD WIDTH="29%" VALIGN="TOP">
<PRE>PROCEDURE PLGgen.list_init;</PRE>
</TD>
<TD WIDTH="71%" VALIGN="TOP">Initialize your scan through the list of text, starting at the first item.</TD>
</TR>
<TR>
<TD WIDTH="29%" VALIGN="TOP">
<PRE>FUNCTION PLGgen.next_list_entry
RETURN VARCHAR2;</PRE>
</TD>
<TD WIDTH="71%" VALIGN="TOP">Get the next item from the list.</TD>
</TR>
<TR>
<TD WIDTH="29%" VALIGN="TOP">
<PRE>FUNCTION PLGgen.end_of_list
RETURN BOOLEAN;</PRE>
</TD>
<TD WIDTH="71%" VALIGN="TOP">Returns TRUE if you have reached the end of the list.</TD>
</TR>
<TR>
<TD WIDTH="29%" VALIGN="TOP">
<PRE>PROCEDURE PLGgen.list_clear;</PRE>
</TD>
<TD WIDTH="71%" VALIGN="TOP">Clear out the list, a good action to take when you are done. It will free up the memory associated with the list.</TD>
</TR>
</TABLE>
<P>Here is an example of the kind of code you can write in PL/SQL to retrieve and display the generated text:</P>
<PRE> BEGIN
PLGgen.list_init;
LOOP
EXIT WHEN PLGgen.end_of_list;
DBMS_OUTPUT.PUT_LINE (PLGgen.next_list_entry);
END LOOP;
PLGgen.list_clear;
END;
/</PRE>
<P>So now the big question is: what do you put in those test CGML files? The next section provides the answer;
it contains a syntax reference for CGML.</P>
<P><A HREF="#Top"><B>Return To Top</B></A></P>
<P>
<HR ALIGN="CENTER">
</P>
<P><A NAME="troubleshooting"></A><FONT SIZE="5" FACE="Arial"><B> TROUBLESHOOTING</B></FONT></P>
<UL>
<LI><A HREF="#trouble1">Information to Provide to Quest Software Support</A><P>
<LI><A HREF="#trouble2">Before Contacting Quest Software Support</A><P>
</UL>
<P>If you encounter an error as you use CGML, you can contact Quest Software Support in one of the following ways:</P>
<UL>
<LI>Email (trial and licensed users): support@Quest Software.com<P> <LI>PL/SQL Pipeline (trial and licensed users): visit www.Quest Software.com/plsql-pipeline and then go to the Pipetalk
bulletin board system. Post a note in the PL/Generator conference. Steven sysops Pipetalk and checks it several times
a day.<P>
<LI>Phone (licensed users only): call Quest Software at 540.373.7703. We would strongly encourage users to use email
or the PL/SQL Pipeline.<P>
</UL>
<P><A NAME="trouble1"></A><FONT SIZE="5" FACE="Arial"><I><B> Information to Provide to Quest Software Support</B></I></FONT></P>
<P>When you contact Quest Software Support, please have the following information available:</P>
<UL>
<LI>Oracle, PL/SQL and PL/Generator version information.<P>
<LI>Any log files from the installation process if this is an installation error.<P>
<LI>Output from the SQL*Plus window or PL/Generator screen interface that shows the error.<P>
<LI>The code (CGML script or other text) you are writing that causing a problem.<P>
<LI>The error code and error text returned by PL/Generator.<P>
</UL>
<P>To obtain the last error code and text returned by PL/Generator, examine the values returned by these two functions:</P>
<DIR>
<PRE>
PLGerr.errtext
PLGerr.errcode</PRE>
</DIR>
<P>as in:</P>
<DIR>
<PRE>SQL> exec DBMS_OUTPUT.PUT_LINE (PLGerr.errcode);</PRE>
</DIR>
<P>The PLGerr.errtext will return the error message, while PLGerr.errcode returns the error code number.</P>
<P>Here are the error numbers currently defined in the PLGerr package specification (you can always review the
specification to see if new error codes were added):</P>
<Table><TR><TD><B>Error Name</B></TD><TD> <B>Error Code</B></TD></TR>
<TR><TD> PLGerr.general_error</TD><TD> 200000;</TD></TR>
<TR><TD>PLGerr.driver_not_found</TD><TD> 200001;</TD></TR>
<TR><TD>PLGerr.unmatched_readahead </TD><TD>200002;</TD></TR>
<TR><TD> PLGerr.hash_value_notfound </TD><TD>200003;</TD></TR>
<TR><TD> PLGerr.read_error</TD><TD> 200004;</TD></TR>
<TR><TD>PLGerr.no_closing_tag</TD><TD> 200005;</TD></TR>
<TR><TD>PLGerr.too_many_iterations</TD><TD> 200006;</TD></TR>
<TR><TD> PLGerr.invalid_target </TD><TD>200007;</TD></TR>
<TR><TD> PLGerr.unmatched_endif</TD><TD> 200008;</TD></TR>
<TR><TD> PLGerr.srcinfo_failure </TD><TD>200009;</TD></TR>
<TR><TD>PLGerr.insert_failure </TD><TD>200010;</TD></TR>
<TR><TD>PLGerr.unmatched_idtags </TD><TD>200011;</TD></TR>
<TR><TD>PLGerr.too_long_to_compile </TD><TD>200012;</TD></TR>
<TR><TD>PLGerr.trial_limit_exceeded </TD><TD>200013;</TD></TR>
<TR><TD>PLGerr.invalid_assign </TD><TD>200014;</TD></TR>
<TR><TD>PLGerr.invalid_copyto</TD><TD> 200015;</TD></TR>
<TR><TD> PLGerr.invalid_dyn_plsql </TD><TD>200016;</TD></TR>
<TR><TD>PLGerr.generation_cancelled </TD><TD>200017;</TD></TR></TABLE>
<P><A NAME="trouble2"></A><FONT SIZE="5" FACE="Arial"><I><B> Before Contacting Quest Software Support</B></I></FONT></P>
<P>Before communicating with Quest Software Support, however, please review the following troubleshooting topics to
see if they will solve your problem.</P>
<UL><LI> <P>If you encounter an error screen like this, indicating that or more programs are marked INVALID, you only need
to recompile those programs.</P>
<P><IMG SRC="errorscreen.gif" WIDTH="329" HEIGHT="194" ALIGN="BOTTOM" BORDER="0"></P>
<P>To recompile, connect to the schema owning the PL/Generator objects and execute this command:</P>
<PRE>exec DBMS_OUTPUT.PUT_LINE (recompile);</PRE>
<P>You will see output like this:</P>
<PRE>RECOMPILING OBJECTS
Object Owner is PLG
Object Name is %
Object Type is % O
Object Status is INVALID.
PROCEDURE PLG.TEST_ISNUM is recompiled. Object status is VALID.
PACKAGE BODY PLG.PLGVAL is recompiled. Object status is VALID.
PACKAGE BODY PLG.PLGDRV is recompiled. Object status is VALID.
PACKAGE BODY PLG.PLGPLSQL is recompiled. Object status is VALID.
PACKAGE BODY PLG.PLGJAVA is recompiled. Object status is VALID.
PACKAGE BODY PLG.PLGCGML is recompiled. Object status is VALID.</PRE>
<P>And then you will be able to start PL/Generator successfully.</P>
</UL><UL>
<LI>Suppose you build a CGML script and forget to properly match a FOREACH with its ENDFOREACH or an IF with its
ENDIF. You will then see an error like this:
<PRE>No closing tag in readahead for [FOREACH]gencol[between],</PRE>
<P>or like this:</P>
<PRE>TRANSLATE DRIVER: ORA-01403: no data found</PRE>
<P>No additional diagnostics are available, so you will need to track down the flaw in your CGML based on the text
in that message. A good candidate?</P>
<PRE>[END IF]</PRE>
<P>instead of</P>
<PRE>[ENDIF]</PRE>
</UL><UL><P>
<LI>You run your test and you cannot find the information in the file you believe you specified with your STOREIN
command. What is wrong? There are several possibilities. First, check to make sure that you did include a STOREIN
statement. If you didn't, then the generated text will only display on the screen if you specified TRUE for show
in your call to PLGCGML.genFile. After that, confirm your directory by calling the showdir.sql script. If the directory
setting is wrong, call setdir.sql to fix it.<P>
<LI>If you don't put the STOREIN on the first line, you will get the following error:
<PRE>PLGvar Boolean assign error on "PLGgen.().STOREIN": ORA-06550: line 1, column 34</PRE>
<P>Simply move the STOREIN command to the very first line and you should be fine.</P>
</UL><UL>
<LI>If you want to write to files, but do not have UTL_FILE set up properly, you will see errors like this:
<PRE>UTL_FILE error for file testCGML.gdrlocated in d:\plgenerator\CGML: invalid_path.</PRE>
<PRE>Please make sure that UTL_FILE is enabled for this instance.</PRE>
<P>If you see this, please follow instructions in the help system for verifying and setting up UTL_FILE.</P>
</UL><UL>
<LI>The most common problem you will encounter is when you try to use an undefined tag. You might make a typographical
error or try to reference a tag defined in one array, but <I>not </I>in the current array. Suppose, for example
that you include a reference to [obname] instead of [objname]. You will then see an error message like this:
<PRE>PLGvar Boolean assign error on "PLGgen.().OBNAME": ORA-06550: line 1, column 34:</PRE>
<P>or this:</P>
<PRE>STRBYNAME error -6550 for [OBNAME] with context PLGgen.().</PRE>
<P>In the first case, the string after "PLGgen.()." is your clue; search for it in your CGML script and
fix the reference. In the second error message, you will find the problem string inside the object tags.</P>
</UL><UL>
<LI>If you are working on defining your own arrays, please be aware that PLGCGML's array_from_query and array_from_table
procedures mayh only work properly if you are connected to the schema that owns the PL/Generator objects.
</UL>
<P>If you encounter a problem that is not handled by the points listed above, please post your problem in the PL/Generator
conference of Pipetalk on the PL/SQL Pipeline.</P>
<P>We will be improving steadily the diagnostic and error handling aspects of CGML, so we would also like to hear
any ideas you have on that process as well!</P>
<P><A HREF="#Top"><B>Return To Top</B></A>
</UL>
</UL>
<DIR>
<DIR>
<hr>
<p align="center"><font size="1">Copyright
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -