我刚开始使用甲骨文产品,最近我一直在尝试使用来自create_external_table包的DBMS_CLOUD,而且我还故意让这个函数失败。但是没有抛出预期的消息,因为您可以看到抛出了完整的异常。
你知道我的代码有什么问题吗?
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
编辑:
我在select查询周围尝试了写和异常,但是我只得到一条消息“过程成功地完成了”。
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.
发布于 2022-05-31 07:47:30
dbms_cloud.create_external_table
调用没有失败,因此永远不会输入异常处理程序。
成功创建了外部表。查询外部表时,Oracle进行HTTP调用,并得到一个运行时错误。您可以在针对外部表的查询周围设置一个异常处理程序,它可以捕获故障并对其执行一些操作。
https://stackoverflow.com/questions/72450431
复制