Help in executing the following db2 sql querry in unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in executing the following db2 sql querry in unix
# 1  
Old 11-29-2010
Help in executing the following db2 sql querry in unix

Hi All,
Please help me out in executing the following db2 querry in unix

Code:
db2 "select AP_RQ_ACQ_INST_ID || ',' || txn_classifier || ',' || AP_RS_RESP_CD || ',' || (count(*) AS COUNT1) || ',' || (SUM(AP_RQ_TXN_AMT) AS TOTAL_AMT) from TXN_RECORD where 
CREATE_TS > '2010-11-22 11:00:00.008645' 
and CREATE_TS < '2010-11-22 23:00:00.008645'
group by AP_RQ_ACQ_INST_ID,txn_classifier,AP_RS_RESP_CD with ur" > vin11.csv


Error:


SQL0104N An unexpected token "AS" was found following "|| ',' || (count(*)".
Expected tokens may include: "+". SQLSTATE=42601


Please let me know what needs to be done

Regards,
Duddu

Moderator's Comments:
Mod Comment edit by bakunin: Please use CODE-tags when posting code, terminal output and the like. Thank you.

Last edited by bakunin; 11-30-2010 at 06:02 AM..
# 2  
Old 12-06-2010
try this. you can put on one line if you want - I broke it into multple lines to be easier to read.

Code:
db2 "export to vin11.csv of del 
select AP_RQ_ACQ_INST_ID, txn_classifier, AP_RS_RESP_CD,count(*) AS COUNT1,SUM(AP_RQ_TXN_AMT) AS TOTAL_AMT 
from TXN_RECORD 
where CREATE_TS > '2010-11-22 11:00:00.008645' 
and CREATE_TS < '2010-11-22 23:00:00.008645'
group by AP_RQ_ACQ_INST_ID,txn_classifier,AP_RS_RESP_CD 
with ur"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to execute a sql querry from shell script?

hello forum , I am new to shell scripting. as part of my assignment i have to execute a sql querry from the shell script. please help me. example. sql queerry:db2 "select emp_id from tsble emp". i have to execute the above querry from the script. advance thanks to forum Siva ranganath (1 Reply)
Discussion started by: workforsiva
1 Replies

2. UNIX for Advanced & Expert Users

Executing SQL file in UNIX

I have few .sql file at some location say /x/y/z. I want to execute those .sql files in UNIX server so that all packages,procedures can be applied on the database of the UNIX server. (1 Reply)
Discussion started by: Dip
1 Replies

3. UNIX for Dummies Questions & Answers

how to capture no. of rows updated in update sql in unix db2

hi, i am a new user in unix..and we have unix db2. i want to capture the no. of rows updated by a update db2 sql statement and redirect into a log file. I've seen db2 -m...but not sure how the syntax should be. The update sql that I'm going to run is from a file... Can you please share... (1 Reply)
Discussion started by: j_rymbei
1 Replies

4. UNIX for Dummies Questions & Answers

executing SQL query using unix shell script

I want to perform few post-session success tasks like update a status to 'true' in one of the sql database table, update date values to current system date in one of the configuration table in sql. How do i achieve this in a post session command?syntax with example will be helpful. (3 Replies)
Discussion started by: nathanvaithi
3 Replies

5. Shell Programming and Scripting

Executing pl/sql using sqlplus on unix

Hi to all, I have a endday.sh file. And I execute this like "sh endday.sh" from command prompt. In endday.sh file it writes: sqlplus temp/temp@data @run.sql& echo $!>>pid.txt However my aim is not to put the pid into pid.txt but I need to insert the pid into an oracle table using sqlplus.... (1 Reply)
Discussion started by: maverick1234
1 Replies

6. UNIX for Advanced & Expert Users

Executing pl/sql using sqlplus on unix

Hi to all, I have a endday.sh file. And I execute this like "sh endday.sh" from command prompt. In endday.sh file it writes: sqlplus temp/temp@data @run.sql& echo $!>>pid.txt However my aim is not to put the pid into pid.txt but I need to insert the pid into an oracle table using sqlplus.... (1 Reply)
Discussion started by: maverick1234
1 Replies

7. Programming

Executing pl/sql using sqlplus on unix

Hi to all, I have a endday.sh file. And I execute this like "sh endday.sh" from command prompt. In endday.sh file it writes: sqlplus temp/temp@data @run.sql& echo $!>>pid.txt However my aim is not to put the pid into pid.txt but I need to insert the pid into an oracle table using sqlplus.... (1 Reply)
Discussion started by: maverick1234
1 Replies

8. Shell Programming and Scripting

parsing output from SQL querry

Hi all I have this output in a variable called ...yes $OUTPUT :-) original...huh these are tablespaces in an Oracle db how do I get this into another variable in two columns so I can do a check on the numbers (space left) SYSTEM 290; USERS 19; UNDOTBS1 1863; DATA 5982; SYSTEM 290; USERS... (7 Replies)
Discussion started by: ludvig
7 Replies

9. Solaris

Executing MS-SQL stored procedures from Unix/C Program?

All, We are contemplating a port of an existing software product and would like to expend as little effort as possible. Our new database would be MS-SQL, and we would write stored procedures to perform common db operations. We'd like to call these stored procedures from C or C++ code running... (3 Replies)
Discussion started by: mparks
3 Replies

10. Shell Programming and Scripting

flags to suppress column output, # of rows selected in db2 sql in UNIX

Hello, I am new to db2 SQL in unix so bear with me while I try to explain the situation. I have a text file that has the contents of the where condition that I am using for a db2 SQL in UNIX ksh. Here is the snippet. if ; then echo "Begin processing VALUEs" ... (1 Reply)
Discussion started by: jerardfjay
1 Replies
Login or Register to Ask a Question