admin管理员组文章数量:1345031
I'm trying to send data from an autonomous database in OCI over this function to a log created in OCI console:
DECLARE
log_endpoint VARCHAR2(4000);
log_body CLOB;
CURSOR audit_cursor IS
SELECT EVENT_TIMESTAMP, DBUSERNAME, ACTION_NAME, RETURN_CODE
FROM UNIFIED_AUDIT_TRAIL
WHERE EVENT_TIMESTAMP > SYSTIMESTAMP - INTERVAL '1' DAY;
BEGIN
log_endpoint := '.log.oc1.eu-frankfurt-1.mysecretocid';
FOR rec IN audit_cursor LOOP
log_body := '{
"specversion": "1.0",
"source": "autonomous-database",
"eventType": "db-audit-log",
"data": {
"timestamp": "' || TO_CHAR(rec.EVENT_TIMESTAMP, 'YYYY-MM-DD"T"HH24:MI:SS"Z"') || '",
"dbusername": "' || rec.DBUSERNAME || '",
"action": "' || rec.ACTION_NAME || '",
"status": "' || CASE WHEN rec.RETURN_CODE = 0 THEN 'SUCCESS' ELSE 'FAILURE' END || '"
}
}';
DBMS_CLOUD.SEND_REQUEST(
credential_name => 'MY_CRED',
uri => log_endpoint,
method => DBMS_CLOUD.METHOD_POST,
body => log_body
);
END LOOP;
END;
/
The credential for this function is already created.
When I execute this function I'm getting
ERROR at line 29:
ORA-06550: line 29, column 5:
PLS-00306: wrong number or types of arguments in call to 'SEND_REQUEST'
ORA-06550: line 29, column 5:
PL/SQL: Statement ignored
From documentation from Oracle everything seems fine with DBMS_CLOUD.SEND_REQUEST definition.
Any suggestions here?
I'm trying to send data from an autonomous database in OCI over this function to a log created in OCI console:
DECLARE
log_endpoint VARCHAR2(4000);
log_body CLOB;
CURSOR audit_cursor IS
SELECT EVENT_TIMESTAMP, DBUSERNAME, ACTION_NAME, RETURN_CODE
FROM UNIFIED_AUDIT_TRAIL
WHERE EVENT_TIMESTAMP > SYSTIMESTAMP - INTERVAL '1' DAY;
BEGIN
log_endpoint := 'https://logging.eu-frankfurt-1.oci.oraclecloud/20200531/logs/ocid1.log.oc1.eu-frankfurt-1.mysecretocid';
FOR rec IN audit_cursor LOOP
log_body := '{
"specversion": "1.0",
"source": "autonomous-database",
"eventType": "db-audit-log",
"data": {
"timestamp": "' || TO_CHAR(rec.EVENT_TIMESTAMP, 'YYYY-MM-DD"T"HH24:MI:SS"Z"') || '",
"dbusername": "' || rec.DBUSERNAME || '",
"action": "' || rec.ACTION_NAME || '",
"status": "' || CASE WHEN rec.RETURN_CODE = 0 THEN 'SUCCESS' ELSE 'FAILURE' END || '"
}
}';
DBMS_CLOUD.SEND_REQUEST(
credential_name => 'MY_CRED',
uri => log_endpoint,
method => DBMS_CLOUD.METHOD_POST,
body => log_body
);
END LOOP;
END;
/
The credential for this function is already created.
When I execute this function I'm getting
ERROR at line 29:
ORA-06550: line 29, column 5:
PLS-00306: wrong number or types of arguments in call to 'SEND_REQUEST'
ORA-06550: line 29, column 5:
PL/SQL: Statement ignored
From documentation from Oracle everything seems fine with DBMS_CLOUD.SEND_REQUEST definition.
Any suggestions here?
Share Improve this question asked yesterday gurbelundergurbelunder 3076 silver badges14 bronze badges1 Answer
Reset to default 1The SEND_REQUEST Expects body as BLOB. Not as CLOB.
Try this:
DECLARE
log_endpoint VARCHAR2(4000);
log_body CLOB;
log_body_blob BLOB;
CURSOR audit_cursor IS
SELECT EVENT_TIMESTAMP, DBUSERNAME, ACTION_NAME, RETURN_CODE
FROM UNIFIED_AUDIT_TRAIL
WHERE EVENT_TIMESTAMP > SYSTIMESTAMP - INTERVAL '1' DAY;
BEGIN
log_endpoint := 'https://logging.eu-frankfurt-1.oci.oraclecloud/20200531/logs/ocid1.log.oc1.eu-frankfurt-1.mysecretocid';
FOR rec IN audit_cursor LOOP
log_body := '{
"specversion": "1.0",
"source": "autonomous-database",
"eventType": "db-audit-log",
"data": {
"timestamp": "' || TO_CHAR(rec.EVENT_TIMESTAMP, 'YYYY-MM-DD"T"HH24:MI:SS"Z"') || '",
"dbusername": "' || rec.DBUSERNAME || '",
"action": "' || rec.ACTION_NAME || '",
"status": "' || CASE WHEN rec.RETURN_CODE = 0 THEN 'SUCCESS' ELSE 'FAILURE' END || '"
}
}';
log_body_blob := TO_BLOB(UTL_RAW.CAST_TO_RAW(log_body));
DBMS_CLOUD.SEND_REQUEST(
credential_name => 'MY_CRED',
uri => log_endpoint,
method => DBMS_CLOUD.METHOD_POST,
body => log_body_blob
);
END LOOP;
END;
/
Also, check the structure of the SEND_REQUEST parameters from Oracle’s DBMS_CLOUD.SEND_REQUEST documentation.
本文标签: oracle databaseDBMSCLOUDSENDREQUEST with wrong types of argumentsStack Overflow
版权声明:本文标题:oracle database - DBMS_CLOUD.SEND_REQUEST with wrong types of arguments - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743776353a2537053.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论