【问题标题】:ORA-01745: invalid host/bind variable name issue starts at &&start_year and &&end_yearORA-01745: 无效的主机/绑定变量名称问题从 &&start_year 和 &&end_year 开始
【发布时间】:2020-04-03 14:56:03
【问题描述】:
define start_year = 2017;
define end_year = 2020;

with af as (
    select 
        dd.retail_year as year
        , dd.retail_quarter_of_year as quarter
        , dd.retail_month_of_year as month
        , dd.retail_week_of_year as week
        , 'BN Asset' as asset_type
        , count(bn_sku) as units
        , sum(bn_actual_cost) as cost
    from o_diamond.diamond_asset_file af 
        left join o_warehouse.date_dim dd on af.receipt_date = dd.full_date
    where 1=1
        and dd.retail_year between &&start_year and &&end_year

【问题讨论】:

  • 该查询不完整 - 它缺少 CTE 的右括号和针对 CTE 的实际查询(至少)。没有显示绑定变量,因此它可能在您省略的代码中。请编辑问题以显示整个查询和整个错误消息,包括它报告的行号/列位置。

标签: sql oracle sqlplus


【解决方案1】:

错误消息与未定义的替换变量前缀兼容。因此你应该执行

set define &

作为脚本中的第一个命令/以交互方式。前缀可以在 sqlplus 客户端的 glogin.sql 中设置为不同的字符。替代变量的使用可能已完全关闭。

This resource 可能有用(虽然有点过时,但应该可以帮助您入门)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 2015-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-01
    相关资源
    最近更新 更多