I am trying to close of multiple users in an Oracle database. Each users has records in multiple tables what I need to do is use a script that call each SQL seperately passing either CLI arguments or gathered arguments from the users during run time.
## Accept variable(s) from the command line... (1 Reply)
Hi all, I have a shell script which invoke a sql script using command
db2 -tf /home/me/db_housekeep.sql -z /home/me/db_housekeep.log
however, this mentioned sql script requires several input arguments, I wonder if one can pass variables from shell script to sql script? thanks! (0 Replies)
Hello,
i am using '#!/bin/bash', i want to make a loop in pl/sql, this loop takes values from a table according to some conditions, each time the loop choose 3 different variables. What i am not able to do is that during the loop i want my shell script to read this 3 variables and run a shell... (1 Reply)
Hi Guys,
I like to pass a variable to a sql file in a unix script..
I tried a below code..
var=200903
db2 -vf test.sql 200903
test.sql is as below.
select * from db2.users where quarter = $1;
Please tell me where i go wrong..
Thanks in advance,
Magesh (2 Replies)
Hi,
I am unable to use parameter in sql script passed from unix script.
my sql script CREATE_SBI_LIST_GROUP.sql is like this -
-------------------------------
SELECT
SDS.ID "SO_ID",
SDS.SO a1,
sgp.sga__code SGA_CODE,
FROM
sga sga,sales_genl_provision sgp , comm_product_condn cpc... (2 Replies)
Hi Guys,
Can someone please help me on adding/inserting a variable date to an sql scipt? Basically I want to assign a 7 days date range. As shown below..
#!/usr/bin/perl
use strict;
use Env qw(ORACLE_HOME);
my $SQLPLUS='/opt/oracle/product/10.1.0/db_1/bin/sqlplus -S... (1 Reply)
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)
Hello,
i`m looking for some way to add to some date an partial number of months, for example to 2015y 02m 27d + 2,54m
i need to write this script in php or bash or sh or mysql or perl in normal time o unix time
i`m asking or there are any simple way to add partial number of month to some... (14 Replies)
Hi all,
$ echo $SHELL
/bin/bash
Requirement - How to pass oracle sql script as argument to unix shell script?
$ ./output.sh users.sql
Below are the shell scripts and the oracle sql file in the same folder.
Shell Script
$ cat output.sh
#!/bin/bash
.... (7 Replies)
Hi All,
I am new to shell script. I am trying to pass value from .sh file to .sql file .
But I am able to run the .sql file from .sh file with values in sql file.
But I am unable to pass the values from .sh file. can some one please help to resolve this.
here is my .sh file
s1.sh
... (4 Replies)
Discussion started by: reddy298599
4 Replies
LEARN ABOUT PHP
examples-with-pdo_4d
EXAMPLES-WITH-PDO_4D(3) 1 EXAMPLES-WITH-PDO_4D(3)Examples with PDO_4D - Examples PDO_4D
This basic example show how to connect, execute a query, read data and disconnect from a 4D SQL server.
Example #1
Basic example with PDO_4D
<?php
$dsn = '4D:host=localhost;charset=UTF-8';
$user = 'test';
$pass = 'test';
// Connection to the 4D SQL server
$db = new PDO($dsn, $user, $pass);
try {
$db->exec('CREATE TABLE test(id varCHAR(1) NOT NULL, val VARCHAR(10))');
} catch (PDOException $e) {
die("Erreur 4D : " . $e->getMessage());
}
$db->exec("INSERT INTO test VALUES('A', 'B')");
$db->exec("INSERT INTO test VALUES('C', 'D')");
$db->exec("INSERT INTO test VALUES('E', 'F')");
$stmt = $db->prepare('SELECT id, val from test');
$stmt->execute();
print_r($stmt->fetchAll());
unset($stmt);
unset($db);
?>
The above example will output:
Array
(
[0] => Array
(
[ID] => A
[0] => A
[VAL] => B
[1] => B
)
[1] => Array
(
[ID] => C
[0] => C
[VAL] => D
[1] => D
)
[2] => Array
(
[ID] => E
[0] => E
[VAL] => F
[1] => F
)
)
This example shows how to execute a query in 4D language, and how to read the result through PDO_4D.
Example #2
Accessing 4D language from pdo_4d
Set up a 4D method, called method. Make sure in the method properties that the option Available via SQL is checked. The 4D code is
the following.
C_TEXTE($0)
$0:=Version application(*);
The PHP code to use the above 4D method is :
<?php
$dsn = '4D:host=localhost;charset=UTF-8';
$user = 'test';
$pass = 'test';
// Connection to the 4D server
$db = new PDO($dsn, $user, $pass);
$stmt = $db->prepare('SELECT {FN method() AS VARCHAR } FROM _USER_SCHEMAS LIMIT 1');
$stmt->execute();
print_r($stmt->fetchAll());
unset($stmt);
unset($db);
?>
The above example will output:
(
[0] => Array
(
[<expression>] => F0011140
[0] => F0011140
)
)
Example #3
Escaping 4D table names
This examples illustrates how to escape characters in a 4D SQL query.
<?php
$dsn = '4D:host=localhost;charset=UTF-8';
$user = 'test';
$pass = 'test';
// Connection to 4D server 4D
$db = new PDO($dsn, $user, $pass);
$objects = array('[',']','[]','][','[[',']]','[[[',']]]','TBL ]]32[23');
foreach($objects as $id => $object) {
$object = str_replace(']',']]', $object);
print "$object
";
$db->exec('CREATE TABLE IF NOT EXISTS ['.$object.'](['.$object.'] FLOAT)');
$req = "INSERT INTO [$object] ([$object]) VALUES ($id);";
$db->query($req);
$q = $db->prepare("SELECT [$object] FROM [$object]");
$q->execute();
$x[] = $q->fetch(PDO::FETCH_NUM);
$db->exec('DROP TABLE ['.$object.'];');
}
?>
The above example will output:
[
]]
[]]
]][
[[
]]]]
[[[
]]]]]]
TBL ]]]]32[23
PHP Documentation Group EXAMPLES-WITH-PDO_4D(3)