php Yajra OCI-8程序包通过简单的SELECT查询返回ORA-01861

yv5phkfx  于 2023-02-18  发布在  PHP
关注(0)|答案(1)|浏览(167)

我正在使用laravel 8并尝试yajra/oci 8软件包。我可以连接到数据库,但无法执行基本查询,如:

$pdo = DB::connection('oracle');
$data = $pdo->table('SD_WH_V')->first();

它总是给我:

Error Code : 1861 Error Message : ORA-01861: literal does not match format string Position : 7929 Statement : select * from (select * from "SD_WH_V") where rownum = 1 Bindings : [] (SQL: select * from (select * from "SD_WH_V") where rownum = 1)

但当我使用oci_connect & oci_parse执行此操作时,它给出了正确的结果

$s = oci_parse($conn, 'select * from (select * from "SD_WH_V") where rownum = 1');
oci_execute($s);
oci_fetch_all($s, $res)

我的oracle配置是

'oracle' => [
            'driver'         => 'oracle',
            'tns'            => '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.11X)(PORT = 15XX))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =PRXX)))',
            'host'           => env('DB_HOST_ORA', ''),
            'port'           => env('DB_PORT_ORA', '1521'),
            'database'       => env('DB_DATABASE_ORA', ''),
            'username'       => env('DB_USERNAME_ORA', ''),
            'password'       => env('DB_PASSWORD_ORA', ''),
            'charset'        => env('DB_CHARSET', 'UTF8'),
            'prefix'         => env('DB_PREFIX', ''),
            'prefix_schema'  => env('DB_SCHEMA_PREFIX', ''),
            'server_version' => env('DB_SERVER_VERSION', '11g'),
            'load_balance'   => env('DB_LOAD_BALANCE', 'yes'),
            'dynamic'        => [],
            'session'        => [] 
        ]

我的oracle数据库可能是版本10,驱动程序/包是否存在兼容性问题?

66bbxpm5

66bbxpm51#

已通过使用以下命令更改文件Oci8ServiceProvider.php上的sessionVars数组修复此问题

$sessionVars = [
                'NLS_TIME_FORMAT'         => 'HH.MI.SSXFF AM',
                'NLS_DATE_FORMAT'         => 'DD-MON-RR',
                'NLS_TIMESTAMP_FORMAT'    => 'DD-MON-RR HH.MI.SSXFF AM',
                'NLS_TIMESTAMP_TZ_FORMAT' => 'HH.MI.SSXFF AM TZR',
                'NLS_NUMERIC_CHARACTERS'  => '.,',
            ];

与Oracle数据库上的NLS配置相同
非常感谢你的帮助!

相关问题