[英]How to create and pass an array from KSH to Oracle sqlplus
I'm trying to create a KSH script in which I'm trying to create an array which will hold the contents of a text file, which contains a list of string values, and send the array to an SQL function in the KSH script. 我试图创建一个KSH脚本,在其中试图创建一个数组,该数组将保存文本文件的内容,该文本文件包含字符串值列表,并将该数组发送到KSH脚本中的SQL函数。 Here's what I've done so far: 到目前为止,这是我所做的:
export text_file=$HOME/values.log
while read **line**;
do
CmResTypUpd
done < $text_file
The ResTypUpd does the following: ResTypUpd执行以下操作:
CmResTypUpd () {
sqlplus -s $db_user/$db_pass@$db_inst <<EOF
SET VERIFY OFF
SET HEADING OFF
SET PAGESIZE 200
SET LINESIZE 200
SET FEEDBACK OFF
update My_Table set Column_Field_To_Change='NEW_VALUE' where IND1_COLUMN_VALUE='SomethingSomething' and IND2_COLUMN_VALUE='**$line**';
commit;
exit;
EOF
}
What I get is that the script hangs and does nothing. 我得到的是脚本挂起并且不执行任何操作。
Also, the script should be able to run cross-platform, meaning on any Unix
or Linux
. 而且,该脚本应该能够跨平台运行,这意味着可以在任何Unix
或Linux
。
You need to pass your line as parameter to the function 您需要将行作为参数传递给函数
export text_file=$HOME/values.log
while read line; do CmResTypUpd "$line"; done < $text_file
And your function: 而你的功能:
CmResTypUpd () {
[...]
update My_Table set Column_Field_To_Change='NEW_VALUE'
where IND1_COLUMN_VALUE='SomethingSomething' and IND2_COLUMN_VALUE='$1';
[...]
}
And also the variable **line**
should be line
并且变量**line**
应该是line
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.