异常块在dbms_cloud pl/sql中不起作用
我是使用Oracle产品的新手,最近我一直在尝试使用DBMS_CLOUD软件包中使用Create_external_table,而且我也有意使该功能失败。但是,预期的消息没有被抛出,因为您可以看到完全的例外。
您知道我的代码中可能出了什么问题吗?
SQL> begin
2 dbms_cloud.create_external_table(
3 table_name => 'ext_table',
4 credential_name =>'cred_name',
5 file_uri_list => 'https://.../invalidBucket/...',
6 column_list => 'name varchar2(20), age number',
7 format => json_object('type' value 'CSV'));
8 exception
9 when others then
10 dbms_output.put_line('Failed!');
11
12 end;
13 /
PL/SQL procedure successfully completed.
SQL>
SQL> select * from ext_table order by 1;
select * from ext_table order by 1
*
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-20400: Request failed with status HTTP 400 -
https.*
Error response - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidBucketName</Code><Message>The specified bucket is not
valid.</Message><BucketName></BucketName><RequestId>RequestID</RequestId>
<HostId>HostID</HostId></Error>
ORA-06512
ORA-06512
ORA-06512
编辑:
我曾尝试过围绕选择查询的写作和例外,但是我只收到一条消息“成功完成”的消息
SQL> declare
2 c_name varchar2(20) := 'a';
3 begin
4 select name into c_name from ext_table order by 1;
5 exception
6 when others then
7 dbms_output.put_line('Failed from select');
8 end;
9 /
PL/SQL procedure successfully completed.
I'm new on using Oracle products, lately I've been trying to use create_external_table from DBMS_CLOUD package and also I'm intentionally making the function fail. But the expected message is not being thrown, as you can see the complete exception is thrown.
Do you know what could be wrong in my code?
SQL> begin
2 dbms_cloud.create_external_table(
3 table_name => 'ext_table',
4 credential_name =>'cred_name',
5 file_uri_list => 'https://.../invalidBucket/...',
6 column_list => 'name varchar2(20), age number',
7 format => json_object('type' value 'CSV'));
8 exception
9 when others then
10 dbms_output.put_line('Failed!');
11
12 end;
13 /
PL/SQL procedure successfully completed.
SQL>
SQL> select * from ext_table order by 1;
select * from ext_table order by 1
*
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-20400: Request failed with status HTTP 400 -
https.*
Error response - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidBucketName</Code><Message>The specified bucket is not
valid.</Message><BucketName></BucketName><RequestId>RequestID</RequestId>
<HostId>HostID</HostId></Error>
ORA-06512
ORA-06512
ORA-06512
Edit:
I had tried write and exception around the select query, but I only get an message "Procedure succesfully completed"
SQL> declare
2 c_name varchar2(20) := 'a';
3 begin
4 select name into c_name from ext_table order by 1;
5 exception
6 when others then
7 dbms_output.put_line('Failed from select');
8 end;
9 /
PL/SQL procedure successfully completed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
dbms_cloud.create_external_table
呼叫不会失败,因此您永远不会输入异常处理程序。外部表是成功创建的。当您查询外部表时,Oracle会进行HTTP调用,并会遇到运行时错误。您可以将一个例外处理程序围绕在外部桌子上的查询中,这可能会捕获失败并对其做些事情。
The
dbms_cloud.create_external_table
call isn't failing so you'd never enter your exception handler.The external table is created successfully. When you query the external table, Oracle makes the HTTP call and you get a runtime error. You could put an exception handler around the query against the external table which could catch the failure and do something with it.