Sponsored Content
Full Discussion: Help with looping
Top Forums UNIX for Dummies Questions & Answers Help with looping Post 11632 by rooh on Monday 10th of December 2001 12:24:51 AM
Old 12-10-2001
Help with looping

Hi,
Actually I have a file which consists data . for eg names.
Then I want my sql query to read this file and produce the output.
Currently I am using this
FOR EG : FILENAME is NAMES
for i in `cat NAMES`
{
sqlplus -s $CONNECTID << EOF
spool rooh
set heading off
select name,address1,address2,street,occupation,age
from emp_detail
where name='$i';
spool off
EOF
}
but what happens is that it produces the spool file but contains only the last row fetched . But I want all the rows to be fetched in this file.
Can somebody show me where I am going wrong ?
Thanks in advance.

Rooh
Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

looping

Hi I have around 100 users in sun server and have default home directory in /usr/home/<username> I want to clean their home directory time to time to make free space on root, as users generate many output files during usage of application. My idea is, generate a file with following command... (4 Replies)
Discussion started by: ishir
4 Replies

2. Shell Programming and Scripting

Looping through the directory

Hi, I have to write a KSH script to loop through the directory and transfer all the files through FTP. The source machine is the Network shared drive and the files in the directory needs to be FTPied to the UNIX server. For eg. Directory (Datasource) + Directory1 ... (6 Replies)
Discussion started by: mahalakshmi
6 Replies

3. Shell Programming and Scripting

for looping

I run into a issue when I try to do sorting of the following with ascending order, one round of for looping seems not working, anyone knows how to use shell or perl? $array = (5,0,3,2,7,9,8) (2 Replies)
Discussion started by: ccp
2 Replies

4. Shell Programming and Scripting

help on looping using if/for or while

Hello, where can I get usefull information on the use of looping with for , if and while with extensive examples. Also use of variables in scripts (1 Reply)
Discussion started by: sam4now
1 Replies

5. Shell Programming and Scripting

help with looping

vesselNames values: xxx yyy zzz vesselPlanned values: xxx zzz zzz zzz OIFS="" OIFS=$IFS IFS="\n" (2 Replies)
Discussion started by: finalight
2 Replies

6. Shell Programming and Scripting

Looping through entries

Hi everyone, I am having trouble looping through entries in a file. The file several entries that are separated by topics e.g. <Topic r:id="Top/World/Français"> </Topic> <Topic r:id="Top/World/Français/Actualité"> </Topic> <Topic r:id="Top/World/Français/Actualité/A_la_Une"> <link... (1 Reply)
Discussion started by: BlueberryPickle
1 Replies

7. Shell Programming and Scripting

Looping

Hi, Now I have written a script which sorts the records in the file and splits them according to some condition. Now, I need to modify the script so that it reads all the files one after the other and does the sorting & splitting. Pls help me in reading all the files in a directory and... (8 Replies)
Discussion started by: Sunitha_edi82
8 Replies

8. Shell Programming and Scripting

Looping

Hi evryone i need a help . i have a file xcv.the content is : accelerate i want a script which will run 1000 times in loop and changing the value to accelerate to acceler in 1st loop and in 2nd loop it will be again accelerate and so on . (6 Replies)
Discussion started by: Aditya.Gurgaon
6 Replies

9. Shell Programming and Scripting

looping while using getopts

so when i use rm file -i vv bb i can delete the first file vv but i cant seem to delete the second file bb as i tried to use shift on it, but it seems that it delete the first one and stops it without looping it to the next file. what is wrong with my coding ? #!/bin/bash function... (3 Replies)
Discussion started by: cman123
3 Replies

10. Shell Programming and Scripting

Looping

Hey guys, so I am trying to do a loop script that will go through each folder (no gui so just each domain has a folder) and grab out the databases being used on that domain. I know I would use mysql -e "show databases where not 'information_schema';" once in each directory to pull the actual... (3 Replies)
Discussion started by: dough
3 Replies
PDO.QUERY(3)								 1							      PDO.QUERY(3)

PDO
::query - Executes an SQL statement, returning a result set as a PDOStatement object SYNOPSIS
public PDOStatement PDO::query (string $statement) DESCRIPTION
PDOStatement PDO::query (string $statement, int $PDO::FETCH_COLUMN, int $colno) PDOStatement PDO::query (string $statement, int $PDO::FETCH_CLASS, string $classname, array $ctorargs) PDOStatement PDO::query (string $statement, int $PDO::FETCH_INTO, object $object) PDO.query(3) executes an SQL statement in a single function call, returning the result set (if any) returned by the statement as a PDOStatement object. For a query that you need to issue multiple times, you will realize better performance if you prepare a PDOStatement object using PDO.pre- pare(3) and issue the statement with multiple calls to PDOStatement.execute(3). If you do not fetch all of the data in a result set before issuing your next call to PDO.query(3), your call may fail. Call PDOState- ment.closeCursor(3) to release the database resources associated with the PDOStatement object before issuing your next call to PDO.query(3). Note Although this function is only documented as having a single parameter, you may pass additional arguments to this function. They will be treated as though you called PDOStatement.setFetchMode(3) on the resultant statement object. PARAMETERS
o $statement - The SQL statement to prepare and execute. Data inside the query should be properly escaped. RETURN VALUES
PDO.query(3) returns a PDOStatement object, or FALSE on failure. EXAMPLES
Example #1 Demonstrate PDO::query A nice feature of PDO.query(3) is that it enables you to iterate over the rowset returned by a successfully executed SELECT state- ment. <?php function getFruit($conn) { $sql = 'SELECT name, color, calories FROM fruit ORDER BY name'; foreach ($conn->query($sql) as $row) { print $row['name'] . " "; print $row['color'] . " "; print $row['calories'] . " "; } } ?> The above example will output: apple red 150 banana yellow 250 kiwi brown 75 lemon yellow 25 orange orange 300 pear green 150 watermelon pink 90 SEE ALSO
PDO.exec(3), PDO.prepare(3), PDOStatement.execute(3). PHP Documentation Group PDO.QUERY(3)
All times are GMT -4. The time now is 06:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy