【问题标题】:getting Error: ORA-00905: missing keyword error when trying to insert rows in temp table from subquery出现错误:ORA-00905:尝试从子查询在临时表中插入行时缺少关键字错误
【发布时间】:2016-07-27 17:56:21
【问题描述】:
select customernumber into total 
from (select customernumber 
      from ccsowner.customer 
      where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS))

通过创建的临时表。

Create Table Total
(
    customernumber   Int
)

【问题讨论】:

    标签: sql oracle


    【解决方案1】:

    Select Into 仅在表不存在时有效。您可以使用以下 SQL 将数据插入到现有表中。

    试试这个 -

    Insert into Total 
     select customernumber 
        from ccsowner.customer 
        where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS)
    

    如果你想使用 SELECT INTO,你可以使用下面的 SQL(它会即时创建 Total 表,如果 Total 表已经存在则会报错):

    ;with cte_Cust As (
        Select customernumber 
          from ccsowner.customer 
          where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS))
    
    
    Select customernumber Into Total
       From cte_Cust
    

    【讨论】:

    • 尝试了第一个,但它给出了无效的数字错误。
    • SQL 错误:ORA-01722:无效号码 01722.00000 -“无效号码”
    • 检查 CustomerNumber 列的数据类型。似乎它是数据类型 varchar。更多解释请参考stackoverflow.com/questions/12549029/…
    猜你喜欢
    • 2021-05-26
    • 2013-01-02
    • 2019-01-18
    • 2016-03-12
    • 1970-01-01
    • 1970-01-01
    • 2010-09-23
    • 2023-03-22
    相关资源
    最近更新 更多