framework icon indicating copy to clipboard operation
framework copied to clipboard

unrecognized bind variable :p3 passed to the bind with Oracle

Open irpcpro opened this issue 1 year ago • 1 comments

Laravel Version

11

PHP Version

8.2

Database Driver & Version

Oracle

Description

Hi. i'm using the laravel 11 everything works well at MySQL but as soon as i connect the framework to the Oracle, my query for searching on some data, has problem.

there is an error while i want to get the data base on 'time_log' : oci_bind_by_name(): ORA-01036: unrecognized bind variable :p3 passed to the bind callHelp: https://docs.oracle.com/error-help/db/ora-01036/ (Connection: oracle_development, SQL: select * from (select * from "CAS_DATA" where "TIME_LOG" < 2024-10-11 06:09:15 and "TIME_LOG" >= 2024-10-10 00:00:00 and "CRAWLER_ID" = 1 order by "TIME_LOG" desc) where rownum = 1)

Steps To Reproduce

here's my code :

        $fields = $validator->validated();
        $targetDateTime = $fields['time_log'];
        $startTime = Carbon::parse($targetDateTime)->subDay()->startOfDay();
        $endTime = Carbon::parse($targetDateTime)->addDay()->endOfDay();
        $crawler_id = $fields['crawler_id'];

        // get data before and after time_log
        $queryBefore = CasData::query()
            ->where('time_log', '<', $targetDateTime)
            ->where('time_log', '>=', $startTime)
            ->where('crawler_id', $crawler_id)
            ->orderBy('time_log', 'desc')
            ->limit(1);

        $queryAfter = CasData::query()
            ->where('time_log', '>', $targetDateTime)
            ->where('time_log', '<=', $endTime)
            ->where('crawler_id', $crawler_id)
            ->orderBy('time_log', 'asc')
            ->limit(1);

        // merge two queries
        $results = $queryBefore->union($queryAfter)->get();```

irpcpro avatar Oct 18 '24 15:10 irpcpro

here's my final query :

select * from (select * from "CAS_DATA" where "TIME_LOG" < '2024-10-11 06:09:15' and "TIME_LOG" >= '2024-10-10 00:00:01' and "CRAWLER_ID" = 1 order by "TIME_LOG" desc) where rownum = 1;

and even when i want to execute this on the Oracle (forgeDB) i get this error :

select * from (select * from "CAS_DATA" where "TIME_LOG" < '2024-10-11 06:09:15' and "TIME_LOG" >= '2024-10-10 00:00:01' and "CRAWLER_ID" = 1 order by "TIME_LOG" desc) where rownum = 1 [2024-10-18 19:15:28] [22008][1861] ORA-01861: literal does not match format string [2024-10-18 19:15:28] Position: 99

irpcpro avatar Oct 18 '24 15:10 irpcpro

Hi there,

Thanks for reporting the problem you are encountering, but Laravel Framework doesn't provide official support to Oracle Database, due to this reason this may be better suited for a support channel. We only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repository you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

crynobone avatar Oct 21 '24 01:10 crynobone