
Online Documentation
Contents
Overview
WebPC was written to extend the functionality of web modules generated
from Oracle Designer 2.1.2.
Make sure that you Register to get
free WebPC upgrades.
There are a number of web features that cannot be 100% generated from
Designer. Here are a few:
-
Make one of the query criteria field mandatory. i.e. prevent query other
wise.
-
Special field layouts, like 2 items on one line, then 3 on the next one.
-
Implement menu security: only display links that the user has access to!
-
Add extra LOVs on unbound items
-
Get items prompts from table (multi-language)
-
Make prompts bold when mandatory, not bold when optional.
-
Add buttons on each line of the record list - record specific actions.
-
Restrict LOVs depending on what value is already typed in field (Forms
3 like functionality).
When confronted with such a requirements, most people would generate as
much as they can from Designer and make manual modifications to the code.
This works but as soon as the module is generated again from Designer,
the manual modifications are lost. We can keep a log of manual modifications
and re-apply them manually each time we need to generate the module again.
This is very time consuming and prone to errors. We can choose to never
generate again from Designer once manual modifications are made. This choice
costs a lot of project time if the module design or database design change.
WebPC provides an automatic method to modify code generated by Designer.
This method is the less overall time consuming and the less prone to error.
For each modification you will need to make it manually once, make sure
that it works and then script it with WebPC. Such scripts must be written
using an extremely easy subset of the language PERL. You don't actually
need to know anything about PERL to make this work. You will find many
examples of scripts in this manual that you can use as models to achieve
the same result on your modules.
WebPC integrates seamlessly with Oracle Designer, SQL*Plus and any browser
you may want to use to display your modules.
Registration
for Upgrades
It is important that the author of WebPC know that you are using this product.
He has a list of all users and uses it to send them upgrades. All this
is free of charge and done in his spare time. To save you and him time,
he has put a web page that sends a formatted email to him. This raises
privacy warnings from browsers, but he does need your email address to
send you upgrades! WebPC fits on a zip file of less than 100K. Don't
forget to do this!
Why
PERL?
-
Because it is free.
-
Because it is a very powerful text processing language.
-
Because it is the backbone of the internet.
-
Because anyone can download it from the Internet.
-
Because it is portable. Perl runs on IBM mainframes and AS/400s, Windows
NT, 95 and 98, OS/2, Novell Netware, Cray supercomputers, Digital's VMS,
Tandem Guardian, HP MPE/ix, Mac OS, and all flavors of Unix, as well as
dozens of smaller operating systems like Acorn RISCOS, and the Amiga.
-
Because it has been around since the mid-1980s; it's not just another fashion.
-
Because it is Y2k Compliant.
-
Because the father of WebPC was looking for a good excuse to learn PERL.
-
Because the PERL culture is cool.
The
Mechanics of WebPC
For each web module, Designer produces 3 files. The .pks file contains
the package header definitions. The .pkb file contains the package body
definitions. The .sql file calls the 2 files previously mentioned. The
file names follow this rule: "Cvw"+<module shortname>.<file type>.
The .pkb and .pks files contain DDL that can be run from either Designer
or SQL*Plus. WebPC changes the DDL by performing a number of text manipulations
that you can specify, like simple search/replace manipulations.
WebPC can work with both .pkb and .pks files. It does not actually change
the .pkb and .pks files. Instead, it produces .pcb and .pcs files and changes
the .sql file to run them instead of the .pkb and .pks.
When WebPC is done with massaging the PL/SQL code, it displays a log
file to the user. At this point there are 2 options. If the users are satisfied
with the content of the log, they can let WebPC install the new module
with SQL*Plus and then call the browser to display the result. If the users
are not satisfied with the content of the log, they can bail out, adjust
Designer or WebPC's rules and start again.
Your
Comments are Welcome
We value and appreciate your comment as an Oracle user and reader of this
documentation. As we write, revise, and evaluate our documentation, your
opinions are the most important feedback we receive.
-
Did you find any errors?
-
Is the information clearly presented?
-
Do you need more information? If so, where?
-
Are the examples correct? Do you need more examples?
-
What features did you like most about this manual?
You are most welcome to send comments and suggestions about this manual
to Hervé Deschamps at hdescham@us.oracle.com
Installation
Guide
Please follow very closely the instructions that follow to install WebPC.
-
Download PERL from www.perl.com. Get the latest stable version, not a beta
one.
-
Install it on your PC, in c:\perl. We highly recommend this location.
-
Check that the PATH variable includes Perl's home directory: c:\perl.
-
Extract pc.zip to any drive, but in its own directory and close to the
root. We recommend c:\pc, d:\pc, h:\pc, etc.
-
In Designer, go to the Design Editor and set the WebServer Options (Options->Generator
Options->WebServer...) as follows:
-
Location of generated files:
Anything with a backslash at the end like h:\web_app\
-
Install Generated PL/SQL:
Normal user name and password with connect string.
Uncheck Auto-Install after Generation.
-
Run generated application:
This is the most important setting
Browser: perl <directory where you extracted pc.zip>\pc.pl <location
of generated files set earlier>
example: perl h:\pc\pc.pl p:\gab_app\
Web Agent URL: <URL of the PL/SQL cartridge>
example: http://hdd.server.com/hdd_pl/plsql/

-
Configure pc.ini. This file is in the directory where you extracted pc.zip.
Like h:\pc\.
-
Complete Path where the .pca files may be found. Example $c_pcaPath
= "P:\\pca\\";
-
Setup the command to call SQL*Plus. Example: $c_SqlPlus='c:\orant\bin\plus80w
scott/tiger@zoo';
-
Setup the editor used to display the log file. Example: $c_Editor='notepad';
-
Setup the browser used to display the web module. Example: $c_Browser ='E:\Program
Files\Netscape\Communicator\Program\netscape.exe';
-
Copy the file webPC.pca in the directory the .pca files may be found.
The calls to SQL*Plus, the editor and the browser are Operating System
specific. In the sample pc.ini file we have example calls for Windows95,
Windows98 and WindowsNT.
Using
WebPC from Designer
WebPC will run automatically from Designer if you follow these steps:
-
In the Design Editor, select a web module.
-
Press the Generate toolbar button.
-
Check the generation options are set as described in the install section
above.
-
Generate the module.
-
In the message window, press the toolbar button 'List Actions'.
-
Select Run Generated application using browser .....
-
Press Run.
-
Follow the prompts from there.
The first time you try this you may find that WebPC displays the
log, run SQL*Plus and brings up the browser just fine, but does add anything
to the code generated by Designer. This is because you need to set up some
actions in WebPC engine. See next section.
WebPC
Developer Guide
This section explains how to use WebPC to make manual modifications automatic.
On virtually all Designer Web generation projects there will be 2 types
of WebPC actions that you may want to perform on your modules:
-
Module Specific Modifications;
-
Application Wide Modifications.
Module
Specific Modifications
The
Basics
In order to get WebPC to make module specific modifications, you need to
create a .pca file that has the same file name as the DDL file generated
by Designer to create the Web Server module. The file names follow this
rule: "CVW"+<module shortname>.pca. For module GBPDTRNW the file name
is CVWGBPDTRNW.pca. Listing A shows an example of such file.
-
Listing A
#Removes the buttons standard query buttons from the bottom of
the query form -- Part 1/2
$myStart = '^-- Name:
gbpdtrnw$pds.QueryList$';
$myEnd = '^ exception$';
$mySearch = '^ htp.formOpen(curl
=> \'gbpdtrnw$pds.querylist\', cattributes => \'NAME="frmZero"\');$';
$myReplace = '/* WebPC removal'."\n".
' htp.formOpen(curl => \'gbpdtrnw$pds.querylist\',
cattributes => \'NAME="frmZero"\');';
&SimpleSearchRepRange($myStart, $myEnd, $mySearch, $myReplace);
#Removes the buttons standard query buttons from the bottom of the
query form -- Part 2/2
#and move the hidden fields.
$myStart = '^-- Name:
gbpdtrnw$pds.QueryList$';
$myEnd = '^ exception$';
$mySearch = '^ htp.formClose;$';
$myReplace = ' htp.formClose;'."\n".
'*/'."\n".
' WSGL.HiddenField(\'O_L_POG_PD_NAME\', P_L_POG_PD_NAME);'."\n".
' WSGL.HiddenField(\'O_L_POG_ORG_ABBRV\',
P_L_POG_ORG_ABBRV);';
&SimpleSearchRepRange ($myStart, $myEnd, $mySearch, $myReplace);
WebPC code performing the automatic code modification.
Module specific actions require careful thinking. You need to make
sure that the action you set in WebPC will only be applied to ...
The code in Listing A is written in PERL. There is very little to it:
-
a few variable assignments for the sake of readability;
-
calls to a search/replace procedure.
$myStart, $myEnd, $mySearch and $myReplace are 4 variables that we use
as parameters to the &SimpleSearchRepRange procedure. All this procedure
does is perform a systematic search/replace within a range delimited by
2 patterns. It is important to limit the range of the search replace because
each WebServer module component represents about 3000 lines of PL/SQL code.
Within this code, similar constructs are repeated a number of times. For
example, the same fields usually appear on the query form, the insert form
and the view form. We usually need a search/replace by range to target
a specific part of the PL/SQL code.
&SimpleSearchRepRange requires 4 parameters:
-
the pattern that marks the beginning of the search/replace range;
-
the pattern that marks the end of the search/replace range;
-
the pattern to look for within that range;
-
the pattern to use as a replacement.
In the example above, WebPC first searches the PL/SQL code for the first
instance of "-- Name: gbpdtrnw$pds.QueryList".
It marks that location. It then searches the PL/SQL code for the first
instance of " exception" from where it found the first
pattern. It marks that location too. These two locations define the search/replace
range. Within that range WebPC performs a systematic search for the content
of the third parameter and replaces it with the content of the last parameter.
That is really all there is to 90% of the
work to be done with WebPC! |
More
Advanced Features
You may have noticed the use of characters ^, $ and \ in Listing A. These
are PERL meta characters.
-
^ means beginning of the line.
-
$ means end of the line.
-
\ is used to prefix a special character: \n means newline.
-
Other meta characters are | ( ) [ { * + ? .. (period is a meta character).
In plain English, looking for '^-- Name:
gbpdtrnw$pds.QueryList$' means find the first instance of "-- Name:
gbpdtrnw$pds.QueryList" that starts at the beginning of a line (not
in the middle) and reaches the end of the line.
\ must be used in front of all single quotes that are included in the
text to be searched or replaced.
We will teach you the basics of PERL through a lot of examples in the
continuation of this manual. If you want unleash the full power of PERL
we recommend that you buy THE PERL book, written by Perl's father
himself:
Programming PERL, Larry Wall, Tom Chrithiansen, Randal L. Schwartz.
O'Reilly, Second Edition, September 1996. or later edition. |
With time and for complex modules your .pca files will grow fairly large.
It is a good idea to document each WebPC action with comments. This is
illustrated in Listing A. PERL consider a comment any text placed after
a #.
Listing A also illustrates how to insert multiple lines to replace a
single line. Look for something like 'this is line 1'."\n".'this is
line 2';. The operator "." concatenates character strings. Just like
|| in PL/SQL. \n means newline. In PERL Character strings can either be
enclose in double quotes or single quotes. Double strings can be "analyzed"
by PERL. That is why we place \n in double quotes: we want PERL to transform
this into a newline character. Single quotes protect strings from any PERL
transformation. You must use single quotes most of the time with WebPC.
Application
Wide Modifications
It is also possible to get WebPC to perform application wide modifications.
Every time WebPC processes a Designer module it execute file WebPC.pca.
In this file you can define actions that are application wide. The way
you define these actions is exactly the same as if you were defining module
specific actions. This was explained in the previous sections of this document
and will be exemplified further in the continuation of this manual.
WebPC
Reference
The procedure &SimpleSearchRepRange shown in listing
A is one of the procedures available in WebPC. The complete definition
of these procedures can be found in file pc_lib.pl. The table that follows
provides an exhaustive alphabetical list with a brief description. Some
of these procedures like listPackages are really for WebPC's internal use.
But this tool is open: if you can find a use for these internal procedures
you are welcome to use them.
We will now then explain each of the procedures in logical order. You
will also learn how to use them in section Learning
WebPC by Example.
SearchRepRange
SearchRepRange was the first WebPC procedure. It takes four parameters:
-
$myStart: the pattern that marks the beginning of the search/replace range;
-
$myEnd: the pattern that marks the end of the search/replace range;
-
$mySearch: the pattern to look for within that range;
-
$myReplace: the pattern to use as a replacement.
All this procedure does is perform a systematic search/replace within a
range delimited by 2 patterns. It is important to limit the range of the
search replace because each WebServer module component represents about
3000 lines of PL/SQL code. Within this code, similar constructs are repeated
a number of times. For example, the same fields usually appear on the query
form, the insert form and the view form. We usually need a search/replace
by range to target a specific part of the PL/SQL code.
WebPC first searches the PL/SQL code for the first instance $myStart
in the package body. It marks that location. It then searches the PL/SQL
code for the first instance of $myEnd from where it found the first pattern.
It marks that location too. These two locations define the search/replace
range. Within that range WebPC performs a systematic search for the content
of $mySearch and replaces it with the content of $myReplace.
There are strict rules as to the content of those variable. That is
because PERL uses "meta-characters" to enable you to define powerful searches.
For example "\d{7,11}" would match a North American phone number: at least
7 digits but no more than 11. Or "(..):(..):(..)" matches three colon-separated
fields, each of which is two character long.
Here is the list of dreaded meta-characters. We highlighted it because
you will need to come back it fairly often.
$ |
\ |
| |
( |
) |
[ |
{ |
^ |
$ |
* |
+ |
? |
. |
" |
' |
In PERL, each of these character has a special meaning and function.
If you want to know more about them we invite you to consult The
PERL Reference.
However, for 99.9% of what you will do with WebPC, you really only
need to follow these rules:
-
In $myStart, $myEnd, $mySearch (when single quoted):
-
Add 1 \ in front of ' $ ( ) | [ { ^ * + ? . that are in the original text;
-
Add 2 \ in front of \;
-
no \ in front of ".
-
in $myReplace (when single quoted):
-
no need for \ in front of $ \ | ( ) [ { ^ $ * + ? . ";
-
1 \ in front of '.
Listing B provides an example of use of SearchRepRange.
-
Listing B
#Adding the cloning button to the record list generated by Designer
$myStart = 'cp0010\$pr3\.QueryList';
$myEnd = '^ WSGL.ClosePageBody;';
$mySearch = 'CURR_VAL\.SERIAL_NUMBER\\\), ctarget=>L_VF_FRAME\)\);';
$myReplace = 'CURR_VAL.SERIAL_NUMBER), ctarget=>L_VF_FRAME));'."\n".
'
WSGL.LayoutData(\'<FORM ACTION="cp0010$pr3.clone" METHOD="POST"><INPUT
TYPE="hidden" NAME="P_SERIAL_NUMBER" VALUE="\'||CURR_VAL.SERIAL_NUMBER||\'"><INPUT
TYPE="Submit" VALUE="Clone"></FORM>\');'."\n";
&SearchRepRange($myStart, $myEnd, $mySearch, $myReplace);
Joggling with meta-characters using SearchRepRange.
It is very important that you use single quotes to define the values of
$myStart, $myEnd, $mySearch and $myReplace. For the technically minded
people, single quotes tell PERL no to interpolate variables at assignment
time. If you really want to use double quotes, get ready to type what listing
C illustrates.
-
Listing C
$myStart = "cp0010\\\$pr3\.QueryList";
$myEnd = "^ WSGL.ClosePageBody;";
$mySearch = "CURR_VAL\.SERIAL_NUMBER\\\), ctarget=>L_VF_FRAME\\\)\\\);";
$myReplace = "CURR_VAL.SERIAL_NUMBER), ctarget=>L_VF_FRAME));\n".
"
WSGL.LayoutData('<FORM ACTION=\"cp0010\$pr3.clone\" METHOD=\"POST\"><INPUT
TYPE=\"hidden\" NAME=\"P_SERIAL_NUMBER\" VALUE=\"'||CURR_VAL.SERIAL_NUMBER||'\"><INPUT
TYPE=\"Submit\" VALUE=\"Clone\"></FORM>');\n";
&SearchRepRange($myStart, $myEnd, $mySearch, $myReplace);
Avoid using double quotes or you will have to type this!
Some of these metacharacters, like { or ., do not always need to be back
slashed when they are in the original text, depending on the surrounding
character. You are strongly encouraged to backslash them systematically
though.
Although SearchRepRange is the most powerful type of search/replace,
its use is made complicated because you need to prefix with "\" all meta-characters
that you do not wish WebPC to consider as meta-characters. This is a tedious
task that is very prone to errors. For this reason we have created a simpler
procedure: SimpleSearchRepRange.
SearchRepRange2Start
SearchRepRange2Start works just like SearchRepRange. The only difference
is that it takes one additional parameter: a second start position. Listing
D shows an example where we have used it.
-
Listing D
$myStart = '^-- Name:
gbamebw\$age\.CreateInsertJavaScript$';
$myStart2 = '^\'function OPTIONAL_REVISION_NUM_LOV\(\) \{$';
$myEnd = '^ if LOV_FRAME
is not null then$';
$mySearch = '^
"&Z_ISSUE_WAIT=Y",\'\);$';
$myReplace = '
"&P_APPL_ID=" + document.forms[0].P_APPL_ID.value + //hdd1 modif'."\n".
'
"&Z_ISSUE_WAIT=Y",\');';
&SearchRepRange2Start ($myStart, $myStart2, $myEnd, $mySearch,
$myReplace);
Double start search/replace.
This is the way &SearchRepRange2Start works:
-
WebPC first searches the PL/SQL code for the first instance of the pattern
contained in $myStart. It marks that location.
-
It then searches the PL/SQL code for the first instance of the pattern
contained in $myStart2 from the position marked for $myStart. It marks
that location.
-
It then searches the PL/SQL code for the first instance of the pattern
contained in $myEnd from the position marked for $myStart2. It marks that
location too.
-
The locations for $myStart2 and $muEnd define the search/replace range.
-
Within that range WebPC performs a systematic search for the content of
$mySearch and replaces it with the content of $myReplace.
You will find situations where you need a double start to define a specific
range. Although this might seem very unlikely to you the first time you
read this, you will be faced with a case where you just cannot change a
piece of code without changing other parts of the code that you really
need to leave as they are unless you use a double start.
SearchRepRangeHdr
&SearchRepRangeHdr works exactly like &SearchRepRange.
However, instead of performing a search replace on the package body, it
works with the package header. You should very rarely need to do this.
If you need to add routines to the packages generated by Designer, you
should record the code into Designer itself, not in a WebPC .pca file.
WebPC should only be used for small tweaks to the PL/SQL code produced
by Designer. For maintenance reasons, all the business logic must be contained
in the repository.
Listing E shows how we used WebPC to add a parameter to a public PL/SQL
procedure generated by Designer.
-
Listing E
$myStart = '^ procedure optional_revision_num_listofva\($';
$myEnd = '^end;$';
$mySearch = '^
Z_CALLER_URL in varchar2,$';
$myReplace = '
Z_CALLER_URL in varchar2,'."\n".
'
P_APPL_ID in varchar2 default null, --hdd3';
&SearchRepRangeHdr($myStart, $myEnd, $mySearch, $myReplace);
Legitimate use of &SimpleSearchRepRangeHdr.
Although &SearchRepRangeHdr is the most powerful type of search/replace,
its use is made complicated because you need to prefix with "\" all meta-characters
that you do not wish WebPC to consider as meta-characters. This is a tedious
task that is very prone to errors. For this reason we have created a simpler
procedure: &SimpleSearchRepRangeHdr.
SimpleSearchRepRange
&SimpleSearchRepRange is the WebPC procedure that you will use
90% of the time. It performs the same task as &SearchRepRange,
but does not require you to prefix PERL's meta-characters with a backslash.
The only exception to this is the single quote: it must always be prefixed
with a backslash. You can compare Listing F with Listing
B to appreciate the difference.
-
Listing F
#Adding the cloning button to the record list generated by Designer
$myStart = 'cp0010$pr3.QueryList';
$myEnd = '^ WSGL.ClosePageBody;';
$mySearch = 'CURR_VAL.SERIAL_NUMBER), ctarget=>L_VF_FRAME));';
$myReplace = 'CURR_VAL.SERIAL_NUMBER), ctarget=>L_VF_FRAME));'."\n".
'
WSGL.LayoutData(\'<FORM ACTION="cp0010$pr3.clone" METHOD="POST"><INPUT
TYPE="hidden" NAME="P_SERIAL_NUMBER" VALUE="\'||CURR_VAL.SERIAL_NUMBER||\'"><INPUT
TYPE="Submit" VALUE="Clone"></FORM>\');'."\n";
&SimpleSearchRepRange($myStart, $myEnd, $mySearch, $myReplace);
&SimpleSearchRepRange makes it easier to work with
WebPC.
What happens behind the scenes is that &SimpleSearchRepRange
looks for all the meta-characters for you and prefixes them with the required
number of backslashes. Consequently, sometimes you may not want to use
&SimpleSearchRepRange if you do not want some of the meta-characters
to be pre-fixed. This situation may occur when you need to use one or more
meta-characters to tell PERL to do something more elaborate that a search-replace.
This is when you need to use &SearchRepRange.
Warning: |
All &SimpleSearchRepRange does is add backslashes
to your search patterns and call &SearchRepRange. This works 99% of
the time and makes things simpler for you. However it may not work for
complex pattern searches and you may have to use &SearchRepRange and
take care of the meta-characters yourself. |
SimpleSearchRepRange2Start
&SimpleSearchRepRange2Start performs the same task as &SearchRepRange2Start,
but does not require you to prefix PERL's meta-characters with a backslash.
The only exception to this is the single quote: it must always be prefixed
with a backslash. You can compare Listing G with Listing
D to appreciate the difference.
-
Listing G
$myStart = '^-- Name:
gbamebw$age.CreateInsertJavaScript$';
$myStart2 = '^\'function OPTIONAL_REVISION_NUM_LOV() {$';
$myEnd = '^ if LOV_FRAME
is not null then$';
$mySearch = '^
"&Z_ISSUE_WAIT=Y",');$';
$myReplace = '
"&P_APPL_ID=" + document.forms[0].P_APPL_ID.value + //hdd1 modif'."\n".
'
"&Z_ISSUE_WAIT=Y",\');';
&SimpleSearchRepRange2Start ($myStart, $myStart2, $myEnd, $mySearch,
$myReplace);
Double start search/replace.
You will find situations where you need a double start to define a specific
range. Although this might seem very unlikely to you the first time you
read this, you will be faced with a case where you just cannot change a
piece of code without changing other parts of the code that you really
need to leave as they are unless you use a double start.
Warning: |
All &SimpleSearchRepRange2Start does is add
backslashes to your search patterns and call &SearchRepRange2Start.
This works 99% of the time and makes things simpler for you. However it
may not work for complex pattern searches and you may have to use &SearchRepRange2Start
and take care of the meta-characters yourself. |
SimpleSearchRepRangeHdr
&SimpleSearchRepRangeHdr performs the same task as &SearchRepRangeHdr,
but does not require you to prefix PERL's meta-characters with a backslash.
The only exception to this is the single quote: it must always be prefixed
with a backslash. You can compare Listing H with Listing
E to appreciate the difference.
You should very rarely need to use &SimpleSearchRepRangeHdr. If
you need to add routines to the packages generated by Designer, you should
record the code into Designer itself, not in a WebPC .pca file. WebPC should
only be used for small tweaks to the PL/SQL code produced by Designer.
For maintenance reasons, all the business logic must be contained in the
repository.
Listing H shows how we used WebPC to add a parameter to a public PL/SQL
procedure generated by Designer.
-
Listing H
$myStart = '^ procedure optional_revision_num_listofva($';
$myEnd = '^end;$';
$mySearch = '^
Z_CALLER_URL in varchar2,$';
$myReplace = '
Z_CALLER_URL in varchar2,'."\n".
'
P_APPL_ID in varchar2 default null, --hdd3';
&SimpleSearchRepRangeHdr($myStart, $myEnd, $mySearch, $myReplace);
Legitimate use of &SimpleSearchRepRangeHdr.
Warning: |
All &SimpleSearchRepRangeHdr does is add
backslashes to your search patterns and call &SearchRepRangeHdr. This
works 99% of the time and makes things simpler for you. However it may
not work for complex pattern searches and you may have to use &SearchRepRangeHdr
and take care of the meta-characters yourself. |
beep2
beep2 is an internal procedure that produces two beeps. This is used at
the end of compilation with SQL*Plus to signal the end of the job that
could take some time for large modules or slow connection to the database.
You are welcome to use beep2 in your .pca files.
escMetaCharsInSearch
escMetaCharsInSearch is an internal procedure that prefixes meta-characters
with backslashes.
Although we cannot think of circumstances that would required its use
in a .pca file, it is possible to do so.
listPackages
listPackages is an internal function that returns an array containing the
names of PL/SQL packages created by Designer for your when module(s).
You could very well use it in a .pca file to get WebPC to produce additional
DDL.
Advanced
WebPC
This section contains a number of additional WebPC features. It also include
recommendations and guidelines. Some of the sub sections were written by
WebPC users. If you want to contribute to this manual please contact
us using the contact information on the registration page.
Adding
DDL with WebPC
You can use WebPC to perform other tasks than search/replace. For example
you can get it to generate grants statements:
-
Open pc.ini in a text editor.
-
Scroll down towards the end of the file, to the preferences section .
-
Set $c_doUserGrants to 'Y'.
-
Set @c_grantees to the list of users or roles who need execute privilege
on your modules. Example: @c_grantees = ('SCOTT','SYSTEM');.
-
Run WebPC as usual.
This will add DDL code similar to what is shown below. This DDL code is
placed in the .sql driver file named after your module: "Cvw"+<module
shortname>.<file type>.
PROMPT
PROMPT Granting Execute access on package gbchklaw$.
grant execute on gbchklaw$ to SCOTT;
grant execute on gbchklaw$ to SYSTEM;
PROMPT Granting Execute access on package gbchklaw$select_appl.
grant execute on gbchklaw$select_appl to SCOTT;
grant execute on gbchklaw$select_appl to SYSTEM;
PROMPT Granting Execute access on package gbchklaw$checklist.
grant execute on gbchklaw$checklist to SCOTT;
grant execute on gbchklaw$checklist to SYSTEM;
WebPC:
use it but don't abuse it!
WebPC is a very simple and powerful tool. But project management must insure
that it is not being used as a cure for lack of knowledge of Designer.
Using WebPC is as tempting to the developers as making manual modifications
to the code generated by Designer: it provides a quick solution. For example,
a developer could use WebPC to add PL/SQL or JavaScript procedures to the
code generated by Designer. There is no reason to do this with WebPC as
Designer provides a place to record additional logic within the repository.
One significant advantage of defining all logic in Designer is that impact
analysis will be accurate. An example of typical impact analysis question
is: if I change that date column to a varchar2, what is the complete
list of modules that will be affected?
With experience using Designer, developer will also learn to meet the
user requirements with simpler designs that can be more easily generated
from Designer. We caution you against using WebPC to compensate for an
unnecessarily complex design.
WebPC:
Batch Mode
Designer can be used to generate a number of modules in one operation.
This is handy when you want to generate a fresh batch of DDL to install
a new release of your application. To get Designer to do this, open the
Design Editor and select menu option: Tools->Batch Generate then proceed
as follows:
-
Select Generator for Client Applications.
-
Click on Next.
-
Select the modules that you want to generate in Oracle WebServer.
-
Click on Next.
-
The web generator options should be set as this indicated in the
installation guide.
-
Check "Save in repository".
-
Don't Include Module Network.
-
Accept the defaults for the remainder of the preferences.
-
After Designer has completed the generation process, close the log.
From there this is how you can call upon WebPC to do the rest of the work
-
Open a DOS Window.
-
Run the appropriate command to run pc_batch. It must follow this format:
perl <directory where you extracted pc.zip>\pc_batch.pl <location
of generated files set earlier> <number of minutes since the batch run
was started in Designer>. Example: perl h:\pc\pc_batch.pl p:\gab_app\ 10
Make sure that you do call pc_batch.pl, not the usual pc.pl. pc_batch takes
one more parameter than pc.pl. It is the maximum age of the files that
WebPC should work with, expressed in minutes. With 10, WebPC will look
form all .pkb and .pks files that are no more that 10 minutes old. If it
took 127 minutes for Designer to generate all of your application and you
came back to the machine 3 hours later, you should give 3*60+127=307 as
a parameter value to WebPC.
WebPC then processes the modules in the same way as it would process
just one module.
You may want to customize the value of 2 parameters in file pc.ini:
-
$c_SQLLogFileBatch="pc_sql_b.log"; # Name of the Log File kept by
the pre-compiler
-
$c_batchSQLDriveName = "pc_batch.sql"; # Name of the SQL file generated
by the batch pre-compiler.
Too
many backslashes for &SimpleSearchRepRange?
Author: Steve Metzger
Although &SimpleSearchRepRange does prefix one backslash with another
backslash, it does not prefix a backslash that is immediately followed
by another backslash. This means that as soon as you have two or more backslashes
in a row in your search strings, you have to do the prefixing yourself.
You will find with experience that depending on what you are trying to
do, the number of backslashes depends. This is why &SimpleSearchRepRange
does not attempt it. As a practical rule, add backslashes to your search
strings until &SimpleSearchRepRange makes the match.
Here is an example:
I want to comment out the RL_QUERY_BUT_ACTION constant within the QueryList
procedure of one of my modules. The original
code generated by Designer looks like the following. Notice the "\"
that gets generated by Designer.
WSGL.RecordListButton(TRUE, 'Z_ACTION',
htf.escape_sc(RL_QUERY_BUT_CAPTION),p_dojs=>FALSE,
buttonJS => 'onClick="this.form.Z_ACTION.value=\''' || RL_QUERY_BUT_ACTION
|| '\''"');
In such a situation, this is how you can setup the .pca file:
$myStart = '^-- Name:
rfapd2$grants.QueryList$';
$myEnd = '^ htp.formClose;$';
$mySearch = '^
buttonJS => \'onClick="this.form.Z_ACTION.value=\\\'\'\' || RL_QUERY_BUT_ACTION
|| \'\\\'\'"\');';
$myReplace = '
buttonJS => \'onClick="this.form.Z_ACTION.value=\\\'\'\' || RL_QUERY_BUT_ACTION
|| \'\\\'\'"\');';
&SimpleSearchRepRange($myStart, $myEnd, $mySearch, $myReplace);
The simple rule in this situation is this: in order to match a backslash
immediately followed by a single quote in the .pkb file, the search string
must issue 3 backslashes followed by a single quote.
You must not have 2 backslashes followed by a single quote or PERL will
reject your search variable assignment with a message like this:
Backslash found where operator expected at P:\pca\test_bs.pca line
27, near "'^
buttonJS => \'onClick="this.form.Z_ACTION.value=\\'\"
(Missing operator before
\?) syntax error at P:\pca\test_bs.pca line 27, near "'^ buttonJS => \'onClick="this.form.Z_ACTION.value=\\'\"
Multiple
Replace Lines
Author: Steve Metzger
WebPC can be used to not only to search and replace single lines of code
but it can be used to search a single line of code and replaced with multiple
lines. An example of such a search and replace is as follows. This example
is not for the novice user.
$myStart = '^-- Name:
rffirst$.firstpage$';
$myEnd = '^ exception$';
$mySearch = '^ WSGL.DefaultPageCaption(\'\',
1);$';
$myReplace = ' -- WSGL.DefaultPageCaption(\'\', 1);'."\n".
'
htp.centerOpen;'."\n".
'htp.tableOpen(cattributes
=> \'border=0 width=90% CELLPADDING=10 CELLSPACING=10\');'."\n".
'htp.tableRowOpen;'."\n".
'htp.tableData( htf.img(
\'/gab_img/nih_biglogo1.gif\', cattributes => \'border=0 width=157 height=98\'),
'."\n".
'
calign => \'left\');'."\n".
'htp.tableData( \'<FONT
size=7 color=#2e61b0>\' || '."\n".
'
htf.bold( \'Division of Extramural<br>Activities (DEA) Referral Office\')
|| '."\n".
'
\'</FONT>\', calign => \'middle\', cattributes => \'VALIGN="top"\');'."\n".
'htp.tableRowClose;'."\n".
'htp.tableClose;'."\n".
' '."\n".
' '."\n".
'htp.FormOpen(\'rffirst$.flagprocess\');'."\n".
'htp.tableOpen(
cattributes => \'width=90% BORDER=0 CELLPADDING=0 CELLSPACING=20\' );'."\n".
'htp.tableRowOpen;'."\n".
'htp.tableData( \'<FONT
size=6 color=#800000>\' || '."\n".
'htf.strong( \'Grant
Referral Status\') || '."\n".
'
\'</FONT>\', calign => \'middle\', cattributes => \'VALIGN="top" colspan=2\');'."\n".
'htp.tableRowClose;'."\n".
'htp.tableRowOpen;'."\n".
'htp.tableData( \'<FONT
size=4 color=#80000>\' || '."\n".
'
htf.strong(\'(Please check a Grant Referral Status selection and the NCAB
date.'."\n".
'
Once your selection has been made click on the '."\n".
'
\'\'Grant Processing Status\'\' button below.)\') || '."\n".
'
\'</FONT>\', calign=>\'left\', cattributes=>\'valign=top colspan=2\');'."\n".
'htp.tableRowClose;'."\n".
' '."\n".
'htp.tableRowOpen;'."\n".
'htp.print(\'<td
valign=top align=middle colspan=2>\');'."\n".
'htp.print(\'<FONT
size=4 color=#800000>\' || '."\n".
'
htf.strong( \'NCAB Date: \') || \'</FONT>\');'."\n".
'htp.FormSelectOpen(cname=>\'p_ncabdate\',nsize=>\'1\');'."\n".
'IF (v_flag) THEN'."\n".
' htp.FormSelectOption(cvalue=>\'
\',cselected=>\'SELECTED\');'."\n".
' htp.FormSelectOption(cvalue=>\'ALL\');'."\n".
' v_flag := FALSE;'."\n".
'END IF;'."\n".
'FOR boardrec IN boardcur
LOOP'."\n".
' htp.FormSelectOption(cvalue=>boardrec.meeting_month||\'/\'||'."\n".
'
substr(boardrec.meeting_year,3,2),cselected=>\'SELECTED\');'."\n".
'END LOOP;'."\n".
'htp.FormSelectClose;'."\n".
'htp.print(\'</td>\');'."\n".
'htp.tableRowClose;'."\n".
' '."\n".
'htp.tableRowOpen;'."\n".
'htp.print(\'<td
align=right>\');'."\n".
'htp.print(\'<img
src="/gab_img/sm-flagr.gif">\');'."\n".
'htp.print(\'</td>\');'."\n".
'htp.tableData( htf.formRadio(cname=>\'p_flag\',
cvalue=>\'R\')||'."\n".
'
\'<FONT size=4 color=#3232CD face="ms sans serif, arial">\' || '."\n".
'
htf.strong( \'To Be Released\' || \'</FONT>\'));'."\n".
'htp.tableRowClose;'."\n".
''."\n".
'htp.tableRowOpen;'."\n".
'htp.print(\'<td
align=right>\');'."\n".
'htp.print(\'<img
src="/gab_img/sm-flagg.gif"><img src="/gab_img/sm-flagy.gif">\');'."\n".
'htp.print(\'</td>\');'."\n".
' '."\n".
'htp.tableData( htf.formRadio(cname=>\'p_flag\',
cvalue=>\'GY\')||'."\n".
'
\'<FONT size=4 color=#3232CD face="ms sans serif, arial">\' || '."\n".
'
htf.strong( \'To Be Referred / Referred (Awaiting Approval)\' || \'</FONT>\'));'."\n".
'htp.tableRowClose;'."\n".
' '."\n".
' '."\n".
'htp.tableRowOpen;'."\n".
'htp.print(\'<td
align=right>\');'."\n".
'htp.print(\'<img
src="/gab_img/sm-flagb.gif">\');'."\n".
'htp.print(\'</td>\');'."\n".
'htp.tableData( htf.formRadio(cname=>\'p_flag\',
cvalue=>\'B\')||'."\n".
'
\'<FONT size=4 color=#3232CD face="ms sans serif, arial">\' || '."\n".
'
htf.strong( \'Approved\' || \'</FONT>\'));'."\n".
'htp.tableRowClose;'."\n".
' '."\n".
'htp.tableRowOpen;'."\n".
'htp.print(\'<td
align=right>\');'."\n".
'htp.print(\'<img
src="/gab_img/sm-flagp2.jpg">\');'."\n".
'htp.print(\'</td>\');'."\n".
'htp.tableData( htf.formRadio(cname=>\'p_flag\',
cvalue=>\'OR\')||'."\n".
'
\'<FONT size=4 color=#3232CD face="ms sans serif, arial">\' || '."\n".
'
htf.strong( \'Rejected - Requires Re-Referral\' || \'</FONT>\'));'."\n".
'htp.tableRowClose;'."\n".
' '."\n".
'htp.tableClose;'."\n".
'htp.para;'."\n".
'htp.formSubmit(cvalue=>\'Grant
Referral Status\');'."\n".
'htp.p(\'<SPACER
TYPE=horizontal size=10>\');'."\n".
'htp.formReset(cvalue=>\'Clear
Selection\');'."\n".
'htp.FormClose;'."\n".
' '."\n".
'htp.tableOpen(
cattributes => \' border=0\' );'."\n".
'htp.tableRowOpen;'."\n".
'htp.tableData( \'<FONT
size=3>\' || '."\n".
'
htf.anchor( \'ncicommon.referconstruction\', \'Status of All Grants \',
cattributes => \' target="_top"\')
|| '."\n".
'
\'| \' ||'."\n".
'
htf.anchor( \'ncicommon.referconstruction\', \'Archived Grants \', cattributes
=> \' target="_top"\') ||
'."\n".
'
\'| \' || '."\n".
'
htf.anchor( \'ncicommon.referconstruction\', \'Set SRA for RFA/PA \', cattributes
=> \' target="_top"\') ||
'."\n".
'
\'| \' || '."\n".
'
htf.anchor( \'ncicommon.referconstruction\', \'Enter Date, Update \', cattributes
=> \' target="_top"\') ||
'."\n".
'
\'| \' ||'."\n".
'
htf.anchor( \'ncicommon.referconstruction\', \'Added Grants\', cattributes
=> \' target="_top"\') ||
'."\n".
'
\'</FONT>\', calign => \'center\');'."\n".
'htp.tableRowClose;'."\n".
'htp.tableClose;'."\n".
' '."\n".
' '."\n".
'htp.para;
'."\n".
'htp.tableOpen(
cattributes => \' border=0 width=80%\' );'."\n".
'htp.tableData( \'<FONT
size="6">\' || '."\n".
'
htf.img( \'/gab_img/sb11.gif\', cattributes => \' border="0" width="550"
height="5"\') || '."\n".
'
\'</FONT>\', calign => \'middle\', cattributes => \' valign="bottom"\');'."\n".
'htp.tableRowClose;
'."\n".
'htp.tableClose;'."\n".
' '."\n".
'htp.tableOpen(
cattributes => \' border=0 width=90%\' );'."\n".
'htp.tableRowOpen;'."\n".
'htp.tableData( \'<FONT
size=3>\' || '."\n".
'
htf.anchor( \'rfhome$.startup\', \'Grant Referral Home \', cattributes
=> \' target="_top"\') || '."\n".
'
\'| \' ||'."\n".
'
htf.anchor( \'rffirst$.startup\', \'Grant Referral Status Page \', cattributes
=> \' target="_top"\') ||
'."\n".
'
\'| \' || '."\n".
'
htf.anchor( \'rfmaint$.startup\', \'Grant Referral Maintenance Page\',
'."\n".
'
cattributes => \' target="_top"\') || '."\n".
'
\'</FONT>\', calign => \'center\');'."\n".
'htp.tableRowClose;'."\n".
' '."\n".
'htp.tableClose;'."\n".
'htp.centerClose;
';
&SimpleSearchRepRange($myStart, $myEnd, $mySearch, $myReplace);
How
to stop WebPC from launching the browser
WebPC launches your browser everytime you generate a new module. You may
prefer to work otherwise. For example you can choose to open the browser
yourself and open up your module from there. This has the advantage of
reducing the number of windows open.
To instruct WebPC not to launch the browser:
-
Open the file 'pc.ini' in an editor.
-
Scroll down to the section called preferences.
-
Set $c_CallBrowser to 'N'.
How
to stop WebPC from beeping after installation of the packages
WebPC's default behavior is to issue a double beep when the installation
of the packages is complete. This is because the installation process can
take several minutes.
To instruct WebPC not to beep:
-
Open the file 'pc.ini' in an editor.
-
Scroll down to the section called preferences.
-
Set $c_Beep to 'N'.
Troubleshooting
There are times when you make a syntax error in a .pca file (like forget
to backslash a single quote) when WebPC will not even be able to display
the run log and the system gets back to Designer without a hint of what
went wrong.
What follows is a method to get a feel for what went wrong. This method
is intended for users running Designer on Windows NT, 98 or 95.
-
Open up a DOS window.
-
Type perl <directory where you extracted pc.zip>\pc.pl <location
of generated files set earlier>, as shown above.
If you have used the same directory names as we showed in our examples,
you could type perl h:\pc\pc.pl p:\gab_app\
You should now see error messages in the DOS window.
If you forgot to backslash a single quote, you will get this kind of
error message from PERL:
Bareword found where operator expected at P:\pca\CVWGBCHKLAW.pca
line 3, near "'
^ exce'ption"
(Missing operator before
ption?)
syntax error at P:\pca\CVWGBCHKLAW.pca line 3, near "'^
exce'ption"
If the log does not get displayed and you get a file not found error,
check the file pc.ini and the installation instructions.
If you get an error message like "No application wide action file was
found", copy the file WebPC.pca from WebPC home directory to the directory
where the .pca files may be found. This is explained in the installation
instructions.
If the log is displayed but SQL*Plus does not run, check pc.ini and
the WebServer Options in Designer. Make sure that you followed the installation
instructions for WebPC.
If the log is displayed, SQL*Plus executes the DDL but your browser
does not run, check pc.ini and the WebServer Options. Make sure that you
followed the installation instructions for WebPC.
If all else fails, contact hdescham@us.oracle.com with a precise
definition of your problem and the release number of WebPC that you are
running.