summaryrefslogtreecommitdiff
path: root/web/src/cgi.tcl-1.10/example/oratcl.cgi
blob: de4a7626d49ba7260867f34779ea3f0714128471 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/depot/path/tclsh

# This is a CGI script that demonstrates how easy it is to use a web
# page to query an Oracle server - using cgi.tcl and Oratcl.
# This example fetches the date from Oracle.

# I wish we had a public account on our Oracle server so that I could
# allow anyone to run this, but alas we don't.  So you'll have to
# trust me that it works. - Don

package require cgi
package require Oratcl

cgi_eval {
    source example.tcl

    cgi_title "Oracle Example"
    cgi_input

    cgi_body {
	set env(ORACLE_SID) fork
	set env(ORACLE_HOME) /u01/oracle/product/7322

	set logon [oralogon [import user]  [import password]]
	set cursor [oraopen $logon]

	orasql $cursor "select SysDate from Dual"
	h4 "Oracle's date is [orafetch $cursor]"

	oraclose $cursor
	oralogoff $logon
    }
}