【问题标题】:Temp table (XXX) already exists in session临时表 (XXX) 已存在于会话中
【发布时间】:2014-03-18 13:15:10
【问题描述】:

我尝试填充我的临时表,但出现以下错误:

SQL Error (-958) : Temp table (temp_table11) already exists in session.

CREATE TEMP TABLE temp_table11
  ( emp_num int);


SELECT emp_num FROM hrgetd INTO  temp_table11
WHERE( emp_num = v_emp_num AND calc_year = p_calc_year)

【问题讨论】:

    标签: sql database stored-procedures informix


    【解决方案1】:

    您正尝试在您的选择语句中再次创建表,试试这个

    CREATE TEMP TABLE temp_table11
      ( emp_num int);
    
    INSERT INTO temp_table11
    SELECT emp_num FROM hrgetd
    WHERE( emp_num = v_emp_num AND calc_year = p_calc_year)
    

    【讨论】:

    • 很好,但是当我在那之后检查IF temp_table11 IS NOT NULL我得到temp_table11 not declared!!
    【解决方案2】:

    当你使用 SELECT INTO 时,你不需要声明你的表

    SELECT emp_num FROM hrgetd INTO  temp_table11
    WHERE( emp_num = v_emp_num AND calc_year = p_calc_year)
    

    【讨论】:

      猜你喜欢
      • 2021-12-21
      • 2018-10-13
      • 2012-11-13
      • 1970-01-01
      • 2013-10-13
      • 2011-05-21
      • 2013-05-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多