Sponsored Content
Top Forums Shell Programming and Scripting Store output of DB Cursor to a txt file Post 302565236 by durden_tyler on Monday 17th of October 2011 10:44:40 AM
Old 10-17-2011
Quote:
Originally Posted by naveensraj
...I am able to store the results of simple select queries to the txt file. but I am not sure how to store the values when using a cursor. I have given the sql query below. I will be executing this in a db2 database. ...
Code:
FOR CRTID AS CUR1 CURSOR FOR
 SELECT CTRCTID FROM LM_ACCT_RTRVL_RQST WHERE STATUS = 'R'
DO
SELECT A.CTRCTBALAMT,                        
       A.CTRCTEFFDATE,      
       A.CUSTSTCD,  
       B.POST_DT,                       
       B.AMOUNT,                              
       B.EFF_DT,                         
       B.EXPIR_DT,
       B.TXN_TYPE_CD
  FROM  CBSAR. SCLM9973 A, CBSAR. SCLM9967 B                    
WHERE A.CTRCTID      =  CRTID.CTRCTID  AND A.CTRCTID        =   B.CTRCT_ID
END FOR;

Maybe you could convert the query into a simple select and save it the way you do?

Code:
SELECT A.CTRCTBALAMT,
       A.CTRCTEFFDATE,
       A.CUSTSTCD,
       B.POST_DT,
       B.AMOUNT,
       B.EFF_DT,
       B.EXPIR_DT,
       B.TXN_TYPE_CD
 FROM  CBSAR.SCLM9973 A,
       CBSAR.SCLM9967 B
       (SELECT CTRCTID
          FROM LM_ACCT_RTRVL_RQST
         WHERE STATUS = 'R'
       ) CRTID
 WHERE A.CTRCTID = CRTID.CTRCTID
   AND A.CTRCTID = B.CTRCT_ID;

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

store output to a file and read from it

Hello all, I need to run snoop command for a period of time (a day) and extract remote host column from it to find out who is accessing my server. When I run the following on the command line it works snoop -port 22 | awk '{print $3}' but when I do snoop -port 22 | awk '{print $3}' | while... (2 Replies)
Discussion started by: afadaghi
2 Replies

2. Shell Programming and Scripting

How to store the sql query output into txt file?

Hi I want ot save SQL query result in one txt file. for that i have written one code line sqlplus -s $dbstring @/usr/local/bin/sched/nightly_Cronjob/exec_123.sql >> /usr/local/bin/sched/nightly_Cronjob/result.txt but it is not working . database : Oracle so please advice me how can i... (7 Replies)
Discussion started by: Himanshu_soni
7 Replies

3. Shell Programming and Scripting

Store grep output file

Hi, I'm trying to store the output from a grep, I just want the file name. But couldn't find how to do it. Basically, I just want to grep <etc> * and I want to store the file name. There is only one file with the what I'm grepping, so storing in a variable o an array its the same. If someone... (3 Replies)
Discussion started by: radicaled
3 Replies

4. Homework & Coursework Questions

man command output to a txt file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to outut the man command output into a text file which will help me for future reference. 2.... (8 Replies)
Discussion started by: hariniiyer300
8 Replies

5. UNIX for Dummies Questions & Answers

Writing a script that will take the first line from each file and store it in an output file

Hi, I have 1000 files names data1.txt through data1000.txt inside a folder. I want to write a script that will take each first line from the files and write them as output into a new file. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

6. UNIX for Advanced & Expert Users

Help on Shell Scripting - to store output to a fixed file

Hi I have a file called "test.txt" and it looks like this x y z x/c y/c/b now, i want to run a command and its output will be like this x 10 y/c/b 20 z 78 -------- my requirement is, i want to add the command output to "test.txt" as like below x 10 y ... (1 Reply)
Discussion started by: siva kumar
1 Replies

7. Shell Programming and Scripting

Need to convert output.txt into html file

I have output.txt file generated through shell scripts which need convert in tabular format using html can you please help me output.txt Token State Date1 Date2 Description Name 34567 open 27/06/13 28/06/13 ... (5 Replies)
Discussion started by: vijay_rajni
5 Replies

8. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

9. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

10. Shell Programming and Scripting

How to store info from a txt file into a hash?

I'm trying to make a perl script using the "open" command to open and read a file, storing the information in said file into a hash structure. This is what is inside my file- Celena Standard F 01/24/94 Cancer Jeniffer Orlowski F 06/24/86 None Brent Koehler M 12/05/97 HIV Mao Schleich... (4 Replies)
Discussion started by: Eric1
4 Replies
MYSQLI_MULTI_QUERY(3)							 1						     MYSQLI_MULTI_QUERY(3)

mysqli::multi_query - Performs a query on the database

       Object oriented style

SYNOPSIS
bool mysqli::multi_query (string $query) DESCRIPTION
Procedural style bool mysqli_multi_query (mysqli $link, string $query) Executes one or multiple queries which are concatenated by a semicolon. To retrieve the resultset from the first query you can use mysqli_use_result(3) or mysqli_store_result(3). All subsequent query results can be processed using mysqli_more_results(3) and mysqli_next_result(3). PARAMETERS
o $ link -Procedural style only: A link identifier returned by mysqli_connect(3) or mysqli_init(3) o $query - The query, as a string. Data inside the query should be properly escaped. RETURN VALUES
Returns FALSE if the first statement failed. To retrieve subsequent errors from other statements you have to call mysqli_next_result(3) first. EXAMPLES
Example #1 mysqli::multi_query example Object oriented style <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $query = "SELECT CURRENT_USER();"; $query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5"; /* execute multi query */ if ($mysqli->multi_query($query)) { do { /* store first result set */ if ($result = $mysqli->store_result()) { while ($row = $result->fetch_row()) { printf("%s ", $row[0]); } $result->free(); } /* print divider */ if ($mysqli->more_results()) { printf("----------------- "); } } while ($mysqli->next_result()); } /* close connection */ $mysqli->close(); ?> Procedural style <?php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $query = "SELECT CURRENT_USER();"; $query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5"; /* execute multi query */ if (mysqli_multi_query($link, $query)) { do { /* store first result set */ if ($result = mysqli_store_result($link)) { while ($row = mysqli_fetch_row($result)) { printf("%s ", $row[0]); } mysqli_free_result($result); } /* print divider */ if (mysqli_more_results($link)) { printf("----------------- "); } } while (mysqli_next_result($link)); } /* close connection */ mysqli_close($link); ?> The above examples will output something similar to: my_user@localhost ----------------- Amersfoort Maastricht Dordrecht Leiden Haarlemmermeer SEE ALSO
mysqli_query(3), mysqli_use_result(3), mysqli_store_result(3), mysqli_next_result(3), mysqli_more_results(3). PHP Documentation Group MYSQLI_MULTI_QUERY(3)
All times are GMT -4. The time now is 12:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy