06-09-2009
Rerun sql statement
Hi,
Script that I wrote only run sql query once then exit. But my requirement, I want the query can be execute a couple of time without exiting the script. How could I do it? Thanks.
10 More Discussions You Might Find Interesting
1. HP-UX
Hi all,
I need to bring the message to log file.Teradat/Hp-Ux
script:
-----
### Update Log Table
bteq <<- EOC
.run file ${SRC_DATA}/logon.txt
.run file ${SRC_DATA}/dbstagebteq.txt
.set format off
.set foldline off all
.set sidetitles off
... (1 Reply)
Discussion started by: vsubbu1000
1 Replies
2. Shell Programming and Scripting
Hi there
I have a database on a remote box and i have been using shell script to insert data into it for example, i could have a script that did this
SN=123456
n=server1
m=x4140
sql="UPDATE main SET hostname='$n',model='$m' WHERE serial='$SN';"
echo $sql |/usr/sfw/bin/mysql -h... (4 Replies)
Discussion started by: hcclnoodles
4 Replies
3. Shell Programming and Scripting
Hi,
How to execute sql statements from the .sh file ??
Means, when we run .sh file then the sql statements within it should be get executed one by one from the sqlplus
With Regards (3 Replies)
Discussion started by: milink
3 Replies
4. Shell Programming and Scripting
Hi Guys..
need some urgent help... I am stuck in something badly
I need to write a script which would read a sql statement (which might be a join/inner join/select/sub select etc. )
I need to read that sql statement ... and in the output I want all the table names and columns (doesn't... (4 Replies)
Discussion started by: freakygs
4 Replies
5. UNIX for Dummies Questions & Answers
Hello,
I have a script to get the information from database, however, it's look like the loop is not work, can someone help? :confused:
echo Input file list to check:
read filelist
for file in 'cat $filelist.txt'
do
echo "select FILENAME from FILE_TABLE where filename like '${file}'%;" >>... (9 Replies)
Discussion started by: happyv
9 Replies
6. UNIX for Dummies Questions & Answers
Hi,
I have the following basic script. However, the statement (line 5) is not work. The output data is not able to set my request format a30. Any advise? :mad:
echo " Column filename format a30"|sqlplus4
echo Input file list to check:
read filelist
for file in `cat $filelist.txt`
do... (1 Reply)
Discussion started by: happyv
1 Replies
7. Shell Programming and Scripting
Hi,
I have problem with the following code. My IF block is not executed. And I see "syntax error near unexpected token `)'" error for line "EOF" in the stats_function().
but when I comment the IF block I don't see this error.
Kindly help me with this issue.
clean_function()
{... (10 Replies)
Discussion started by: babom
10 Replies
8. Shell Programming and Scripting
The following is my script :
#!/bin/bash
echo "please give app_instance_id"
read app_instance_id
echo "id is $app_instance_id"
export app_id=app_instance_id
sqlplus -s nnviewer/lookup@//nasolora008.enterprisenet.org:1521/LOAD3 @test.sql<<EOF
SPOOL /home/tibco/MCH/Data/qa/raak/name.xls... (4 Replies)
Discussion started by: raakeshr
4 Replies
9. Shell Programming and Scripting
Can anyone please assist me?
I have attached 2 input files and one output file. I need to generate the sql update statements using the above 2 input files. if inputfile2 has 5 rows, then we should generate 5 update statements because column1 is unique. inputfile1 and inputfile2 may contain more... (10 Replies)
Discussion started by: vinus
10 Replies
10. UNIX for Beginners Questions & Answers
Hi Gurus... good day;
currently I trying to run the df -g command with awk to get to convert in SQL statement, but I have some errors;
df -g | awk '{print "This is the FileSystem: " $NF, " This is LV: "$1, "This is SIZE: "$2, "This is FREE: " $3, "This is the USED% "$4}'
This on AIX... (3 Replies)
Discussion started by: wcastibl
3 Replies
LEARN ABOUT REDHAT
prepare
PREPARE(7) SQL Commands PREPARE(7)
NAME
PREPARE - create a prepared query
SYNOPSIS
PREPARE plan_name [ (datatype [, ...] ) ] AS query
INPUTS
plan_name
An arbitrary name given to this particular prepared query. It must be unique within a single session, and is used to execute or
remove a previously prepared query.
datatype
The data-type of a parameter to the prepared query. To refer to the parameters in the prepared query itself, use $1, $2, etc.
OUTPUTS
PREPARE
The query has been prepared successfully.
DESCRIPTION
PREPARE creates a prepared query. A prepared query is a server-side object that can be used to optimize performance. When the PREPARE
statement is executed, the specified query is parsed, rewritten, and planned. When a subsequent EXECUTE statement is issued, the prepared
query need only be executed. Thus, the parsing, rewriting, and planning stages are only performed once, instead of every time the query is
executed.
Prepared queries can take parameters: values that are substituted into the query when it is executed. To specify the parameters to a pre-
pared query, include a list of data-types with the PREPARE statement. In the query itself, you can refer to the parameters by position
using $1, $2, etc. When executing the query, specify the actual values for these parameters in the EXECUTE statement -- refer to EXECUTE
[execute(7)] for more information.
Prepared queries are stored locally (in the current backend), and only exist for the duration of the current database session. When the
client exits, the prepared query is forgotten, and so it must be re-created before being used again. This also means that a single prepared
query cannot be used by multiple simultaneous database clients; however, each client can create their own prepared query to use.
Prepared queries have the largest performance advantage when a single backend is being used to execute a large number of similar queries.
The performance difference will be particularly significant if the queries are complex to plan or rewrite. For example, if the query
involves a join of many tables or requires the application of several rules. If the query is relatively simple to plan and rewrite but rel-
atively expensive to execute, the performance advantage of prepared queries will be less noticeable.
NOTES
In some situations, the query plan produced by PostgreSQL for a prepared query may be inferior to the plan produced if the query were sub-
mitted and executed normally. This is because when the query is planned (and the optimizer attempts to determine the optimal query plan),
the actual values of any parameters specified in the query are unavailable. PostgreSQL collects statistics on the distribution of data in
the table, and can use constant values in a query to make guesses about the likely result of executing the query. Since this data is
unavailable when planning prepared queries with parameters, the chosen plan may be sub-optimal.
For more information on query planning and the statistics collected by PostgreSQL for query optimization purposes, see the ANALYZE [ana-
lyze(7)] documentation.
COMPATIBILITY
SQL92
SQL92 includes a PREPARE statement, but it is only for use in embedded SQL clients. The PREPARE statement implemented by PostgreSQL also
uses a somewhat different syntax.
SQL - Language Statements 2002-11-22 PREPARE(7)