I have some coding challenges that I'm hoping you can help me out.
I have one file#1 that contains the following sql statement that spans over multiple lines:
First step - Cleanup the file to remove blank lines, comments (#) and convert sql statement to span over 1 line only
tmp_file#1 now contains: Challenge#1:
The condition "and b.address is not null" should not be commented out.
I'm thinking the comment part "-- and a.id is not null" should become "/* and a.id is not null */ in order to comment that condition only
How can I easily handle this?
Note: Comments can appear anywhere in the sql statement
Next, I have a second file#2 as follows which I need to replace $$SQL with the sql statement above:
Challenge#2:
The "/" and "*" in the sql statment is not producing the desired results by the sed command
I get an error such as "sed function cannot be parsed".
Thank you for any help or insight that you can provide
Everything else seems to be working, but this isn't. Is it the "cat..." that is wrong of the condition? Thanks.
cat tc_result.txt | while read LINE
do
if
then
let "files_run += 1";
echo "inside the if loop"
# save current filetype
case $LINE... (5 Replies)
Hello All,
I was just wondering if there is any direct way to access PL/SQL OUT variables from Korn Shell Script.
I could already figure out how to return a single value back from PL/SQL to Shell Script (using bind variable).
But, what if we want to return multiple values?
One option I... (4 Replies)
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)
There are 4 parameters that I have to pass from korn shell to sql script.
1) I have to check if $1 , $2 , $3 and $4 are null values or not .
How can I do that ?
2) Once its determined that these values are null (in the sense they are empty) how can I pass null values to sql script... (11 Replies)
this is my issue.
4 parameters are passed from korn shell to sql script.
parameter_1= varchar2 datatype or no value entered my user.
parameter_2= number datatype or no value entered my user.
parameter_3= number datatype or no value entered my user.
parameter_4= number datatype or no... (5 Replies)
Hi All ,
I am trying to pass a value from sqlplus to korn shell .
There is a table tab1 in Oracle that has a column userdate.
I need to pass the userdate to the korn shell . This is what I am doing .
VALUE=`sqlplus -silent username/password << END
set pagesize 0 feedback off verify off... (14 Replies)
I'm in the process of writng a function that consists of a case statement is there a way of calling the function and passing a value to it?
ie
function1 () {
case
opt1 do .....
opt2 do.....
esac
}
function opt1
I'm aware the syntax is not correct, but you get the general idea. (1 Reply)
I am fairly new to writing scripts, and have gotten a lot of help from this site in the past with many of the posts.
I have a question/issue with a script I am attempting to write and have a question regarding executing an sql statement inside of a loop (do while). I have in the past written... (1 Reply)
Table TAB1 contains following example data (its a tree sitting in table data format & its driven based CHILD & PARENT column pick the RULE condition to generate the below SQL:
CHILD PARENT SS MID MNM VNM RULE FLG
1 ? S1 ? ? V1 rule004 I
2 1 S1 ? ? V1 0 Z
3 1 S1 ? ? V1 1 Z ... (6 Replies)
#!/bin/sh
sqlplus -s "/ as sysdba" << EOF
SET HEADING OFF
SET FEEDBACK OFF
Select
pt.user_concurrent_program_name , OUTFILE_NAME
FROm
apps.fnd_concurrent_programs_tl pt,
apps.fnd_concurrent_requests f
where
pt.concurrent_program_id = f.concurrent_program_id
and pt.application_id =... (1 Reply)
Discussion started by: usman_oracle
1 Replies
LEARN ABOUT PHP
pdo.prepare
PDO.PREPARE(3) 1 PDO.PREPARE(3)PDO ::prepare - Prepares a statement for execution and returns a statement object
SYNOPSIS
public PDOStatement PDO::prepare (string $statement, [array $driver_options = array()])
DESCRIPTION
Prepares an SQL statement to be executed by the PDOStatement.execute(3) method. The SQL statement can contain zero or more named (:name)
or question mark (?) parameter markers for which real values will be substituted when the statement is executed. You cannot use both named
and question mark parameter markers within the same SQL statement; pick one or the other parameter style. Use these parameters to bind any
user-input, do not include the user-input directly in the query.
You must include a unique parameter marker for each value you wish to pass in to the statement when you call PDOStatement.execute(3). You
cannot use a named parameter marker of the same name more than once in a prepared statement, unless emulation mode is on.
Note
Parameter markers can represent a complete data literal only. Neither part of literal, nor keyword, nor identifier, nor whatever
arbitrary query part can be bound using parameters. For example, you cannot bind multiple values to a single parameter in the IN()
clause of an SQL statement.
Calling PDO.prepare(3) and PDOStatement.execute(3) for statements that will be issued multiple times with different parameter values opti-
mizes the performance of your application by allowing the driver to negotiate client and/or server side caching of the query plan and meta
information, and helps to prevent SQL injection attacks by eliminating the need to manually quote the parameters.
PDO will emulate prepared statements/bound parameters for drivers that do not natively support them, and can also rewrite named or ques-
tion mark style parameter markers to something more appropriate, if the driver supports one style but not the other.
PARAMETERS
o $statement
- This must be a valid SQL statement for the target database server.
o $driver_options
- This array holds one or more key=>value pairs to set attribute values for the PDOStatement object that this method returns. You
would most commonly use this to set the PDO::ATTR_CURSOR value to PDO::CURSOR_SCROLL to request a scrollable cursor. Some drivers
have driver specific options that may be set at prepare-time.
RETURN VALUES
If the database server successfully prepares the statement, PDO.prepare(3) returns a PDOStatement object. If the database server cannot
successfully prepare the statement, PDO.prepare(3) returns FALSE or emits PDOException (depending on error handling).
Note
Emulated prepared statements does not communicate with the database server so PDO.prepare(3) does not check the statement.
EXAMPLES
Example #1
Prepare an SQL statement with named parameters
<?php
/* Execute a prepared statement by passing an array of values */
$sql = 'SELECT name, colour, calories
FROM fruit
WHERE calories < :calories AND colour = :colour';
$sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$sth->execute(array(':calories' => 150, ':colour' => 'red'));
$red = $sth->fetchAll();
$sth->execute(array(':calories' => 175, ':colour' => 'yellow'));
$yellow = $sth->fetchAll();
?>
Example #2
Prepare an SQL statement with question mark parameters
<?php
/* Execute a prepared statement by passing an array of values */
$sth = $dbh->prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < ? AND colour = ?');
$sth->execute(array(150, 'red'));
$red = $sth->fetchAll();
$sth->execute(array(175, 'yellow'));
$yellow = $sth->fetchAll();
?>
SEE ALSO PDO.exec(3), PDO.query(3), PDOStatement.execute(3).
PHP Documentation Group PDO.PREPARE(3)