日期:2014-05-17  浏览次数:20937 次

ORA-00984列不可用
执行下面语句时,总提示ORA-00984和ORA-06512:行4
不知道具体是什么地方有问题?
begin
    for   i   in   1..9
    loop  
        execute   immediate   'insert   into   TB   values   ( '
        || '0 '||to_char(i)|| ', '
        || '0000 '||to_char(i)|| ', '
        ||to_char(i)|| ', '
        || '0 '||to_char(i)|| ', '
        ||to_char(i)|| ', '
        ||sysdate|| ', '
        ||sysdate|| ', '
        || 'userByFeng0 '||to_char(i)|| ', '
        || 'userByFeng0 '||to_char(i)|| ', '
        || 'FengId0 '||to_char(i)|| ', '
        || 'FengId0 '||to_char(i)|| ', '
        || '0 '|| ') ';
    end   loop;
    commit;
end;


------解决方案--------------------
ORA-00984 column not allowed here

Cause
A column name was used in an expression where it is not permitted, such as in the VALUES clause of an INSERT statement.
Action
Check the syntax of the statement and use column names only where appropriate.

------解决方案--------------------
|| 'userByFeng0 '||to_char(i)|| ', '
还有以上一下的句子中如果是字符串应该替换俩次
|| ' ' 'userByFeng0 '||to_char(i)|| ' ' ', '
这样才能产生出执行是的SQL是 'userByFeng0X '的效果(X从1-9)
楼主的SQL会在values里产生一个
userByFeng01,子句。相当于insert into table1(A) values(asdceasdasd);字符串的值没有引号,被系统理解为列!
当然会出现里无效的错误