The Instructional Oracle Perl/DBI Example Script perldbi.pl retrieves and updates the table "counter_table" from a test Instructional Oracle account. ( To review the actual source code see perldbi.pl source code. To execute the script click on this link run perldbi.pl.) This table was created ( you can use the Secure SQL Editor to execute SQL commands on your Instructional Oracle account ) with the following SQL command :
Create table counter_table( counter number, last_update_time date);
There is currently one row in this table. The example script first connects to the Instructional Oracle database with the specified Oracle account and password. After a successful connection, the script retrieves the current values from that row. Next the script updates that row by incrementing the counter by one and storing the current time "sysdate" in the date column. It is important to execute a commit before either disconnecting from the database or terminating the script. If the commit command is not issued then the updates will not take effect. After the commit, the script retrieves the current values for that table. The before values and after values are then displayed. This table counter_table effectively tracks the number of times this example script was run and the last time the script was run.
Since the Oracle account and password are stored in the script source, one must set the permissions for the script so that only the owner has read/write/execute permissions. You can check by using the ls command on the script in your campuscgi directory.
tucson.Princeton.EDU% ls -ld perldbi.pl -rwx------ 1 storacle 5931 Aug 2 11:10 perldbi.plYou can use the chmod command to set the correct permissions
tucson.Princeton.EDU% chmod 700 perldbi.plNote that if you want others to be able to run your script, you can set the group and others execute permissions with the following chmod command ( remember to use the ls command to verify the permissions ).
tucson.Princeton.EDU% chmod 711 perldbi.pl tucson.Princeton.EDU% ls -ld perldbi.pl -rwx--x--x 1 storacle 5931 Aug 2 11:10 perldbi.pl
On the Unix arizona machines, users can execute their campuscgi perl scripts directly from their campuscgi directory. This provides a useful environment to test and debug the campuscgi perl scripts.
tucson.Princeton.EDU% pwd /usr/campuscgi/storacle tucson.Princeton.EDU% ls perldbi.pl tucson.Princeton.EDU% perldbi.pl Content-Type: text/html; charset=ISO-8859-1Instructional Oracle Perl/DBI Example Instructional Oracle Perl/DBI Example
Values Before Update
Counter[ 5240 ] Last_Update_Time[ 08/02/2004 11:10 ]Values After Update
Counter[ 5241 ] Last_Update_Time[ 08/02/2004 11:11 ] If your perl scripts generate html output, you can use Princeton University Campus CGI Facility development environment to test and debug your campuscgi perl/dbi/Instructional Oracle account scripts.
Source For Instructional Oracle Perl/DBI Example Script