Hi all,
is it possible to create a 'dynamic' case statement.
ie
select option in `ls`
do
case satement depending on results of the above `ls`
done
I hope I have explained this ok!
Thanks
Helen (1 Reply)
Can anyone please tell me why this wont work! Thanks so much!
#!/bin/sh
for file
do
case $file in
*.*.*)
echo Cannot have more than 1 dot
exit
;;
*'**'*)
echo Cannot have more than 1 asterisk
exit
;;
*'*'*|?.)
echo this is a target (19 Replies)
hi all
i'm writing a script and in it i need to prompt the user if the entered value is correct or not ,i wrote the following and its not working ,its executing the script even if i enter Y/N
pls any help is appreciated
echo "\nAre you sure you entered the right Destination Environment? y :... (5 Replies)
I want to write a program with the following variables:
a=7000
b=24000
c=613.8
The user can enter two words: Vivid or Blue for example. The challenge is that the user might not want to write the words the way they appear. The user can write V or v or vivid or Vivid or write Blue or blue, or B,... (1 Reply)
Hi,
I am writing a bash shell script. My script has a few user defined parameters. When the script runs the first thing it does is make sure that these parameters are valid. One of the parameters is called YEAR. A valid input for YEAR can be 1997-2000.
One way I have come up with to ensure... (3 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)
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 menu... (4 Replies)
Hey, guys I really need some help with a project.
"Write a shell program that examines the command line arguments, counts and collects the number of options. Basically it has to collect and count the arguments that start with a "-" and the one's that don't start with a -
I know I have to use... (2 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 PHP
db2_prepare
DB2_PREPARE(3) 1 DB2_PREPARE(3)db2_prepare - Prepares an SQL statement to be executedSYNOPSIS
resource db2_prepare (resource $connection, string $statement, [array $options])
DESCRIPTION db2_prepare(3) creates a prepared SQL statement which can include 0 or more parameter markers ( ? characters) representing parameters for
input, output, or input/output. You can pass parameters to the prepared statement using db2_bind_param(3), or for input values only, as an
array passed to db2_execute(3).
There are three main advantages to using prepared statements in your application:
o Performance: when you prepare a statement, the database server creates an optimized access plan for retrieving data with that
statement. Subsequently issuing the prepared statement with db2_execute(3) enables the statements to reuse that access plan and
avoids the overhead of dynamically creating a new access plan for every statement you issue.
o Security: when you prepare a statement, you can include parameter markers for input values. When you execute a prepared statement
with input values for placeholders, the database server checks each input value to ensure that the type matches the column defini-
tion or parameter definition.
o Advanced functionality: Parameter markers not only enable you to pass input values to prepared SQL statements, they also enable
you to retrieve OUT and INOUT parameters from stored procedures using db2_bind_param(3).
PARAMETERS
o $connection
- A valid database connection resource variable as returned from db2_connect(3) or db2_pconnect(3).
o $statement
- An SQL statement, optionally containing one or more parameter markers..
o $options
- An associative array containing statement options. You can use this parameter to request a scrollable cursor on database servers
that support this functionality. For a description of valid statement options, see db2_set_option(3).
RETURN VALUES
Returns a statement resource if the SQL statement was successfully parsed and prepared by the database server. Returns FALSE if the data-
base server returned an error. You can determine which error was returned by calling db2_stmt_error(3) or db2_stmt_errormsg(3).
EXAMPLES
Example #1
Preparing and executing an SQL statement with parameter markers
The following example prepares an INSERT statement that accepts four parameter markers, then iterates over an array of arrays con-
taining the input values to be passed to db2_execute(3).
<?php
$animals = array(
array(0, 'cat', 'Pook', 3.2),
array(1, 'dog', 'Peaches', 12.3),
array(2, 'horse', 'Smarty', 350.0),
);
$insert = 'INSERT INTO animals (id, breed, name, weight)
VALUES (?, ?, ?, ?)';
$stmt = db2_prepare($conn, $insert);
if ($stmt) {
foreach ($animals as $animal) {
$result = db2_execute($stmt, $animal);
}
}
?>
SEE ALSO db2_bind_param(3), db2_execute(3), db2_stmt_error(3), db2_stmt_errormsg(3).
PHP Documentation Group DB2_PREPARE(3)