Re: creating an Oracle variable...
| From: | Anthony Carlos | Date: | Tue, 11 Sep 2001 03:32:58 +0000 |
| Subject: | Re: creating an Oracle variable... | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-12332@lists.php.net to get a copy of this message | ||
Bona:
You're using OCIParse incorrectly. It's used to parse SQL commands. The var
statement that you quoted is a SQL*Plus command. That is, you're defining a
variable in SQL*Plus. That's why you're getting an Invalid SQL Command
error.
Use the OCIBindByName to bind a PHP variable (you're using test) to an
Oracle placeholder, which is denoted by a preceding colon.
e.g.,
$sql = "INSERT INTO emp (ename) VALUES (:ename_placeholder);";
$stmt = OCIParse($conn, $sql);
OCIBindByName($stmt,":ename_placeholder",$empno,32);
$empno = "Bona";
OCIExecute($stmt, OCI_DEFAULT);
Please let me know if this makes sense,
Anthony Carlos
> From: bona@trama.com.br
> Date: Mon, 10 Sep 2001 11:10:04 -0800
> To: php-db@lists.php.net
> Subject: [PHP-DB] creating an Oracle variable...
>
> Hi,
>
> I creat the variable "test" using the sql plus:
>
> var test varchar2(10);
>
> I´ve been trying to do it wiht PHP:
>
> ================================================
> $comando1 = "exec var test varchar2(10);";
>
> $controle = OCIParse ($connection, $comando1);
> if ($controle == false){
> echo OCIError($controle)."<BR>";
> }
>
> $result1 = OCIExecute ($controle);
> ================================================
>
> I tryed $comando1 using begin and without the exec... with and without the
> ";" on the end...
>
> but I allways have the same message: Invalid SQL Command...
>
> can anybody help me???
>
> thanks
>
> Bona
>
> __________________________
> Visite http://www.trama.com.br
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net