Hi,
I have a script like below :
#!/bin/ksh
echo "Do you want to export all docs ?"
read alld
echo "Do you want to export template or report only "
read temr
case && ]
#arguments
;;
case && ]
#arguments
;;
case && ]
#arguments
;; (4 Replies)
hi, i will like to know whether awk command can ignore case?
i written a script that will take in user input and search for data on the 1st field from a text file.
echo -n "Title:"
read title
awk -F":" '$1~/'"$title"'/{print $0}' Filename
read ans
return
... (5 Replies)
I'm trying to run the logic below but get a `<' is not matched error message when I return a Y or y;
printf "Run this ? : "
read RESP
case $RESP in
Y|y)
cat <<EOF > file
today is Monday
EOF ;;
N|n)
exit 1 ;;
esac
Any ideas? (2 Replies)
i want to get user input like this
please tell which option to chose
1. mango 2. tango 3. rango
if user chooses mango
then it should execute a set of statements and again ask like this
what do you want to do
1.add 2.subtract 3.exit
when i choose exit it should goto my previous... (1 Reply)
Hi,
In my script it takes the input from the user. i.e. sys or system.
How can i make it case insensitive in my code.
if || ; then
echo "valid"
Any help is appreciated.
Thanks,
priya (4 Replies)
This is supposed to be a simple bank script. Whenever I try the case construct options it wont work for the deposit option after typing the amount it just goes straight back into the menu, same with withdrawal option. Option 3 which should just display the balance amount doesn't echo anything. The... (2 Replies)
Hi All,
I have script which will take the parameter as
PNLYYYYMMDD/PNL
or PNL-AMDYYYYYMMDD/PNL-AMD
now based on YYYYMMDD my script will parse and do some logic within
my case statement looks like below
case `echo $1 | tr '' ''`
in
pnl*) do some logic;;
pnl-amd*) do some logic;;... (2 Replies)
I need to Write a shell script that allows some system-administration tasks to be preformed automatically from a menu-driven interface. with automated following tasks:
Copy directory tree
Delete files or directories
Output Information (this part is done )
*Copy directory tree
The “Copy... (2 Replies)
have written the below code to check whether the string received from user is a file name or dir using case statement, but its going into default case*).
#!/bin/sh
#Get a string from user and check whether its a existing filename or not
rm str2
rm str3
echo "enter a file \c"
read fil... (8 Replies)
I'm having an issue with bash read input when using a case statement.
The script halts and doesn't read the input on the first loop. if I hit enter then the scripts starts to respond as expected. Need some help here.
defaultans=8hrs
read -e -i $defaultans -p "${bldwht}How long would you like... (5 Replies)
Discussion started by: woodson2
5 Replies
LEARN ABOUT SUSE
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)