Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

oci_pconnect with tls problems

Ivanov SergeyMar 28 2017 — edited Apr 4 2017

Hi. I try to use persistent connection to database with tls protocol. Also i use nginx and php-fpm.

First 6 connections to db are established. Next connection is broken. This means that i have php warning: oci_parse(): supplied resource is not a valid oci8 connection resource.

For tests I use simple code:

ini_set('error_reporting', E_ALL);

ini_set('display_errors', 1);

function errorsHandler($errno , $errstr) {

    echo "Errno: " . $errno . "\n";

    echo "Errstr: " . $errstr . "\n";

    die();

}

set_error_handler('errorsHandler');

$conn = oci_pconnect('/', '', 'SECUREDCONNECTION','AL32UTF8',OCI_CRED_EXT);

if (!$conn) {

  die("Connection problems: " . oci_error());

}

$stid = oci_parse($conn, 'select * from p2p_accounts where account_number = :account_number');

$value = '4080************2622';

oci_bind_by_name($stid, ':account_number', $value, -1, SQLT_CHR);

oci_execute($stid);

echo "<table border='1'>\n";

while ($row = oci_fetch_assoc($stid)) {

  echo "<tr>\n";

  foreach ($row as $k => $v) {

    echo "    <td>" . $k . ' = ' . $v . "</td>\n";

  }

  echo "</tr>\n";

}

echo "</table>\n";

oci_free_statement($stid);

Also if I use oci_connect() function, all works fine. Also if I use oci_pconnect() function without tls protocol all works fine.

I confused where I wrong?

PHP version: 7.0.15

Oracle Run-time Client Library Version 12.2.0.1.0

Oracle Compile-time Instant Client Version 12.2

Env variables are:

env[LD_LIBRARY_PATH] = /usr/lib/oracle/12.2/client64/lib

env[ORACLE_HOME] = /usr/lib/oracle/12.2/client64/

Comments

fac586

Please update your forum profile with a recognisable username instead of "User_25KFL", and supply the following information:
Full database version
Full APEX version
APEX theme and theme style used in the application

fac586

This will work if the number of columns is consistent within the dataset.

<<dynamic_table>>
declare

  type table_record is record (n_lin number, n_col number, val varchar(4000));
  type table_chunk is table of table_record;

  i pls_integer;
  n pls_integer := 0;

  /*
    This form of test data generation requires Oracle 18+
  */
  l_columns_data dynamic_table.table_chunk := dynamic_table.table_chunk(
                                                  dynamic_table.table_record(1, 0, 'DATA')
                                                , dynamic_table.table_record(1, 1, 'UGW')
                                                , dynamic_table.table_record(1, 2, '500')
                                                , dynamic_table.table_record(2, 0, 'DATA')
                                                , dynamic_table.table_record(2, 1, 'Teste')
                                                , dynamic_table.table_record(2, 2, '100')
                                              );

begin

  i := l_columns_data.first;

  if i is not null
  then
    htp.p('<table>');
    htp.p('<tbody>');

    while i is not null
    loop
      if l_columns_data(i).n_lin != n
      then
        htp.p('<tr>');
        n := l_columns_data(i).n_lin;
      end if;

      htp.p('<td>' || l_columns_data(i).val);

      i := l_columns_data.next(i);

    end loop;

    htp.p('</tbody>');
    htp.p('</table>');

  end if;

end;
Content-type: text/html
Content-length: 96

<table>
<tbody>
<tr>
<td>DATA
<td>UGW
<td>500
<tr>
<td>DATA
<td>Teste
<td>100
</tbody>
</table>

If the data contains rows with different numbers of columns then things will get more complicated.

Gonçalo
Answer

Thank you in advance.
Yes the problem is because i never know how many columns i will have so i save in the collection the line, the column and the value, but to construct the body dinamically i's getting hard.

Because when i loop the collection the first row is :

dynamic_table.table_record(1, 0, 'DATA')

and i can save them into a variable to get to the next row if necessary, but this won t work cause i never know exactly the number of columns.
Thanks.

Marked as Answer by Gonçalo · Feb 7 2021
fac586

Yes the problem is because i never know how many columns i will have so i save in the collection the line, the column and the value, but to construct the body dinamically i's getting hard.
Because when i loop the collection the first row is :

dynamic_table.table_record(1, 0, 'DATA')

and i can save them into a variable to get to the next row if necessary, but this won t work cause i never know exactly the number of columns.
This provides no additional information.
Please respond the questions asked above.
What is your:
Full database version
Full APEX version
APEX theme and theme style used in the application
Does the code posted above produce the expected output for the test data provided?
Can an individual dataset contain rows with different numbers of columns or data positions? For example:

dynamic_table.table_chunk(
    dynamic_table.table_record(1, 0, 'DATA')
  , dynamic_table.table_record(1, 1, 'UGW')
  , dynamic_table.table_record(2, 1, 'DEF')
  , dynamic_table.table_record(3, 0, 'Teste')
  , dynamic_table.table_record(3, 1, 'XYZ')
  , dynamic_table.table_record(3, 2, '586')
)
Gonçalo

Sorry, afterall its working.
Thank you so much.
Cheers

1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 2 2017
Added on Mar 28 2017
11 comments
3,385 views