SQL> select * from aa; NUM STR
---------- ----------
0 1SQL> declare
2 str varchar2(10);
3 begin
4 select num into str from aa where num=1;
5 exception
6 when others then
7 dbms_output.put_line(sqlcode);
8 end;
9 /
100PL/SQL procedure successfully completed
---------- ----------
0 1SQL> declare
2 str varchar2(10);
3 begin
4 select num into str from aa where num=1;
5 exception
6 when others then
7 dbms_output.put_line(sqlcode);
8 end;
9 /
100PL/SQL procedure successfully completed
解决方案 »
- 关联两个表做Updage 操作。。。。。。。。[初级]
- EXP-00056:ORACLE错误1033出现
- 下面的存储过程那里错了?
- !!!怎么获得系统日期的年份,再将它减去表示日期的字段,得到年龄?!!!
- 请教数据库导入导出命令行中文件目录的指定
- Oracle的存储过程不能返回记录集??
- 如何面試一個oracle編程員,問些什麼,我對這個什麼都不懂,請幫忙,在線等!
- 寻:PB8连接Oracle的配置方法 !
- 请问在PL/SQL存储过程中,我定义了一个数组但不知怎么访问这个数组,用操作符[]竟然说语法错误,谁能解决。
- oracle语言翻译
- 一个触发器的问题!
- 帮忙看看我该下载哪个jdk啊?急~~~~~~~~~~~~~~~~`
declare
str varchar2(10);
begin
select num into str from aa where num=1;
dbms_output.put_line(sqlcode); --正常返回0
exception
when others then
dbms_output.put_line(sqlcode); --异常返回错误的号
end;
可以用dbms_output.put_line(sqlcode);
v_ErrorCode NUMBER; -- Code for the error
v_ErrorMsg VARCHAR2(200); -- Message text for the error
v_CurrentUser VARCHAR2(8); -- Current database user
v_Information VARCHAR2(100); -- Information about the error
BEGIN
/* Code which processes some data here */
NULL;
EXCEPTION
WHEN OTHERS THEN
-- Assign values to the log variables, using built-in
-- functions.
v_ErrorCode := SQLCODE;
v_ErrorMsg := SQLERRM;
v_CurrentUser := USER;
v_Information := 'Error encountered on ' ||
TO_CHAR(SYSDATE) || ' by database user ' || v_CurrentUser;
-- Insert the log message into log_table.
INSERT INTO log_table (code, message, info)
VALUES (v_ErrorCode, v_ErrorMsg, v_Information);
END;
/