04-14-2005
Get Oracle fuction return value in a variable
Hi All,
I have the following code.
var=' '
sqlplus user/pass@DB <<EOF
whenever sqlerror exit 1
select package.func() into $var from dual;
EOF
echo $var
But, this code does not work to display the value returned by the oracle function. Do we have to bind variables before getting their values, like we do in PERL. Do Let me know.
Thanks.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am writing a unix script that logs into oracle and does a count on a table. I want to return that count to my unix script. this is my script:
#!/bin/ksh
typeset retcode;
numin=0
sqlplus -s <<-EOSQL
myuser/mypass@mydb
variable ret_val number;
begin
... (3 Replies)
Discussion started by: lesstjm
3 Replies
2. Shell Programming and Scripting
Guys,
I´m have this problem and I do not know what to do anymore:
cod=`sqlplus -s ${DATABASE} << EOF
set heading off feedback off verify off
select max(eventid) from events;
exit
EOF`
sed "s/CODEVENTID/${cod}/" c.ctl
Abova What I´ve done. The CODEEVENTID is already set into a... (1 Reply)
Discussion started by: Rafael.Buria
1 Replies
3. Shell Programming and Scripting
Hi All,
I have a perl script(1.pl) that calls a c function defined in another file sample.c
#!/usr/bin/perl
my $re = 1;
my @s = `/home/PERL_SCRIPTING/Rough/sample pline $re 10`;
print "$_" foreach(@s);
The sample.c is as bwlow:
# include <stdio.h>
int pline(int, int);... (4 Replies)
Discussion started by: jisha
4 Replies
4. UNIX for Dummies Questions & Answers
Hi ,
i have written a shell scipt to call a procedure and get the value back from procedure.But i am facing the issue like
#!/bin/sh
returnedvalue=`sqlplus -s userid/pass<<EOF
set serveroutput on;
exec pass($1)
set serveroutput off;
EXIT;
EOF`
flag=`echo $returnedvalue `
echo "$flag"... (2 Replies)
Discussion started by: ravi214u
2 Replies
5. Shell Programming and Scripting
I need help . I am not getting anything back from my setup. I have defined an oracle package which I am calling from within my sql call, but is returning no rows. If I run my sql from sqlplus works find, does not work whe I try to run from UNIX shell script
My korn script test.ksh
#!bin/ksh... (6 Replies)
Discussion started by: TimHortons
6 Replies
6. Shell Programming and Scripting
I want to instert Category:XXXXX into the 2. line
something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong:
sed "2i\\${n}Category:$cat\n"
Sample:
Titel Blahh Blahh abllk sdhsd sjdhf
Blahh Blah Blahh
Blahh
Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies
7. UNIX and Linux Applications
Having searched high and low through Oracles documentation, I came to think that they're very scripting-averse, as there's (apparently) no list of possible return/exit codes for their various command line utilities.
Is anyone here in possession of such a list, or knows where to find one? It... (16 Replies)
Discussion started by: pludi
16 Replies
8. Shell Programming and Scripting
So, in Oracle (11gR2) on aix I have a function like:
CREATE OR REPLACE function COMMON.t2(var1 in varchar2, vari in number,var2 in out number) return number as
begin
insert into korisnik_temp(kor_inicia, kor_opisno) values(1, var1);
var2:=0;
return var2;
exception
when... (12 Replies)
Discussion started by: bongo
12 Replies
9. UNIX and Linux Applications
Good evening
I nned your help pls, In an unix server i want to connect to a remote oracle databse server by sqlplus.
I tried to find out the user/passwd and service name by env variable and all Ive got is this:
ORACLE_SID_REPCOL=SCL_REPCOL
ORACLE_SID=xmeta
ORACLE_SID_TOL=SCL_PROTOLCOL... (2 Replies)
Discussion started by: alexcol
2 Replies
LEARN ABOUT PHP
oci_error
OCI_ERROR(3) OCI_ERROR(3)
oci_error - Returns the last error found
SYNOPSIS
array oci_error ([resource $resource])
DESCRIPTION
Returns the last error found.
The function should be called immediately after an error occurs. Errors are cleared by a successful statement.
PARAMETERS
o $resource
- For most errors, $resource is the resource handle that was passed to the failing function call. For connection errors with
oci_connect(3), oci_new_connect(3) or oci_pconnect(3) do not pass $resource.
RETURN VALUES
If no error is found, oci_error(3) returns FALSE. Otherwise, oci_error(3) returns the error information as an associative array.
oci_error(3) Array Description
+----------+--------------------------------------+---+
|Array key | | |
| | | |
| | Type | |
| | | |
| | Description | |
| | | |
+----------+--------------------------------------+---+
| | | |
| code | | |
| | | |
| | | |
| | integer | |
| | | |
| | The Oracle error number. | |
| | | |
| | | |
| message | | |
| | | |
| | | |
| | string | |
| | | |
| | The Oracle error text. | |
| | | |
| | | |
| offset | | |
| | | |
| | | |
| | integer | |
| | | |
| | The byte position of an error in | |
| | the SQL statement. If there was no | |
| | statement, this is 0 | |
| | | |
| | | |
| sqltext | | |
| | | |
| | | |
| | string | |
| | | |
| | The SQL statement text. If there | |
| | was no statement, this is an empty | |
| | string. | |
| | | |
+----------+--------------------------------------+---+
EXAMPLES
Example #1
Displaying the Oracle error message after a connection error
<?php
$conn = oci_connect("hr", "welcome", "localhost/XE");
if (!$conn) {
$e = oci_error(); // For oci_connect errors do not pass a handle
trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
?>
Example #2
Displaying the Oracle error message after a parsing error
<?php
$stid = oci_parse($conn, "select ' from dual"); // note mismatched quote
if (!$stid) {
$e = oci_error($conn); // For oci_parse errors pass the connection handle
trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
?>
Example #3
Displaying the Oracle error message, the problematic statement, and the position of the problem of an execution error
<?php
$stid = oci_parse($conn, "select does_not_exist from dual");
$r = oci_execute($stid);
if (!$r) {
$e = oci_error($stid); // For oci_execute errors pass the statement handle
print htmlentities($e['message']);
print "
<pre>
";
print htmlentities($e['sqltext']);
printf("
%".($e['offset']+1)."s", "^");
print "
</pre>
";
}
?>
PHP Documentation Group OCI_ERROR(3)