yajra / pdo-via-oci8

PHP PDO_OCI functions via OCI8 extension
Other
88 stars 61 forks source link

After updating from 3.2.0 to 3.2.1 I get this error: oci8 statement resource #1058, #106

Closed NBA707 closed 2 years ago

NBA707 commented 2 years ago

I am calling select from my connection with a parameter:

DB::connection('oracle')->SELECT("SELECT MY_WO.LAST_TEN( ? ) FROM DUAL",[ $user_ID]);

[ {#4176 +"my_wo.last_ten( ? )": oci8 statement resource #1058, }, ]

If I update composer and set it to 3.2.0 everything works. Not sure what the change is or how to fix it.

Thank you for any ideas

yajra commented 2 years ago

Looks fine on my side. Might be on your function?

Route::get('dual', fn() => DB::connection('oracle')->select('select sysdate from dual'));

Output:

[
  {
     sysdate: "2022-05-16 19:27:56"
  }
]
NBA707 commented 2 years ago

It has to do with the parameter being passed, in 3.2.1 it must require additional information (breaking change)?

NBA707 commented 2 years ago

Confirmed, the statement you did w/out parameters works fine in 3.2.1

NBA707 commented 2 years ago

What the procedure does is return the last 10 entries for a table given a user id. Not sure what changed, but per the PHP.NET manual (https://www.php.net/manual/en/function.oci-get-implicit-resultset.php) it looks like it is just returning the fact there are rows to return instead of returning the actual rows themselves like it did in 3.2.0.

yajra commented 2 years ago

Sorry can't check further atm, would you please send a PR if you can? The recent changes was mostly php8 chores that fixes the warnings.

Here is the comparison of changes: https://github.com/yajra/pdo-via-oci8/compare/v3.2.0...v3.2.1

Most changes were added via PR https://github.com/yajra/pdo-via-oci8/pull/95, ping @danielrona if you can assists? Thanks!

danielrona commented 2 years ago

I can't reproduce this either, though I can't figure out where there would have been a breaking change as there's not much change apart from typecasting/hinting.

@NBA707 can you run the tests and see if there's any problem popping up if not could you provide a test where the problem occurs?

//EDIT If you can provide the tables / sample data I can also try to debug this locally.

NBA707 commented 2 years ago

Create Function and Table.docx

Attached is the create and replace function command, the create table command and insert sample data.

In SQL Developer I do: select LAST_TEN(59496) from dual; or select LAST_TEN(18357) from dual; and there is data

In Tinker I do (artisan tinker):

DB::connection('train')->select('select LAST_TEN(18357) from dual') => [ {#4175 +"last_ten(18357)": oci8 statement resource #1045, }, ]

DB::connection('train')->select('select LAST_TEN( ? ) from dual',[18357]) => [ {#4179 +"last_ten(:p0)": oci8 statement resource #1057, }, ]

So the function works, returns up to 10 rows in a cursor, but 3.2.1 just returns the fact there is a cursor but not the data.

In 3.2.0 you get:

DB::connection('train')->select('select LAST_TEN( ? ) from dual',[18357]) => [ {#4178 +"partid": "316", +"supid": "18357", +"pn": "39033153-1", +"description": "Electrical installation kit", +"replaces_pn": "Modification Part", +"approvalbasis": "STC SA09693AC dated November 2, 2007, DWG No: 39000004 Rev: A Date: September 4, 2007, or later FAA approved revision.", +"models": "Hawker Beechcraft (390)", }, ]

NBA707 commented 2 years ago

Granted the test data doesn't match the system data, here is what it looks like with 3.2.0 and multiple rows:

DB::connection('train')->select('select LAST_TEN(48055) from dual') => [ {#4195 +"partid": "2990", +"supid": "48055", +"pn": "170980-01, 170980-02", +"description": "Double Seat Harness", +"replaces_pn": "Boeing 170980-01, 170980-02", +"approvalbasis": "Identicality per 14 CFR § 21.303, Licensing Agreement", +"models": "Boeing (747-300 Series)", }, {#4194 +"partid": "1877", +"supid": "48055", +"pn": "171919-01, 171919-02, 171919-03, 171919-04, 171919-05, 171919-06, 171919-07, 171919-08, 171919-20, 171919-21, 171919-22, 171919-23, 171919-24, 171919-25", +"description": "Double Seat Harness Assembly", +"replaces_pn": "Boeing 171919-01, 171919-02, 171919-03, 171919-04, 171919-05, 171919-06, 171919-07, 171919-08, 171919-20, 171919-21, 171919-22 , 171919-23, 171919-24, 171919-25", +"approvalbasis": "Identicality per 14 CFR § 21.303, Licensing Agreement", +"models": "Boeing (767-300)", }, {#4193 +"partid": "329", +"supid": "48055", +"pn": "170777-30", +"description": "Module, Electrical Jack", +"replaces_pn": "McDonnell Douglas 170777-30", +"approvalbasis": "Identicality per 14 CFR § 21.303, Licensing Agreement", +"models": "McDonnell Douglas (MD-11)", }, ]

danielrona commented 2 years ago

@NBA707 with the sample Data you provided I could replicate the behavior in Toad this shows up as a cursor but @yajra already applied some magic 👍and I fixed the underlying issue.

Apologies for any inconvenience this might have caused you.

image image
NBA707 commented 2 years ago

Wow! Thank you for that.

yajra commented 2 years ago

Released on v3.2.2, thanks a lot @danielrona and @NBA707 🍻