Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to use for loop to execute multiple .sql files while using SQLPLUS for db connection.? Post 303031873 by RudiC on Thursday 7th of March 2019 03:10:52 AM
Old 03-07-2019
You seem to have two problems in your code snippet: The "unxpected EOF" error, and the non-existing for loop construct.
For the error, Scrutinizer proposed a solution.

For the other: What have you tried, and where are you stuck?

For a for loop, you need a list of items to loop across, i.e. the sql scripts you want to execute. How to generate that list?
 

10 More Discussions You Might Find Interesting

1. AIX

how can i install sqlplus and execute some sql commands

hi everybody, i am Talip, a begginner at unix based systems and i have a problem (actually, we may think myself as the problem, in this situation). i am not sure if this is the correct platform for my questions. if it is not please forgive me about this inappropriate mail. what i have: *... (2 Replies)
Discussion started by: talipk
2 Replies

2. Shell Programming and Scripting

How to execute the multiple line sql using shell script

Hi All, Please help me to write a shell script to execute the below sql query. select c.account_no,b.bill_no,a.pay_type,(b.total_due + b.recvd + b.adjusted + b.disputed + b.transferred) as amt_not_billed,d.cash_on_delivery, (select j.bill_no from billinfo_T y, bill_t j where... (1 Reply)
Discussion started by: girish.raos
1 Replies

3. UNIX for Dummies Questions & Answers

For Loop to execute a command on a series of files

Hello, I have a set of input data that I split into batches using the following command: split -l 4000000 MyInput.in Split_a Once I get the split files, I run a certain command on the split files that spews an output. So far I have been doing it without a for loop. How can I translate the... (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

4. Shell Programming and Scripting

Execute multiple SQL scripts from single SQL Plus connection

Hi! I would like to do a single connection to sqlplus and execute some querys. Actually I do for every query one connection to database i.e echo 'select STATUS from v$instance; exit' > $SQL_FILE sqlplus user/pass@sid @$SQL_FILE > $SELECT_RESULT echo 'select VERSION from v$instance;... (6 Replies)
Discussion started by: guif
6 Replies

5. Shell Programming and Scripting

SQL query in a loop with single sqlplus connection

Hi, I'm trying to build a shell script that reads a set of accounts from a file. For each account I need to perform a set of sql queries. So I have a loop with a set of sqlplus connections to retrieved my data. Is it possible to have a single sqlplus connection before entering the loop and... (4 Replies)
Discussion started by: lsantacana
4 Replies

6. UNIX and Linux Applications

how to execute multiple .sql scripts from within a shell script using sqlplus

using sqlplus I want to execute a .sql script that has dbms_output statments in rhe script. I want to write the dbms_output statements from .sql file to a log file. is this possible. thanks any help would be appreciated :wall: (1 Reply)
Discussion started by: TRS80
1 Replies

7. Shell Programming and Scripting

Create Multiple UNIX Files for Multiple SQL Rows output

Dear All, I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File. The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files. Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies

8. Shell Programming and Scripting

Need help to write a function in shell scripting to execute sql files

Hi, I am new to shell scripting and i need to write a automation script to execute sql files. I need to check the table if it is there in system tables and need to write a function to call the .sql files. For ex. I have a.sql,b.sql,c.sql files, where the sql file contains DELETE and INSERT... (1 Reply)
Discussion started by: Samah
1 Replies

9. Shell Programming and Scripting

Execute multiple files in multiple folders and also output on same folder

How to execute multiple files in multiple folders and also output to be generated in the same folder? Hello Team, I have a path like Sanity_test/*/* and it has around 100+ folders inside with files. I would like to run/execute those files and output of execution to be placed on same /... (1 Reply)
Discussion started by: pushpabuzz
1 Replies

10. Shell Programming and Scripting

How to execute 10 sql files from a folder through sqlplus in shell script?

I am new to shell scripting and i want to know how to execute the *.sql files from a folder through sqlplus in shell script and files should be execute in sequentially one by one while execution if any ORA error it has to exit from sqlplus session 1) scripts from external folder 2) logs has... (1 Reply)
Discussion started by: sreekanth Reddy
1 Replies
MYSQL_FETCH_ASSOC(3)							 1						      MYSQL_FETCH_ASSOC(3)

mysql_fetch_assoc - Fetch a result row as an associative array

SYNOPSIS
Warning This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include: omysqli_fetch_assoc(3) o PDOStatement::fetch array mysql_fetch_assoc (resource $result) DESCRIPTION
Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead. mysql_fetch_assoc(3) is equiv- alent to calling mysql_fetch_array(3) with MYSQL_ASSOC for the optional second parameter. It only returns an associative array. o $ result -The result resource that is being evaluated. This result comes from a call to mysql_query(3). Returns an associative array of strings that corresponds to the fetched row, or FALSE if there are no more rows. If two or more columns of the result have the same field names, the last column will take precedence. To access the other column(s) of the same name, you either need to access the result with numeric indices by using mysql_fetch_row(3) or add alias names. See the example at the mysql_fetch_array(3) description about aliases. Example #1 An expanded mysql_fetch_assoc(3) example <?php $conn = mysql_connect("localhost", "mysql_user", "mysql_password"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("mydbname")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $sql = "SELECT id as userid, fullname, userstatus FROM sometable WHERE userstatus = 1"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } // While a row of data exists, put that row in $row as an associative array // Note: If you're expecting just one row, no need to use a loop // Note: If you put extract($row); inside the following loop, you'll // then create $userid, $fullname, and $userstatus while ($row = mysql_fetch_assoc($result)) { echo $row["userid"]; echo $row["fullname"]; echo $row["userstatus"]; } mysql_free_result($result); ?> Note Performance An important thing to note is that using mysql_fetch_assoc(3) is not significantly slower than using mysql_fetch_row(3), while it provides a significant added value. Note Field names returned by this function are case-sensitive. Note This function sets NULL fields to the PHP NULL value. mysql_fetch_row(3), mysql_fetch_array(3), mysql_data_seek(3), mysql_query(3), mysql_error(3). PHP Documentation Group MYSQL_FETCH_ASSOC(3)
All times are GMT -4. The time now is 02:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy