1
votes

Thanks for the help you can give me.

I am having a problem using OCI8 in PHP 7.2 with PL/SQL statements in Oracle 9i. I am using oracle instant client 11.2.

SQL:

BEGIN 
  DBMS_OUTPUT.put_line('¡Hola Mundo!'); 
END;

PHP:

$rs = oci_parse($conn, $SqlCode);
$RExec = @oci_execute($rs);

ERROR:

ORA-06550: line 1, column 7: PLS-00103: Encountered the symbol "" when expecting one of the following: begin case declare exit for goto if loop mod null pragma raise return select update while with << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe The symbol "" was ignored. ORA-06550: line 2, column 42: PLS-00103: Encountered the symbol "" when expecting one of the following: begin case declare end exception exit for goto if loop mod null pragma raise return select update while with


I have problems with all PL / SQL statements in Oracle 9i, but if I try a basic statement like "SELECT * FROM some_table" it works correctly.

If I execute the same PL / SQL statement in Oracle 10 and 11 Database, it works normally.


UPDATE 2020-02-04:

I have a PHP portal, which has a form to save the scripts (PL / SQL Oracle) in a MYSQL database, then in another view I select the script that I want to execute, so I get the script (PL / SQL) that I want to run in an Oracle database.

Locking up the problem, I find that if I read the PL / SQL code or script from the MYSQL database and then execute it, I get the error "ORA-06550: line 1, column 7: PLS-00103: Encountered the symbol", but if I take the code and store it in a variable directly in the PHP file, it executes it correctly.

So the problem must be some character coding issue when I insert or query the MYSQL database to get the pl/sql code that I intend to execute in Oracle database.

Thanks.

1
How are you declaring/setting $SqlCode? At a guess I'd wonder if it's a line break/carriage return issue, from the reported position of the errors.Alex Poole
@AlexPoole $SqlCode = "BEGIN DBMS_OUTPUT.put_line('¡Hola Mundo!'); END;"; Nothing more.Santiago Zuluaga
@AlexPoole I added more information to the question.Santiago Zuluaga
I can't really help with that then; I'd suggest you inspect the value retrieved from My SQL to see if any invisible/invalid characters are being added, check the character sets of both connections, maybe try storing the same PL/SQL block as a single line (no line breaks) to see if that works. Not really something we can help with though, you need to debug it on your portal to see what is being stored/received/executed. once you know what's happening someone might be able to help you avoid it, possibly via a new question.Alex Poole

1 Answers

0
votes

as per the doco at https://www.php.net/manual/en/function.oci-parse.php

you do not include a final ; it is implicit

eg their example is

$stid = oci_parse($conn, 'SELECT * FROM employees');

Try dropping the final ;