10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I am pretty new to bash scripting.I am trying to write the if statement in bash and it give me error. Can you please help me what I am doing wrong in If statement?
if && &&
then
fector=$kk;
divide=$DB_SIZE/$kk;
echo "factor value:$fector"
echo"divide value:$divide"... (4 Replies)
Discussion started by: Gevni
4 Replies
2. UNIX for Beginners Questions & Answers
Hi
I am pretty new to bash scripting.I am trying to write the if statement in bash and it give me error. Can you please help me what I am doing wrong in If statement?
if && &&
then
fector=$kk;
divide=$DB_SIZE/$kk;
echo "factor value:$fector"
echo"divide value:$divide"... (1 Reply)
Discussion started by: Gevni
1 Replies
3. Programming
Hi
I am pretty new to bash scripting.I am trying to write the if statement in bash and it give me error. Can you please help me what I am doing wrong in If statement?
Code:
if && &&
then
fector=$kk;
divide=$DB_SIZE/$kk;
echo "factor value:$fector"
echo"divide... (1 Reply)
Discussion started by: Gevni
1 Replies
4. Shell Programming and Scripting
echo $line | awk -F, "BEGIN {if(NF==10) && /'"${MONTH}"' '"${DAY}"' '"${TIMEH}:"'/,0 {print $10"-"$4} else {print $13"-"$4}}"
if the fields in the line is equal to 10, print the values of this specified fields "$10 and $4".
if the fields in the line is anything but 10, print the values of... (5 Replies)
Discussion started by: SkySmart
5 Replies
5. Shell Programming and Scripting
Hi ! all I am just trying to check range in my datafile
pls tell me why its resulting wrong
admin@IEEE:~/Desktop$ cat test.txt
0 28.4
5 28.4
10 28.4
15 28.5
20 28.5
25 28.6
30 28.6
35 28.7
40 28.7
45 28.7
50 28.8
55 28.8
60 28.8
65 28.1... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies
6. Shell Programming and Scripting
hi guys,
here's the code
$ cat getsums.sh
#!/usr/bin/sh
FILENAME=$1
DELIMITER=$2
FIRST_COL=$3
SECOND_COL=$4
SALESDATE_COL=$5
STOREID=$6
UPC=$7
GTIN=$8
PROMOID=$9
echo ""
echo ".:Summation Tool:."
for FILE in ${FILENAME}
do (7 Replies)
Discussion started by: ramneim
7 Replies
7. Shell Programming and Scripting
I had this working a few days ago but I since changed it. Heres the code
x=1
while 1 2 3 4 5 6
1=$(ps -ef | grep process | awk '{ print $2}')
if
then
echo "The database is accepting connections..."
echo "Now I will check the next process"
2=$(ps -ef | grep process1 |... (10 Replies)
Discussion started by: jeffs42885
10 Replies
8. Shell Programming and Scripting
I started writing a script to save the files from a camera I got the other day, which mounts in /Volumes , and I got into it and started building this menu. The only problem is that the switch case is coming up as a syntax error at the parenthesis after a case. Here is the code:
while :
do
... (2 Replies)
Discussion started by: snakemasterAK
2 Replies
9. Shell Programming and Scripting
cmd="find /a/technologies -name '*.jar' | grep \"Tuning/specificloader/lib\""
echo $cmd
for index in `$cmd`
do
SL_JARS="${SL_JARS}:${index}"
done
gives error ==>
find: paths must precede expression
Usage: find
but
for index in... (2 Replies)
Discussion started by: crackthehit007
2 Replies
10. UNIX for Dummies Questions & Answers
The script below is supposed to list file and folder names and list the type besides each - It has no practical value - I am just trying to learn KSH (so far sounds like a bad idea!)
Expected output should look like this:
folder 1 *** dir ***
file1 * file *
The code runs but produces... (9 Replies)
Discussion started by: GMMike
9 Replies
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)