jsp页面中的代码
cs=conn.prepareCall("{call held('"+session.getAttribute("roll")+"')}");
cs.executeUpdate();
在oracle数据库中的过程如下
create or replace procedure "Held"
(s in Varchar2)
l_col_name varchar2(30);
begin
SELECT SUBJECTCODE
into l_col_name
FROM table02
WHERE SERIALNUMBER = '1';
execute immediate
'UPDATE TABLE01 SET '|| l_col_name || ' = '
|| l_col_name || ' + 1 WHERE Rollno = s'
;
end;
错误如下
java.sql.SQLException: ORA-00904: "S": invalid identifier ORA-06512: at "ROHIT.HELD", line 12 ORA-06512: at line 1
请更正
我试图从jsp中的代码中获取session ie的值并尝试在oracle数据库中使用它...... 我使用 s 作为变量来存储该值并在 where 子句中使用它
提出解决方案
最佳答案
我不知道jsp端是否正确,但你的程序中显然有一个错误。
When ORA-00904 occurs, you must enter a valid column name as it is either missing or the one entered is invalid.
在这里,您的语句 WHERE Rollno = s
被理解为“其中列 rollno 等于列 s”,但列 s 不存在。我想您只需将 s
从字符串中移出即可。
execute immediate
'UPDATE TABLE01 SET '|| l_col_name || ' = '
|| l_col_name || ' + 1 WHERE Rollno = ''' || s || ''''
;
关于java - 向oracle数据库中的过程传递参数的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31649639/