Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Problem with while loop and SQL Post 302116161 by credit85 on Wednesday 2nd of May 2007 06:22:07 AM
Old 05-02-2007
Quote:
Originally Posted by ranj@chn
Without the -s option, you will get display like this while connecting
and display like this while disconnecting,
With the -s option, this display gets surpressed. It is basically used in scripts to get only the sql statement output and to avoid all unwanted information.
If you can check the script that your '$DCITS_SQL' points to, you will be able to determine if that is the cause.

mine is without the -s

========================================================
SQL*Plus: Release 9.2.0.5.0 - Production on Mon Apr 30 10:10:42 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
=======================================================

sorry but i dunno whether its the sql the cause of the error because the database is returning the results but its the while loop having error...
kindly advise...thanks!

Last edited by credit85; 05-02-2007 at 10:08 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unix-Sql Loop error

Hi, I am getting the error "No matching <<", when i run the below. Is it that we can't execute SQL in a Unix loop. I am executing a SQL in a loop. Is it the EOF is written wrongly. . /opt/app/wlsconfigv61/domains/profiles/oracleV901.profile export DBUSER=ecdb01 set -A DBINSTANCE... (3 Replies)
Discussion started by: manu_byc
3 Replies

2. Shell Programming and Scripting

Help shell script to loop through files update ctl file to be sql loaded

I am currently trying to find a way to loop through files in a given directory and for each file modify a ctl file and sql load it. I have been using the sed command to change the infile, badfile parameters of the control file. I have not yet tried to sql load it. Requirement: files are ftp to... (1 Reply)
Discussion started by: dba_nh
1 Replies

3. Shell Programming and Scripting

how to call shell script from pl/sql loop

Hello, I am doing a shell script which contain a pl/sql loop to search for 3 values, i would like to call another shell script inside this sql loop each time it find the values. so how can i call shell script from pl/sql using its variables, any idea? Here is idea about the code: my... (1 Reply)
Discussion started by: rosalinda
1 Replies

4. Shell Programming and Scripting

Sql in a linux loop

Hi i want to run a query in loop(unix loop) every 2 hours and spool the result to a file. i am trying but getting error here is the script $ while true do sqlplus ank/ank<<! spool ank.lst select * from v$database; exit sleep 7200 done :D (2 Replies)
Discussion started by: ankurk
2 Replies

5. Shell Programming and Scripting

how to pass a variable to an update sql statement inside a loop

hi all, i am experiencing an error which i think an incorrect syntax for the where clause passing a variable was given. under is my code. sqlplus -s ${USERNAME}/${PASSWORD}@${SID} << END1 >> $LOGFILE whenever sqlerror exit set serveroutput on size 1000000 declare l_rc ... (0 Replies)
Discussion started by: ryukishin_17
0 Replies

6. Shell Programming and Scripting

Compiling n number of SQL files in loop

Trying to compile all SQL files using a shell script. But the below code is not working. Below Code works fine when for loop is not there(commenting line no: 1,2 and 9). 1. sq_lfile=`ls *.sql` 2. for current_sql_file in $sql_file 3. do 4. sqlplus uname/pass@Service>>SQLLOG << -ENDOFSQL... (3 Replies)
Discussion started by: Dip
3 Replies

7. 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

8. Shell Programming and Scripting

UNIX/SQL loop to spool files!!

I want to spool files from unix using a sql script that would take values from another sql query within the KSH script.. unix loop select order_date from date_tbl for each order_Date i need to call this spool script with the value sqlplus scott/tiger@order_db @/ordspool/order_date.sql... (2 Replies)
Discussion started by: vr23
2 Replies

9. Programming

SQL not working in a for loop

Need help. Any reason why the update is not working in this sql: #!/bin/ksh #setup your environment . /opt/lnpsite/nm00/scripts/setup_env nm00 for tn in `cat /home/cpac/Resync/sv_tn.list` do `sqlplus -s ${DB_USERID} << EOF SET ECHO OFF NEWP 0 SPA 0 PAGES 0 FEED OFF HEAD OFF... (5 Replies)
Discussion started by: mrn6430
5 Replies

10. UNIX for Beginners Questions & Answers

How to use for loop to execute multiple .sql files while using SQLPLUS for db connection.?

Hello , Im calling every single file inside my script like 1.sql,2.sql so on it looks so tedious. I want to replace with for loop where every file gets executed. When i use for loop im getting errorUnexpected EOF] , can anyone please help me out in this.. How i can use for loop to invoke my... (6 Replies)
Discussion started by: preethi87
6 Replies
MYSQLMETAGREP(1)						  MySQL Utilities						  MYSQLMETAGREP(1)

NAME
mysqlmetagrep - Search MySQL servers for objects matching a pattern SYNOPSIS
mysqlmetagrep [options] [pattern | server] ... DESCRIPTION
This utility searches for objects matching a given pattern on all the servers specified using instances of the --server option. It produces output that displays the matching objects. By default, the first nonoption argument is taken to be the pattern unless the --pattern option is given. If the --pattern option is given, all nonoption arguments are treated as connection specifications. Internally, the utility generates an SQL statement for searching the necessary tables in the INFORMATION_SCHEMA database on the designated servers and executes it in turn before collecting the result and printing it as a table. Use the --sql option to have the utility display the statement rather than execute it. This can be useful if you want to feed the output of the statement to another application such as the mysql monitor. The MySQL server supports two forms of patterns when matching strings: SQL Simple Patterns (used with the LIKE operator) and POSIX Regular Expressions (used with the REGEXP operator). By default, the utility uses the LIKE operator to match the name (and optionally, the body) of objects. To use the REGEXP operator instead, use the --regexp option. Note that since the REGEXP operator does substring searching, it is necessary to anchor the expression to the beginning of the string if you want to match the beginning of the string. To specify how to display output, use one of the following values with the --format option: grid (default) Display output in grid or table format like that of the mysql monitor. csv Display output in comma-separated values format. tab Display output in tab-separated format. vertical Display output in single-column format like that of the G command for the mysql monitor. SQL Simple Patterns The simple patterns defined by the SQL standard consist of a string of characters with two characters that have special meaning: % (per- cent) matches zero or more characters and _ (underscore) matches exactly one character. For example: 'mats%' Match any string that starts with 'mats'. '%kindahl%' Match any string containing the word 'kindahl'. '%_' Match any string consisting of one or more characters. POSIX Regular Expressions POSIX regular expressions are more powerful than the simple patterns defined in the SQL standard. A regular expression is a string of char- acters, optionally containing characters with special meaning: . Match any character. ^ Match the beginning of a string. $ Match the end of a string. [axy] Match a, x, or y. [a-f] Match any character in the range a to f (that is, a, b, c, d, e, or f). [^axy] Match any character except a, x, or y. a* Match a sequence of zero or more a. a+ Match a sequence of one or more a. a? Match zero or one a. ab|cd Match ab or cd. a{5} Match five instances of a. a{2,5} Match from two to five instances of a. (abc)+ Match one or more repetitions of abc. This is but a brief set of examples of regular expressions. The full syntax is described in the MySQL manual, but can often be found in regex(7). OPTIONS
mysqlmetagrep accepts the following command-line options: --help Display a help message and exit. --body, -b Search the body of stored programs (procedures, functions, triggers, and events). The default is to match only the name. --database=<pattern> Look only in databases matching this pattern. --format=<format>, -f<format> Specify the output display format. Permitted format values are grid, csv, tab, and vertical. The default is grid. --object-types=<types>, --search-objects=<types> Search only the object types named in types, which is a comma-separated list of one or more of the values procedure, function, event, trigger, table, and database. The default is to search in objects of all types. --pattern=<pattern>, -e=<pattern> The pattern to use when matching. This is required when the first nonoption argument looks like a connection specification rather than a pattern. If the --pattern option is given, the first nonoption argument is treated as a connection specifier, not as a pattern. --regexp, --basic-regexp, -G Perform pattern matches using the REGEXP operator. The default is to use LIKE for matching. This affects the --database and --pattern options. --server=<source> Connection information for a server to search in <user>[:<passwd>]@<host>[:<port>][:<socket>] format. Use this option multiple times to search multiple servers. --sql, --print-sql, -p Print rather than executing the SQL code that would be executed to find all matching objects. This can be useful to save the state- ment for later execution or to use it as input for other programs. --version Display version information and exit. NOTES
For the --format option, the permitted values are not case sensitive. In addition, values may be specified as any unambiguous prefix of a valid value. For example, --format=g specifies the grid format. An error occurs if a prefix matches more than one valid value. EXAMPLES
Find all objects with a name that matches the pattern 't_' (the letter t followed by any single character): $ mysqlmetagrep --pattern="t_" --server=mats@localhost +------------------------+--------------+--------------+-----------+ | Connection | Object Type | Object Name | Database | +------------------------+--------------+--------------+-----------+ | mats:*@localhost:3306 | TABLE | t1 | test | | mats:*@localhost:3306 | TABLE | t2 | test | | mats:*@localhost:3306 | TABLE | t3 | test | +------------------------+--------------+--------------+-----------+ To find all object that contain 't2' in the name or the body (for routines, triggers, and events): $ mysqlmetagrep -b --pattern="%t2%" --server=mats@localhost:3306 +------------------------+--------------+--------------+-----------+ | Connection | Object Type | Object Name | Database | +------------------------+--------------+--------------+-----------+ | root:*@localhost:3306 | TRIGGER | tr_foo | test | | root:*@localhost:3306 | TABLE | t2 | test | +------------------------+--------------+--------------+-----------+ In the preceding output, the trigger name does not match the pattern, but is displayed because its body does. This is the same as the previous example, but using the REGEXP operator. Note that in the pattern it is not necessary to add wildcards before or after t2: $ mysqlmetagrep -Gb --pattern="t2" --server=mats@localhost +------------------------+--------------+--------------+-----------+ | Connection | Object Type | Object Name | Database | +------------------------+--------------+--------------+-----------+ | root:*@localhost:3306 | TRIGGER | tr_foo | test | | root:*@localhost:3306 | TABLE | t2 | test | +------------------------+--------------+--------------+-----------+ COPYRIGHT
Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA AUTHOR
MySQL Utilities Team COPYRIGHT
2010, Oracle and/or its affiliates. All rights reserved. 1.0.3 May 09, 2012 MYSQLMETAGREP(1)
All times are GMT -4. The time now is 10:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy