临时表(XXX)已存在于会话中

时间:2014-03-18 13:15:11

标签: sql database stored-procedures informix

我尝试填充临时表但是我收到以下错误:

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)

2 个答案:

答案 0 :(得分:3)

您正在尝试在select语句中再次创建表,请尝试此

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)

答案 1 :(得分:1)

使用SELECT INTO时,无需声明表格

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