PERL 在数据库准备中使用 WITH 子句
PERL using WITH clause in Database prepare
我正在尝试在 perl 中使用 WITH 针对 Oracle 数据库准备一个复杂的查询,但在准备过程中一直出现错误。
DBD::Proxy::st execute failed: Server returned error: Failed to execute method CallMethod: DBD::Oracle::db prepare failed: ORA-00911: invalid character (DBD ERROR: error possibly near <*>
这是我正在准备的 sql:
my $sql = <<EOT;
;WITH GCG as (
SELECT FIRST_NAME, CONFIRMATION,EMAIL,
row_number() over (partition by EMAIL order by (1)) gemail
FROM GENERAL_VIEW
WHERE
CONFIRMATION is not null
AND TO_CHAR(INSERT_DATE, 'YYYY-MM-DD HH24:MI:SS') <= ?
AND TO_CHAR(INSERT_DATE, 'YYYY-MM-DD HH24:MI:SS') >= ?
AND EMAIL is not null
)
SELECT FIRST_NAME, CONFIRMATION,EMAIL FROM GCG WHERE gemail=1;
EOT
我在 DataGrip 中执行了查询并得到了结果。似乎我遗漏了 perl 的细微差别。
有人有什么想法可以帮助我吗?
提前致谢。
将您的声明更改为
my $sql = <<EOT;
WITH GCG as (
SELECT FIRST_NAME, CONFIRMATION,EMAIL,
row_number() over (partition by EMAIL order by (1)) gemail
FROM GENERAL_VIEW
WHERE
CONFIRMATION is not null
AND TO_CHAR(INSERT_DATE, 'YYYY-MM-DD HH24:MI:SS') <= ?
AND TO_CHAR(INSERT_DATE, 'YYYY-MM-DD HH24:MI:SS') >= ?
AND EMAIL is not null
)
SELECT FIRST_NAME, CONFIRMATION,EMAIL FROM GCG WHERE gemail=1
EOT
祝你好运。
我正在尝试在 perl 中使用 WITH 针对 Oracle 数据库准备一个复杂的查询,但在准备过程中一直出现错误。
DBD::Proxy::st execute failed: Server returned error: Failed to execute method CallMethod: DBD::Oracle::db prepare failed: ORA-00911: invalid character (DBD ERROR: error possibly near <*>
这是我正在准备的 sql:
my $sql = <<EOT;
;WITH GCG as (
SELECT FIRST_NAME, CONFIRMATION,EMAIL,
row_number() over (partition by EMAIL order by (1)) gemail
FROM GENERAL_VIEW
WHERE
CONFIRMATION is not null
AND TO_CHAR(INSERT_DATE, 'YYYY-MM-DD HH24:MI:SS') <= ?
AND TO_CHAR(INSERT_DATE, 'YYYY-MM-DD HH24:MI:SS') >= ?
AND EMAIL is not null
)
SELECT FIRST_NAME, CONFIRMATION,EMAIL FROM GCG WHERE gemail=1;
EOT
我在 DataGrip 中执行了查询并得到了结果。似乎我遗漏了 perl 的细微差别。
有人有什么想法可以帮助我吗?
提前致谢。
将您的声明更改为
my $sql = <<EOT;
WITH GCG as (
SELECT FIRST_NAME, CONFIRMATION,EMAIL,
row_number() over (partition by EMAIL order by (1)) gemail
FROM GENERAL_VIEW
WHERE
CONFIRMATION is not null
AND TO_CHAR(INSERT_DATE, 'YYYY-MM-DD HH24:MI:SS') <= ?
AND TO_CHAR(INSERT_DATE, 'YYYY-MM-DD HH24:MI:SS') >= ?
AND EMAIL is not null
)
SELECT FIRST_NAME, CONFIRMATION,EMAIL FROM GCG WHERE gemail=1
EOT
祝你好运。