Sponsored Content
Top Forums Shell Programming and Scripting Passing Shell array to SQLPlus Post 302580308 by felipe.vinturin on Thursday 8th of December 2011 05:47:53 AM
Old 12-08-2011
Check the code below:
Code:
$ cat testScript.sh
buildSQLPlusExecStr ()
{
	unset sqlStr
	
	arrayCountPos=0
	arrayLastPos=${#FileName[@]}
	while [ ${arrayCountPos} -lt ${arrayLastPos} ]
	do
		currValue="${FileName[${arrayCountPos}]}"
		# Do you really need the line below?
		# sqlStr="${sqlStr} \n exec :deptno := '${currValue}'"
		# sqlStr="${sqlStr} \n select customer_name from customer where customer_id=:deptno;"
		
		# Can't you just do this?
		sqlStr="${sqlStr} \n select customer_name from customer where customer_id='${currValue}';"
		arrayCountPos=`expr ${arrayCountPos} + 1`
	done
}

FileName[0]=1000
FileName[1]=2000
FileName[2]=3000
FileName[3]=4000

buildSQLPlusExecStr

echo -e "${sqlStr}"

$ ./testScript.sh
 select customer_name from customer where customer_id='1000';
 select customer_name from customer where customer_id='2000';
 select customer_name from customer where customer_id='3000';
 select customer_name from customer where customer_id='4000';

I hope it helps!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing parameters from a shell script to sqlplus

Hi , I want to pass parameters from a shell script to a sql script and use the parameter in the sql query ..and then I want to spool a particular select query on to my unix box... for 4 different locations by writing only one sql script Right now no file is generated on the unix box...it is a... (2 Replies)
Discussion started by: phani
2 Replies

2. 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

3. Shell Programming and Scripting

error in passing a variable to sqlplus from a shell script

hi, I am using a shell script from where i will be conecting to sqlplus.. i am having a problem in passing a variable to sqlplus query.. i will be assigning the variable in the unix environment..whenever i am trying to pass a variable having the contents greater than 2500 characters, i am... (3 Replies)
Discussion started by: kripssmart
3 Replies

4. 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

5. Shell Programming and Scripting

Passing a file handler and an array from Perl to Shell Script

Hi there, I am trying to call a shell script from a Perl script. here is the code: @args = ("sh", "someshellprg.sh", "a file handler", "an array"); system(@args) == 0 or die "system @args failed: $?"; in the shell program, I examine if the arguments exits using: if then echo... (5 Replies)
Discussion started by: pinkgladiator
5 Replies

6. Shell Programming and Scripting

Shell Script passing parameters to sqlplus code

Hello All, I am interested in finding out a way to pass parameters that are entered at the prompt from HP unix and passed to SQLPlus code with a Shell Script. Is this possible? Thanks (4 Replies)
Discussion started by: compprog11
4 Replies

7. Shell Programming and Scripting

Passing a parameter from a shell script to sqlplus

Hi All, I'm new to Linux and scripting, apologies in advance for 'stupid' questions. Please help... Im writing a script that calls a sqlplus script but the sqlplus requires inputs and i cant seem to get this to work. here is my code. #!/bin/sh TERM=vt100 export TERM... (4 Replies)
Discussion started by: Mahomed
4 Replies

8. Shell Programming and Scripting

Passing sqlplus output to shell variable

Hi , I am using below code : for i in `ps -ef|grep pmon|awk {' print $8 '}|cut -f3 -d'_'|grep -v '^grep'` do ORACLE_SID=$i export ORACLE_SID; dest=`sqlplus "/ as sysdba" <<EOF set heading off feedback on verify off select DESTINATION from v\\$archive_dest where target in... (5 Replies)
Discussion started by: admin_db
5 Replies

9. Shell Programming and Scripting

Passing Oracle function as file input to sqlplus

Apologies if this is the incorrect forum.There is an issue in the function call I am facing while calling the same from a unix shell scripts. Basically, I want the ref cursor to return values to a variable in sqlpus. The function call is currently saved in a ".txt" file in a unix location. I want... (7 Replies)
Discussion started by: amvip
7 Replies

10. Shell Programming and Scripting

Passing string from bash to sqlplus

Hello, I have file (PARFILE) with string on first line: INCLUDE=SCHEMA:"IN\( 'SCHEMA1','SCHEMA2','SCHEMA3' \)"In .sh script I use: .... IMPORT_SCHEMA=`awk 'NR==1{print $2}' ${PARFILE}` ...print $2 is because 'SCHEMA1','SCHEMA2','SCHEMA3' is 2nd column in file echo "$IMPORT_SCHEMA"... (5 Replies)
Discussion started by: DjukaZg
5 Replies
STRMSGSZ(5)							File Formats Manual						       STRMSGSZ(5)

NAME
STRMSGSZ - maximum size of streams message data (bytes) VALUES
Failsafe Default Allowed values Recommended values DESCRIPTION
This tunable limits the number of bytes of message data that can be inserted by or in the data portion of any streams message on the sys- tem. If the tunable is set to zero, there is no limit on how many bytes can be placed in the data segment of the message. returns if the buffer being sent is larger than the current value of segments the data into multiple messages. Who Is Expected to Change This Tunable? Any customer. Restrictions on Changing Changes to this tunable take effect at next reboot. When Should the Value of This Tunable Be Raised? The tunable should be increased by any customer if the customer's STREAMS module/driver(s) require a longer message size in the data por- tion than the current value. What Are the Side Effects of Raising the Value of This Tunable? The kernel will use more memory. During low memory situations, it may bring down system performance due to frequent swapping. When Should the Value of This Tunable Be Lowered? The tunable could be lowered by any customer if the customer's STREAMS module/driver(s) do not require a longer message size in the data portion than the current value. What Are the Side Effects of Lowering the Value of This Tunable? Possible improper functioning in any of the STREAMS module/driver(s). Possible performance degradation, particularly in networking. What Other Tunable Should Be Changed at the Same Time as This One? None. WARNINGS
All HP-UX kernel tunable parameters are release specific. This parameter may be removed or have its meaning changed in future releases of HP-UX. Installation of optional kernel software, from HP or other vendors, may cause changes to tunable parameter values. After installation, some tunable parameters may no longer be at the default or recommended values. For information about the effects of installation on tun- able values, consult the documentation for the kernel software being installed. For information about optional kernel software that was factory installed on your system, see at AUTHOR
was developed by HP. Tunable Kernel Parameters STRMSGSZ(5)
All times are GMT -4. The time now is 08:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy