Sponsored Content
Top Forums Programming Could't pass clob from my shell script Post 302458076 by mayukh.banerjee on Wednesday 29th of September 2010 02:24:17 PM
Old 09-29-2010
Could't pass clob from my shell script

Hello Everyone,
I am trying to write a shell script that will read from a file and will call a pl/sql procedure that takes clob as input.
Now as varchar2 has a limit much less than clob so i can't just pass the input as in one variable.(size may be >32K).

This is what i tried. Not posting the whole code. I am using korn shell.--

Code:
sqltext="declare i_clob clob; begin "
sqltmp=""
while read -r line
do
file="$file\n$line"
done < $filename
length=${#file}
while [ $count -lt $length ]
do
tmp=`expr substr "$file" 1 32000`
sqltml="$sqltmp i_clob:=i_clob||to_clob('$tmp');"
done
sqltext="$sqltext $sqltmp procedure1(i_clob); end;"
sqlplus -s user/pass@sid > output.log <<EOF
$sqltext
/
EOF

I am getting an error saying::
sp2 0027 input is too long (greather than 2499 ..

Any help will be greatly appreciated.

Thanks in advance
MB

Last edited by pludi; 09-29-2010 at 06:17 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fetching CLOB value from oracle into shell script

Hi, Can anybody let me know how i can achieve the below output. I have a select query which selects two columns. I need to spool the value into a dat file for each row that is returned from the query with the coulumn1 as the name of the dat file . ex: column1: location_id column2:... (1 Reply)
Discussion started by: justchill
1 Replies

2. Shell Programming and Scripting

call another shell script and pass parameters to that shell script

Hi, I basically have 2 shell scripts. One is a shell script will get the variable value from the user. The variable is nothing but the IP of the remote system. Another shell script is a script that does the job of connecting to the remote system using ssh. This uses a expect utility in turn. ... (2 Replies)
Discussion started by: sunrexstar
2 Replies

3. Shell Programming and Scripting

How to call stored procedure with CLOB out parameter from shell script?

I have written a stored procedure in oracle database, which is having a CLOB OUT parameter. How can i call this stored procedure from shell script and get the CLOB object in shell script variable? (0 Replies)
Discussion started by: vel4ever
0 Replies

4. Shell Programming and Scripting

How to write CLOB parameter in a file or XML using shell script?

I executed a oracle stored procedure using shell script. How can i get the OUT parameter of the procedure(CLOB) and write it in a file or XML in UNIX environment using shell script? (2 Replies)
Discussion started by: vel4ever
2 Replies

5. Post Here to Contact Site Administrators and Moderators

Unable to pass shell script parameter value to awk command in side the same script

Variable I have in my shell script diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk -F'~' ''$2 == "$id"' {print $0}' > $new I could see value of $id is not passing to the awk... (0 Replies)
Discussion started by: Ashunayak
0 Replies

6. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

7. Shell Programming and Scripting

How to pass Oracle sql script as argument to UNIX shell script?

Hi all, $ echo $SHELL /bin/bash Requirement - How to pass oracle sql script as argument to unix shell script? $ ./output.sh users.sql Below are the shell scripts and the oracle sql file in the same folder. Shell Script $ cat output.sh #!/bin/bash .... (7 Replies)
Discussion started by: a1_win
7 Replies

8. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

9. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

10. Shell Programming and Scripting

Pass C shell array to another C shell script(csh) and shell(sh)

Dear Friends, Please help me on this my script name is send.csh In this i have written the statement like this set args = ( city state country price ) I want to pass this array to another c shell called receiver.csh. and i want to use it in this c shell or how to pass to... (2 Replies)
Discussion started by: SA_Palani
2 Replies
OCI_NEW_DESCRIPTOR(3)													     OCI_NEW_DESCRIPTOR(3)

oci_new_descriptor - Initializes a new empty LOB or FILE descriptor

SYNOPSIS
OCI-Lob oci_new_descriptor (resource $connection, [int $type = OCI_DTYPE_LOB]) DESCRIPTION
Allocates resources to hold descriptor or LOB locator. PARAMETERS
o $connection - An Oracle connection identifier, returned by oci_connect(3) or oci_pconnect(3). o $type - Valid values for $type are: OCI_DTYPE_FILE, OCI_DTYPE_LOB and OCI_DTYPE_ROWID. RETURN VALUES
Returns a new LOB or FILE descriptor on success, FALSE on error. EXAMPLES
Example #1 oci_new_descriptor(3) example <?php /* This script is designed to be called from a HTML form. * It expects $user, $password, $table, $where, and $commitsize * to be passed in from the form. The script then deletes * the selected rows using the ROWID and commits after each * set of $commitsize rows. (Use with care, there is no rollback) */ $conn = oci_connect($user, $password); $stmt = oci_parse($conn, "select rowid from $table $where"); $rowid = oci_new_descriptor($conn, OCI_D_ROWID); oci_define_by_name($stmt, "ROWID", $rowid); oci_execute($stmt); while (oci_fetch($stmt)) { $nrows = oci_num_rows($stmt); $delete = oci_parse($conn, "delete from $table where ROWID = :rid"); oci_bind_by_name($delete, ":rid", $rowid, -1, OCI_B_ROWID); oci_execute($delete); echo "$nrows "; if (($nrows % $commitsize) == 0) { oci_commit($conn); } } $nrows = oci_num_rows($stmt); echo "$nrows deleted... "; oci_free_statement($stmt); oci_close($conn); ?> <?php /* This script demonstrates file upload to LOB columns * The formfield used for this example looks like this * <form action="upload.php" method="post" enctype="multipart/form-data"> * <input type="file" name="lob_upload" /> * ... */ if (!isset($lob_upload) || $lob_upload == 'none'){ ?> <form action="upload.php" method="post" enctype="multipart/form-data"> Upload file: <input type="file" name="lob_upload" /><br /> <input type="submit" value="Upload" /> - <input type="reset" value="Reset" /> </form> <?php } else { // $lob_upload contains the temporary filename of the uploaded file // see also the features section on file upload, // if you would like to use secure uploads $conn = oci_connect($user, $password); $lob = oci_new_descriptor($conn, OCI_D_LOB); $stmt = oci_parse($conn, "insert into $table (id, the_blob) values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob"); oci_bind_by_name($stmt, ':the_blob', $lob, -1, OCI_B_BLOB); oci_execute($stmt, OCI_DEFAULT); if ($lob->savefile($lob_upload)){ oci_commit($conn); echo "Blob successfully uploaded "; }else{ echo "Couldn't upload Blob "; } $lob->free(); oci_free_statement($stmt); oci_close($conn); } ?> Example #2 oci_new_descriptor(3) example <?php /* Calling PL/SQL stored procedures which contain clobs as input * parameters (PHP 4 >= 4.0.6). * Example PL/SQL stored procedure signature is: * * PROCEDURE save_data * Argument Name Type In/Out Default? * ------------------------------ ----------------------- ------ -------- * KEY NUMBER(38) IN * DATA CLOB IN * */ $conn = oci_connect($user, $password); $stmt = oci_parse($conn, "begin save_data(:key, :data); end;"); $clob = oci_new_descriptor($conn, OCI_D_LOB); oci_bind_by_name($stmt, ':key', $key); oci_bind_by_name($stmt, ':data', $clob, -1, OCI_B_CLOB); $clob->write($data); oci_execute($stmt, OCI_DEFAULT); oci_commit($conn); $clob->free(); oci_free_statement($stmt); ?> NOTES
Note In PHP versions before 5.0.0 you must use ocinewdescriptor(3) instead. This name still can be used, it was left as alias of oci_new_descriptor(3) for downwards compatability. This, however, is deprecated and not recommended. SEE ALSO
oci_bind_by_name(3). PHP Documentation Group OCI_NEW_DESCRIPTOR(3)
All times are GMT -4. The time now is 09:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy