【发布时间】:2018-01-14 16:34:11
【问题描述】:
我有以下用 SQR 编写的代码:
select
business_unit &g8_iee_business_unit
ledger g8_iee_ledger
sum_posted_total_amt &yb_g8_iee_amount_selected
ft_yb_iee_RPT_NY &g8_iee_rpt_row_ny
currency_cd &g8_iee_currency_cd
From (
with a as (
Select DISTINCT account
From ps_gl_account_tbl
Where account [$col_g8_account]
)
SELECT /*+LEADING(a g8row g8func g8ybdata) PX_JOIN_FILTER(g8ybdata) swap_join_inputs(g8row) use_hash(g8row) swap_join_inputs(g8func) use_hash(g8func) swap_join_inputs(angel) use_hash(angel)*/
g8row.ft_yb_iee_rpt_ny, g8ybdata.business_unit, g8ybdata.ledger,
sum(g8ybdata.posted_total_amt) sum_posted_total_amt,
g8ybdata.currency_cd
from ps_ft_yba_rul8_row g8row
, ps_ledger g8ybdata
, a
where ([$criteria2])
and g8ybdata.ledger in ([$verledger])
and g8ybdata.account = a.account
and (g8ybdata.currency_cd = 'USD' or g8ybdata.currency_cd = ' ' )
and g8ybdata.fiscal_year = #year
and [$account_period_select]
and g8ybdata.product = g8row.product
and ( g8row.ft_yb_iee_rpt_ny > '18' AND g8row.ft_yb_iee_rpt_ny < '22' )
group by g8row.ft_yb_iee_rpt_ny, g8ybdata.business_unit, g8ybdata.ledger, g8ybdata.currency_cd
)
order by FT_YB_IEE_RPT_NY, business_unit, ledger, currency_cd;
似乎无法读取内联视图中的[$col_g8_account],因为它给我一个错误'invalid relational operator':
(SQR 5528) 光标 6 中的 ORACLE OCIStmtExecute 错误 920: ORA-00920: 无效的关系运算符 SQL:选择business_unit,分类帐,sum_posted_total_amt,FT_YB_IEE_RPT_NY, ft_yb_rpt_col_char, CHARTFIELD2, currency_cd From ( with a as ( Select DISTINCT account From ps_gl_account_tbl where account group by g8row.FT_YB_IEE_RPT_NY,g8func.ft_yb_rpt_col_char,g8func.CHARTFIELD2, g8ybdata.business_unit、g8ybdata.ledger、g8ybdata.currency_cd)
第 682 行错误: (SQR 3716) SQL 语句错误。
(SQR 5528) 光标 7 中的 ORACLE OCIStmtExecute 错误 920: ORA-00920: 无效的关系运算符 SQL:选择 business_unit、分类帐、sum_posted_total_amt、ft_yb_iee_RPT_NY、 currency_cd From ( 带有 as ( Select DISTINCT account From ps_gl_account_tbl 其中帐户组按 g8row.ft_yb_iee_rpt_ny, g8ybdata.business_unit、g8ybdata.ledger、g8ybdata.currency_cd)
第 803 行错误: (SQR 3716) SQL 语句错误。
在程序文件中发现错误。
PeopleSoft 的 SQR:程序中止。
【问题讨论】:
-
在 BEGIN-SELECT 语句之前设置的 $col_g8_account 是什么?
-
我不懂SQL,但
where account [$col_g8_account]不应该是where account = [$col_g8_account]吗? -
@William: 可能,但是 - 还有 'where ([$criteria2])' 这表明这些变量可能不仅仅包含一个值,而是更多,例如 'id = 25和 (12, 23, 56)' 中的 sal。谁知道? Tom,如果可能,显示所有变量的值,以查看传递给此 SQL 代码的内容。使用它们的确切值并重写查询,然后再次运行它——Oracle 可能会指出你的罪魁祸首。
-
这不是 SQL 问题,而是 SQR 问题。 SQR “保护” SQL 并将其自己的变量放入其中。 SQR 变量 $col_g8_account 可以有 = xxx 或只有 xxx。 Begin-SQL 语句之前的“显示 $col_g8_account”应该会显示问题,但在 @Tom_micua 回答我们之前,我们不会知道
-
大家好,[$col_g8_account]的值来自于IF语句的结果: if account = '1000000' then [$col_g8_account] value is 'like '1000%' else [$col_g8_account ] 值为 '='1000000''
标签: sql oracle inline sqr inline-view