Read parameter file in a shell script to unload a DB2 Table???
Hi ,
I Have following requirement:
DB2 Sql query to pass from a parameter file
for example, I would create a parameter file with (SELECT column 1, column 2 FROM Table name) then job would read it and create a file with the contents named table.txt
How to write/modify below ksh script to call the parameter file and write "query out put "to a text file ??
Environment: DB2 tables, AIX, Datastage7.5.2
Shell script: unload.sh (Table name as a parameter )
Explanation: Here table name is passed as a variable and gives the out put to .ext file but I want to pass the parameter file (in the form of sql query)
Please share your ideas here
Thank you
Moderator's Comments:
Use code tags please, see PM.
---------- Post updated 12-09-11 at 09:22 AM ---------- Previous update was 12-08-11 at 11:06 PM ----------
Hi ,
I am looking at the ksh script to execute a parameter file (which has DB2 sql query stored in it)
Please post your ideas here
Thank you
Last edited by zaxxon; 12-09-2011 at 02:17 AM..
Reason: code tags, see PM
Hi,
Parameter file is of format (.ini)consist of Properties and directories:
name=value
Query=select colA,colB FROM schema.tablename (i.e actual query to pass for the table)
I think above approach is works
I welcome more ideas to implement based on my requirement
Here we are specifying "sql query" in the script itself ..if it is a small we can accommodate here
Requirements:
We have multiple tables of same format to unload:-
so we want to modify the query often without changing the code (script)i.e without disturbing the code only just modify the sql query in a file.
Sql query=stored in a file and call that file in the script to execute the query
Read my code again, it does what you want, unless the file isn't actually as you described it.
If you just stored all the queries in a file, one by one, without the 'value=' and 'query=' stuff, you could feed that file right into db2 raw with no shell script at all.
HI Team,
I am working on reading hive table and send email in email body using shell script, can you please help on fixing the errors: I have 6 columns in my hive table and trying to send the email in the mail body.
below script:
#!/bin/bash
hive -e 'SELECT count(*) from db.table' >... (4 Replies)
Team
I have files in different directories . How can i take the count of latest file and insert into Db2 table .
I am using
awk 'END{print NR+1-ARGC}' (File name)
to get the counts.
How can i take
1.The count of latest file
2.Insert into Db2 table( File Name and Counts) .
cd... (4 Replies)
Hi,
I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below...
if (start_new_rec=="true"){
exclude_user="false";
user=toupper($6);
match(user, "XXXXX.");
if (RSTART ==2 ) {
... (9 Replies)
Hi All,
I need urgent Help from all of you here.
Below is my code-
==================================================
#!/usr/bin/sh
cd $1
cat $2 | tr -ds "$" "" > parameter_file.param
export `parameter_file.param`
chmod 777 parameter_file.param
echo $1
echo $2
cd $prmDirInput... (5 Replies)
Hi All,
I have written a shell script to compile an oracle R12 form and also a procedure is called from it. The procedure registers the form, function and creates a menu entry.
I took directory as a parameter. Code is as below:
#!/bin/ksh
echo... (3 Replies)
Can anyone please help me with an unix shell script to connect a DB2 database. My requirement is just to display the no of records present in a table of a DB2 database through Unix Shell script. Thx - Ram (1 Reply)
I need to pass a variable as a parameter from shell script into a DB2 database.
var=bhuk_1123_Q_11/22/09
select * from tbl1 where serial_id='$var';
I have tried executing it using
db2 -tvf scriptname
Somebody please help me out with this. It is throwing an error. Please tell me how... (2 Replies)
Hi....can you guys help me out in this script??
Below is a portion text file and it contains these:
GEF001 000093625 MKL002510 000001 000000 000000 000000 000000 000000 000001
GEF001 000093625 MKL003604 000001 000000 000000 000000 000000 000000 000001
GEF001 000093625 MKL005675 000001... (1 Reply)
Hi All,
I want to connect two tables in DB2 using shell script and then compare the contents of two tables field by field. Could any one please help me in connecting database tables using Unix and retriving data from the same.
Thanks,
Durwas (0 Replies)
I have a file with userIDs, one per line no spaces. I have a script that accepts userIDs as a parameter and outputs information about them. What I have had to do in the past was to modify each line of the file with userIDs to call the script with the userID and pipe the output to a data file.
... (2 Replies)