Database Reference
In-Depth Information
56
57 # parse an anonymous PL/SQL block for retrieving the ORACLE DBMS version
58 # and compatibility as well as the database and instance names
59 # V$ views are not used, since they may be accessed by privileged users only
60 # quoting with q{<SQL or PL/SQL statements>} is used, since
61 # it avoids trouble with quotes (", ')
62 $sth = $dbh->prepare(q{
63 begin
64 dbms_utility.db_version(:version, :compatibility);
65 :result:=dbms_utility.get_parameter_value('db_name',:intval, :db_name
);
66 :result:=dbms_utility.get_parameter_value('instance_name', :intval,
67 :instance_name);
68 end;
69 });
70 my ($version, $compatibility, $db_name, $instance_name, $result, $intval);
71 $sth->bind_param_inout(":version", \$version, 64);
72 $sth->bind_param_inout(":compatibility", \$compatibility, 64);
73 $sth->bind_param_inout(":db_name", \$db_name, 9);
74 $sth->bind_param_inout(":instance_name", \$instance_name, 16);
75 $sth->bind_param_inout(":intval", \$intval, 2);
76 $sth->bind_param_inout(":result", \$result, 1);
77 $sth->execute;
78
79 $sth = $dbh->prepare(q{SELECT userenv('sid'),
80 to_char(sysdate, 'Day, dd. Month yyyy hh24:mi:ss "(week" IW")"') FROM dual}
);
81 $sth->execute;
82 my ($sid, $date_time);
83 # pass reference to variables which correspond to columns in
84 # SELECT from left to right
85 $sth->bind_columns(\$sid, \$date_time);
86 my @row = $sth->fetchrow_array;
87
88 printf "Connected to ORACLE instance %s, release %s (compatible=%s)",
89 $instance_name, $version, $compatibility;
90 printf "; Database %s\n", $db_name;
91 # due to bind_columns, may use meaningful variable names instead of $row[0],
etc.
92 printf "Session %d on %s\n", $sid, $date_time;
93
94 $sth = $dbh->prepare("INSERT INTO customer(name, phone) VALUES (:name, :phone
)
95 RETURNING id INTO :id", { ora_check_sql => 0 });
96 # loop, number of iterations is in command line argument
97 for (my $i=0; $i < $ARGV[0]; $i++) {
98 # bind_param_inout is for receiving values from the DBMS
Search WWH ::




Custom Search