09-18-2010
Hi,
@ Tyler_Durden: thanks for the suggestion. The command you wrote will definitely give me the count. But that is not the issue here.
First, there would be only one type of statement. Either Insert or update or delete, not all 3.
Second, I need to check the count of the impacted rows for each DML statement.
Thanks for helping me, do you have any command for this???
-----------------------------------------------------------------------------
Hi Guru,
Thanx a lot. Here I want to first check the count of all the statements present in the input file. If the count of all the statements (impacted rows) is less than 100,000 records then only I want to execute the DML statements. If the count for even a single statement is going to affect more than 100,000 records then I want that this should be caught in SELECT COUNT(*) statement which will stop processing. That is why I first want to check the count and then it will execute the DMLs.
Thanks
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
#!/usr/bin/ksh
echo Please enter
while read n
do
echo $n >> datafile
done
question:
How can I enject an if statement that if the users enter 0 (zero) the program will exit?
this is what I have but not working
#!/usr/bin/ksh
echo Please enter number
while read n
do
if $n=0
then... (2 Replies)
Discussion started by: bobo
2 Replies
2. Shell Programming and Scripting
Hi all,
How can i use the below unix command in AWK . Can any one please suggest me how i can use.
sed -e "s/which first.sh/which \$0/g" $shell > $shell.sal
where $0=current program name(say current.sh)
$shell=second.sh (1 Reply)
Discussion started by: krishna_gnv
1 Replies
3. Shell Programming and Scripting
I need to pass a DDL statement into a ksh script & parse the statement.
What is the best way to pass a DDL statement into a KSH script.
---------- Post updated at 09:28 AM ---------- Previous update was at 07:35 AM ----------
if the name of the script is test.ksh
test.ksh "ALTER TABLE... (12 Replies)
Discussion started by: gayathree
12 Replies
4. Shell Programming and Scripting
Hi,
I'm doing a small shellscript which is going to take each line in a "queue file" and do stuff to them. I can do the script easily, but I'd like this one to be a bit prettier.
Consider the following perl statement:
...
foreach my $line (@filedata) {
my ($a, $b, $c) = split(/\t/,... (4 Replies)
Discussion started by: brightstorm
4 Replies
5. Shell Programming and Scripting
Hey guys,
a=`cat abc | wc -l`
b=`cat def | wc -l`
if $a== $b
then
echo "a"
else
echo "b"
fi
I want the if condition to retry itself , untill a==b.
I can't use goto statemt.
Please help.
Thanx in advance.
Please use next time code tags for your code and data (5 Replies)
Discussion started by: jaituteja
5 Replies
6. Shell Programming and Scripting
Hi all.
This is my first post on this forum. I've previously found great help in the huge knowledgebase that is here, but this time I have not been able to find a solution to my problem.
I have a large text file that looks like this:
typedef struct ABC_struct_nbr1_ {
char attr1; /*... (0 Replies)
Discussion started by: Yagi Uda
0 Replies
7. Shell Programming and Scripting
I have the following scenario where I need to use a header record from a file and generate a DML based off of it...
E.g.: The header can change periodically with an additional column in between or remove a col....
Sample header : (head -1 sample.txt)... (17 Replies)
Discussion started by: anduzzi
17 Replies
8. Shell Programming and Scripting
Hi,
I'm a rookie who is trying to learn this stuff. What I need help with is putting together a non complicated "while" loop within the below "if" statement. I also need the while loop to keep looping until the user types a key to end the loop. Please reveal the proper insertion points. Thank... (4 Replies)
Discussion started by: jefferj54
4 Replies
9. Shell Programming and Scripting
Hi,
Can we use 3 statements convert in a single statement.
First statement output using the second statement and the second statement output using the third statement please let me know the syntax so that I can able to merge all the three statement. (2 Replies)
Discussion started by: Priti2277
2 Replies
10. Shell Programming and Scripting
Hi folks,
I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex.
I have a bunch of update statements with all columns in a file which I need to convert into insert statements.
UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies
LEARN ABOUT DEBIAN
prepare
PREPARE(7) SQL Commands PREPARE(7)
NAME
PREPARE - prepare a statement for execution
SYNOPSIS
PREPARE name [ ( datatype [, ...] ) ] AS statement
DESCRIPTION
PREPARE creates a prepared statement. A prepared statement is a server-side object that can be used to optimize performance. When the PRE-
PARE statement is executed, the specified statement is parsed, rewritten, and planned. When an EXECUTE command is subsequently issued, the
prepared statement need only be executed. Thus, the parsing, rewriting, and planning stages are only performed once, instead of every time
the statement is executed.
Prepared statements can take parameters: values that are substituted into the statement when it is executed. When creating the prepared
statement, refer to parameters by position, using $1, $2, etc. A corresponding list of parameter data types can optionally be specified.
When a parameter's data type is not specified or is declared as unknown, the type is inferred from the context in which the parameter is
used (if possible). When executing the statement, specify the actual values for these parameters in the EXECUTE statement. Refer to EXECUTE
[execute(7)] for more information about that.
Prepared statements only last for the duration of the current database session. When the session ends, the prepared statement is forgotten,
so it must be recreated before being used again. This also means that a single prepared statement cannot be used by multiple simultaneous
database clients; however, each client can create their own prepared statement to use. The prepared statement can be manually cleaned up
using the DEALLOCATE [deallocate(7)] command.
Prepared statements have the largest performance advantage when a single session is being used to execute a large number of similar state-
ments. The performance difference will be particularly significant if the statements 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 statement is relatively simple to plan and re-
write but relatively expensive to execute, the performance advantage of prepared statements will be less noticeable.
PARAMETERS
name An arbitrary name given to this particular prepared statement. It must be unique within a single session and is subsequently used to
execute or deallocate a previously prepared statement.
datatype
The data type of a parameter to the prepared statement. If the data type of a particular parameter is unspecified or is specified as
unknown, it will be inferred from the context in which the parameter is used. To refer to the parameters in the prepared statement
itself, use $1, $2, etc.
statement
Any SELECT, INSERT, UPDATE, DELETE, or VALUES statement.
NOTES
In some situations, the query plan produced for a prepared statement will be inferior to the query plan that would have been chosen if the
statement had been submitted and executed normally. This is because when the statement is planned and the planner attempts to determine the
optimal query plan, the actual values of any parameters specified in the statement are unavailable. PostgreSQL collects statistics on the
distribution of data in the table, and can use constant values in a statement to make guesses about the likely result of executing the
statement. Since this data is unavailable when planning prepared statements with parameters, the chosen plan might be suboptimal. To exam-
ine the query plan PostgreSQL has chosen for a prepared statement, use EXPLAIN [explain(7)].
For more information on query planning and the statistics collected by PostgreSQL for that purpose, see the ANALYZE [analyze(7)] documenta-
tion.
You can see all available prepared statements of a session by querying the pg_prepared_statements system view.
EXAMPLES
Create a prepared statement for an INSERT statement, and then execute it:
PREPARE fooplan (int, text, bool, numeric) AS
INSERT INTO foo VALUES($1, $2, $3, $4);
EXECUTE fooplan(1, 'Hunter Valley', 't', 200.00);
Create a prepared statement for a SELECT statement, and then execute it:
PREPARE usrrptplan (int) AS
SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid
AND l.date = $2;
EXECUTE usrrptplan(1, current_date);
Note that the data type of the second parameter is not specified, so it is inferred from the context in which $2 is used.
COMPATIBILITY
The SQL standard includes a PREPARE statement, but it is only for use in embedded SQL. This version of the PREPARE statement also uses a
somewhat different syntax.
SEE ALSO
DEALLOCATE [deallocate(7)], EXECUTE [execute(7)]
SQL - Language Statements 2010-05-14 PREPARE(7)