Jump to content

chn262

New Members
  • Posts

    6
  • Joined

  • Last visited

chn262's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hello, I not able to call a function with php oci8. i got an error. ORA-03131: an invalid buffer was provided for the next piece. the error seem to be at "oci_execute" statement. anyone can help? thank you // Establish a connection to Oracle database $connection = oci_connect($database_username, $database_password, "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$database_host)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=$database_service_name)))"); if (!$connection) { $error_message = oci_error(); echo "Failed to connect to Oracle: " . $error_message['message']; exit(); } // Establish a connection to Oracle database $connection = oci_connect($database_username, $database_password, "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$database_host)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=$database_service_name)))"); if (!$connection) { $error_message = oci_error(); echo "Failed to connect to Oracle: " . $error_message['message']; exit(); } echo "Connected to Oracle database successfully<br>"; // Prepare the PL/SQL call statement $sql = "BEGIN :result := wm_mvs_mvd.get_employee_salary(:p_employee_id); END;"; $statement = oci_parse($connection, $sql); if (!$statement) { $error_message = oci_error($connection); echo "Failed to prepare SQL statement: " . $error_message['message']; exit(); } else { echo "SQL statement prepared successfully<br>"; } // Set the prefetch rows attribute for the statement oci_set_prefetch($statement, 50000); // Adjust the buffer size as needed if (!$statement) { $error_message = oci_error($connection); echo "Failed to set prefetch for SQL statement: " . $error_message['message']; exit(); } else { echo "Prefetch set successfully<br>"; } // Bind the parameters $p_employee_id = 1; // Example employee ID oci_bind_by_name($statement, ':p_employee_id', $p_employee_id, 255); oci_bind_by_name($statement, ':result', $result, 255); // Assuming the result length is 255 characters if (!$statement) { $error_message = oci_error($connection); echo "Failed to bind parameters for SQL statement: " . $error_message['message']; exit(); } else { echo "Parameters bound successfully<br>"; } // Execute the statement $result = ''; if (!oci_execute($statement,OCI_COMMIT_ON_SUCCESS)) { $error_message = oci_error($statement); echo "Failed to execute SQL statement: " . $error_message['message']; exit(); } else { echo "SQL statement executed successfully<br>"; } echo "Employee salary: $result"; // Output the result // Free statement and close connection oci_free_statement($statement); oci_close($connection);
  2. hello, this is the correct output from php.ini file based in info.php i have extension=oci8.so running ; extension=modulename ; extension=mysqli ; extension=/path/to/extension/mysqli.so ; Note : The syntax used in previous PHP versions ('extension=<ext>.so' and ; 'extension='php_<ext>.dll') is supported for legacy reasons and may be ; move to the new ('extension=<ext>) syntax. ;extension=bz2 ;extension=curl ;extension=ffi ;extension=ftp ;extension=fileinfo ;extension=gd ;extension=gettext ;extension=gmp ;extension=intl ;extension=imap ;extension=ldap ;extension=mbstring ;extension=exif ; Must be after mbstring as it depends on it ;extension=mysqli ;extension=oci8_12c ; Use with Oracle Database 12c Instant Client extension=oci8.so ; Use with Oracle Database 19 Instant Client ;extension=odbc extension=openssl ;extension=pdo_firebird ;extension=pdo_mysql ;extension=pdo_oci ;extension=pdo_odbc ;extension=pdo_pgsql ;extension=pdo_sqlite ;extension=pgsql ;extension=shmop ;extension=snmp ;extension=soap ;extension=sockets ;extension=sodium ;extension=sqlite3 ;extension=tidy ;extension=xsl ;zend_extension=opcache ;zend_extension=/usr/php/8.0/lib/extensions/no-debug-zts-20200930/xdebug.so
  3. i did a "grep "extension=" php.ini" here is what i got. can you help? thank you ; extension=modulename ; extension=mysqli ; extension=/path/to/extension/mysqli.so ; Note : The syntax used in previous PHP versions ('extension=<ext>.so' and ; 'extension='php_<ext>.dll') is supported for legacy reasons and may be ; move to the new ('extension=<ext>) syntax. ;extension=bz2 ;extension=ldap ;extension=curl ;extension=ffi ;extension=ftp ;extension=fileinfo ;extension=gd ;extension=gettext ;extension=gmp ;extension=intl ;extension=imap ;extension=mbstring ;extension=exif ; Must be after mbstring as it depends on it ;extension=mysqli ;extension=oci8_12c ; Use with Oracle Database 12c Instant Client ;extension=oci8_19 ; Use with Oracle Database 19 Instant Client ;extension=odbc ;extension=openssl ;extension=pdo_firebird ;extension=pdo_mysql ;extension=pdo_oci ;extension=pdo_odbc ;extension=pdo_pgsql ;extension=pdo_sqlite ;extension=pgsql ;extension=shmop ;extension=snmp ;extension=soap ;extension=sockets ;extension=sodium ;extension=sqlite3 ;extension=tidy ;extension=xsl ;extension=zip ;zend_extension=opcache
  4. I already have OCI8 configured. $data = find_gate($conn); returns was able to return data (array). I was able to open the PHP file in the browser (via Apache server). but got an error when run as a command line. error: PHP Fatal error: Uncaught Error: Call to undefined function oci_pconnect() in still need some help. thanks
  5. Hello, i was able to load my PHP page on the web browser but got an error when run as a command line on the server. error: PHP Fatal error: Uncaught Error: Call to undefined function oci_pconnect() in ... here is my code. // Oracle database connection string $db_str = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = $db_host)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = $db_service_name) ) )"; // Attempt to connect to the Oracle database $conn = oci_pconnect($db_user, $db_pass, $db_str); // Check if the connection was successful if (!$conn) { $error = oci_error(); die("Connection failed: " . $error['message']); } $data = find_gate($conn); var_dump($data); // Close the database connection oci_close($conn); thank you
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.