Perl DBI 没有准备 [英] Perl DBI no prepare

查看:61
本文介绍了Perl DBI 没有准备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Perl (DBI:ODBC) 连接到 Teradata.正在执行的 SQL 语句是替换过程语句.
Teradata ODBC 驱动程序不允许准备 REPLACE PROCEDURE 抛出异常.
因此,我尝试使用 do
而不是准备 + 执行$rownum = $con->do("replace procedure ... ");

I am using Perl (DBI:ODBC) to connect to Teradata. SQL statement being executed is replace procedure statement.
Teradata ODBC driver doesn't allow to prepare REPLACE PROCEDURE throwing exception.
So, instead of prepare + execute I've tried to use do
$rownum = $con->do("replace procedure ... ");

问题是,如果无法执行替换过程(语法错误、缺少对象),那么 ODBC 驱动程序不会生成错误.它只是返回带有错误列表的记录集.

The problem is that if replace procedure can not be executed (syntax errors, missing objects) then ODBC driver doesn't generate an error. It simply returns recordset with the list of errors.

因此,如果在替换过程中发生错误,则 $rownum 值将非零.
但是 DBI->do 不支持返回记录集.
所以,目前的情况是:

So if an error occured during replace procedure, then $rownum value will be non zero.
But DBI->do doesn't support return of recordsets.
So, current situation is:

  1. 由于驱动程序不支持的语句,我无法使用准备 + 执行
  2. 我无法使用 do,因为我无法获取错误列表(但是我可以通过非零行影响值识别此错误).

一般:如何获取无法准备的查询结果?

Generally: how to fetch results of the query that can't be prepared?

推荐答案

强制 DBD::ODBC 使用 SQLExecDirect 而不是 SQLPrepare/SQLExecute.odbc_exec_direct

Force DBD::ODBC to use SQLExecDirect instead of SQLPrepare/SQLExecute. odbc_exec_direct

这篇关于Perl DBI 没有准备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆