How to print huge values in sqlplus variable in UNIX?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to print huge values in sqlplus variable in UNIX?
# 1  
Old 06-28-2013
How to print huge values in sqlplus variable in UNIX?

Hi,

I ahve a unix code as below.
Code:
sqlTxt=$*
sqlReturn=`echo "set feedback off;
set heading off;
set term off;
set verify off;
set serveroutput on size unlimited
set lin 1000;
VARIABLE GV_return_val NUMBER;
VARIABLE GV_script_error varchar2(4000);
EXEC :GV_return_code := 0;
EXEC :GV_script_error := NULL;
WHENEVER SQLERROR EXIT ${FATAL}
$sqlTxt
/
print :GV_script_error;
exit :GV_return_code;
" | sqlplus -s ${connectStr}`

Now from another program GV_script_error variable is getting populated and they value of that charecter string is nearly 12000 charecter.

In sqlplus I can't print more than 4000 so when that huge amount of value is getting passed in this GV_script_error variable it's not priniting anything and the below error is coming as chareter size is greater than 4000.

"
Code:
PL/SQL: numeric or value error: character string buffer too small
"

So in this scenario I need to append/merge the value in two variables or I need to find out some other way to print all the charecters that is getting passed in GV_script_error variable whether it may be > 4000 .

Can you please give me a idea for this .

Thanks in advance.

So

Last edited by vbe; 06-28-2013 at 12:35 PM.. Reason: please use code tags...
# 2  
Old 06-28-2013
It is obvious that with varchar2 datatype you can define maximum 4000 bytes. So did you consider using any Large Object (LOB) Datatypes?
# 3  
Old 06-28-2013
Thanks for the suggestions.
I didn't consider LOB datatypes.
How I will do this?
# 4  
Old 06-28-2013
Define your bind variable: GV_script_error as CLOB which can store up to 4GB of character data:
Code:
VARIABLE GV_script_error CLOB;

This User Gave Thanks to Yoda For This Post:
# 5  
Old 06-28-2013
Hi Yoda,

I'm getting the error like this.

ORA-01461: can bind a LONG value


GV_script_error is assigned as a out parameter while calling a packaged function where out parameter in package is alos clob.

So I'm not getting why the error is coming.
# 6  
Old 06-28-2013
The ORA-01461 error states that you are trying to bind a LONG datatype to a different datatype.

LONG and LONG RAW datatypes are deprecated, change it to CLOB datatype.
# 7  
Old 06-28-2013
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sqlplus variable UNIX

hi guys i have a sqlplus : sqlplus -s username/password << EOF @mysql.sql EOF in mysql.sql there is a count of a table, i want to write in a variabile unix. how can i do? Thanks a lot Regards Francesco. (3 Replies)
Discussion started by: Francesco_IT
3 Replies

2. UNIX for Dummies Questions & Answers

More efficient way to print variable values?

Hello, Through the process of a executing a shell script, I extract the values for a number of variables (arbitrarily declared as a through i) and towards the end I print them out like shown below: #!bin/sh # bits of code to get values for the variables ...... ...... # print the values... (4 Replies)
Discussion started by: Gussifinknottle
4 Replies

3. Shell Programming and Scripting

Passing multiple column values to UNIX variable

sqlplus -s $USER_ID@$SID/$PWD<<EOF>sql_1.txt set feedback off set heading off select 114032 as c_1 from dual ; EOF for i in `cat sql_1.txt` do sh script_1.sh $i Currently i am passing one column value to the single unix variable. How can i pass the values from 2... (2 Replies)
Discussion started by: rafa_fed2
2 Replies

4. Shell Programming and Scripting

Piping Unix Variable Array values into AWK

#ksh Here is my code: ERRORLIST="43032 12001 12002 12003 12004 34019 49015 49016 49017 49018 49024 49025 49026 58004 72003 12005 12006 12007 12008 12011 12012 16024 16023" for ERROR in ${ERRORLIST} do awk -v l="$lastdate" '/^....-..-../&&$0>l{d=$0}d&&/Error: '"${ERROR}"'/{print... (3 Replies)
Discussion started by: k1ko
3 Replies

5. Shell Programming and Scripting

How to print array values whose name is inside a variable

I have a array as CArray=( a1 a2 ) and a1,a2,a3 are also array as: a1=(1 2 3) a2=(3 4 5) now I have this in my code: for i in `echo "${CArray}"` do echo ${$i} done It is giving error as :"bad substitution" It should give me value as 1 2 3 3 4 5 how can I get this...Can u please... (2 Replies)
Discussion started by: joshilalit2004
2 Replies

6. UNIX for Dummies Questions & Answers

how to print the values of pcpu of any process in unix

hiiiiiiiiii this is shyam.i have written a code that it will take the process id of any process and using it print the value of pcpu etc but the problem is it prints the same value every time it is in loop the code for this is given below. while true do y=`ps... (2 Replies)
Discussion started by: ronit_ok2000
2 Replies

7. Shell Programming and Scripting

Passing the unix variable to sqlplus

Hi, I am writing a script which creates an external table using a shell script. My requirement is like this. Usage: . ./r.ksh <table_name> - this should create an external table. e.g . ./r.ksh abc - this should create an external table as abc_external. How do i achieve this? Please... (5 Replies)
Discussion started by: Anaramkris
5 Replies

8. UNIX for Dummies Questions & Answers

select count(*) in sqlplus into variable unix shell

Need to select count(*) from table to check for zero result in unix script (2 Replies)
Discussion started by: struggle
2 Replies

9. UNIX for Advanced & Expert Users

passing unix variable to sqlplus without a file name

Hi, I want to input unix variable to sqlplus.The following is working fine sqlplus username/password @dummy.sql param1 param2 << EOF create user $1 identified by $2; EOF But I dont want any file name to be passed,I just want to pass the parameter. Is there any way to that?? Thanks... (3 Replies)
Discussion started by: sakthi.abdullah
3 Replies

10. UNIX for Advanced & Expert Users

How to pass unix variable to SQLPLUS

hi fellows, can any body tell me how to pass unix variables to oracle code is... #! /bin/ksh echo ENTER DATE VALUE's read START_DATE END_DATE sqlplus xyx/abc@oracle select * from table1 where coloumn1 between $START_DATE and $END_DATE; is this is correct way........... Thanks in... (1 Reply)
Discussion started by: chiru
1 Replies
Login or Register to Ask a Question