Need your help again to get a best approach for the below scenario.
I am previously having one shell script which accepts request_id/s as the command line argument.
single req_id arg= 1111
Multiple arg= 1111,2222,3333
which gets passed to the embedded sql inside to the in operator to update the status to inactive
Pseudo code for the same : (please ignore syntax error)
The above method was working like a charm for some small set of request_ids.
As presently I am getting a huge volume of request_ids(~1200) I fear whether the command line argument will allow a string of 5000bytes.
If at all it allows the in operator will not allow > 2499 bytes of data.
I have tried inserting the record into a temp table and run a for loop in sql but can't as i am not privileged to create temp table in prod env.
Also tried to pass the file as the command line (.csv file) argument then split the file into 300 records each by pivoting using awk command and process one by one file and remove them once processed but still restricted to create temp files in prod box.
Can you please focus some idea to deal with this situation without using temporary table and split method.
Do you really (need to) supply the IDs on the command line? How do you construct the line? How about creating an sql- file with several update lines for a max number of IDs? And then executing that?
Thanks Rudic. Good idea of creating multiple updates in a single SQL
File . but the ids are not constant. Everyday I am getting request 3-4 times with different sets of ids.
I think the line length limitation has to do with parameters that are passed to the script and not what is in the script itself. You say there is a text file with arguments in a single column, so that means this?
?
If so, you could try something like this
Pass the filename a parameter to the script:
Obviously this is just a principle. Your script would need exception handling, for example to test where the filename is passed as an argument and whether it exists.
IFS=, is used for the expansion of the array so that the values are separated by comma's. If you have more lines in your script then you'll probably want to save the contents of IFS and restore it afterwards..
Last edited by Scrutinizer; 11-29-2015 at 04:41 PM..
Reason: setting reg_ids array was wrong
This User Gave Thanks to Scrutinizer For This Post:
Hi All,
Seeking for your assistance to read each line $1 and $2 of input file and used it to query.
Ex. file1.txt(number range)
9064500000 9064599999
9064600000 9064699999
9064700000 9064799999
Database name: ranges_log
a_no message
9064500001 test
9064700000 ... (7 Replies)
Hi all,
How to pass the command line argument to a sql file
Script:
#!/bin/ksh
if ] ; then
test.sql
fi
My Sql Informix DB:
echo "select * from table where col1 = 2234
and col2 = '$3'"|dbaccess ddname
But im getting `:' unexpected error (5 Replies)
Hi All,
Do we know how to read input file within awk script and send output toanother log file. All this needs to be in awk script, not in command line. I am running this awk through crontab.
Cat my.awk
#!/bin/awk -f
function test(var){
some code}
{
}
END
{
print"test code"
} (5 Replies)
I need to run sql script from shell script which takes the input from a file and contents of file will be like :
12345
34567
78657
and query will be like :
select seq_nbr from bus_event where event_nbr='12345';
select seq_nbr from bus_event where event_nbr='34567';
select seq_nbr... (1 Reply)
Here is the requirement, When I run the "run file KSH (sql)", it should substitute
'${pCW_Bgn_DT}' with 201120
and
'${pCW_End_DT}' with 201124
Input File
----------
$ cat prevwk.dat
201124 20110711
run file KSH (sql)
------------------
In this file, I want to use the variables... (1 Reply)
1) I wrote a script and gave the desired permissions using "chmod 755 scriptname". Now if i edit the script file, why do i need to set the permission again? Didn't i set the permission attribute.. or if i edit the file, does the inode number of file changes?
2) I am running my unix on a server... (1 Reply)
Dear All,
The sqlplus 'Accept' command is not waiting for user input when I include the command within a shell script.
Note: The 'Accept' command is working fine if I execute it in a SQLPLUS Prompt.
Please fins the below sample script which i tried.
SCRIPT:
--------
#!... (4 Replies)
Hi ,
I used the below script to get the sql data into csv file using unix scripting.
I m getting the output into an output file but the output file is not displayed in a separe columns .
#!/bin/ksh
export FILE_PATH=/maav/home/xyz/abc/
rm $FILE_PATH/sample.csv
sqlplus -s... (2 Replies)
I've got:
isql -U $USERID -S $SERVER -D $DATABASE -i inputfile.sql -o outputfile.txt
in inputfile I have:
go
sql#1
go
sql#2
go
sql#3
go
I also tried without "go" and with";" instead which did not work
SQL statements will work if I paste them directly into the script and use EOF
... (0 Replies)
Here's the problem...
I have a mysqldump file and I need to put single quotes around the date/time timestamp. So for example I have a line like:
INSERT INTO attachments VALUES (1,182,2004-08-06 09:24:04,'description'...
and I need it to become
INSERT INTO attachments VALUES... (10 Replies)