Skip to Main Content

API, CLI, SDK & Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

OCI PL/SQL SDK | Cannot assign supertype instance to subtype when trying to call document understanding functions.

Dan PettittJul 17 2025

I run into the same error when trying to call any of the dbms_cloud_oci_aid_ai_service_document functions, and that is ‘PL/SQL: value or conversion error: cannot assign supertype instance to subtype’. The documentation for the PL/SQL SDK mentions subtypes, but it isn't clear how to use them.

My goal is to use text extraction on documents stored in an OCI Storage Bucket. I have tried both analyze_document and create_processor_job, but receive the same error for both. Below are the blocks i have tried. for both, i have tried the full constructor methods as well as manually assigning parameters, but i get the same result. Notably, the error is in the actual function calls?

any help would be greatly appreciated, i can't find any examples. i did find a very similar post on here, but i applied the same logic and it didn't work.

Thanks :)

 declare 
l_response dbms_cloud_oci_aid_ai_service_document_analyze_document_response_t; 
l_func_details dbms_cloud_oci_ai_document_analyze_document_details_t := dbms_cloud_oci_ai_document_analyze_document_details_t 
(); 
l_doc_details dbms_cloud_oci_ai_document_object_storage_document_details_t := dbms_cloud_oci_ai_document_object_storage_document_details_t 
(); 
l_features dbms_cloud_oci_ai_document_document_feature_tbl := dbms_cloud_oci_ai_document_document_feature_tbl(); 
l_output_loc dbms_cloud_oci_ai_document_output_location_t := dbms_cloud_oci_ai_document_output_location_t(); 
begin 
-- init document details for passing to func details 
l_doc_details := dbms_cloud_oci_ai_document_object_storage_document_details_t( 
source => 'OBJECT_STORAGE', 
namespace_name => 'XXXXXxxxxx', 
bucket_name => 'bucket-xxxx-xxxxxxxx', 
object_name => 'general/doc.pdf' 
); 

-- init features for func 
l_features := dbms_cloud_oci_ai_document_document_feature_tbl(dbms_cloud_oci_ai_document_document_feature_t('TEXT_EXTRACTION' 
)); 
-- init output location for func 
l_output_loc.namespace_name := 'xxxxxxx'; 
l_output_loc.bucket_name := 'bucket-xxxx-xxxx'; 
l_output_loc.prefix := 'results'; 
-- init function details 
l_func_details.features := l_features; 
l_func_details.document := l_doc_details; 
l_func_details.compartment_id := 'ocid1.tenancy.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; 
l_func_details.output_location := l_output_loc; 
-- call function 
l_response := dbms_cloud_oci_aid_ai_service_document.analyze_document( 
analyze_document_details => l_func_details, 
region => 'eu-frankfurt-1', 
credential_name => 'CRED_NAME' 
); 

end;

ERROR:

ORA-06502: PL/SQL: value or conversion error: cannot assign supertype instance to subtype
ORA-06512: at "C##CLOUD$SERVICE.DBMS_CLOUD_OCI_AID_AI_SERVICE_DOCUMENT", line 596
ORA-06512: at "C##CLOUD$SERVICE.DBMS_CLOUD_OCI_AID_AI_SERVICE_DOCUMENT", line 2506
ORA-06512: at "C##CLOUD$SERVICE.DBMS_CLOUD_OCI_AID_AI_SERVICE_DOCUMENT", line 2579
ORA-06512: at "C##CLOUD$SERVICE.DBMS_CLOUD_OCI_AID_AI_SERVICE_DOCUMENT", line 7342
ORA-06512: at line 31

and the other function:

set SERVEROUTPUT on 
declare 
-- Object Storage document location 
l_object_location dbms_cloud_oci_ai_document_object_location_t; 
l_object_locations dbms_cloud_oci_ai_document_object_location_tbl; 
l_input_location dbms_cloud_oci_ai_document_object_storage_locations_t; 

-- Output location 
l_output_location dbms_cloud_oci_ai_document_output_location_t; 

-- Processor configuration 
l_features dbms_cloud_oci_ai_document_document_feature_tbl; 
l_processor_config dbms_cloud_oci_ai_document_processor_config_t; 

-- Job details 
l_job_details dbms_cloud_oci_ai_document_create_processor_job_details_t; 

-- Response 
l_response dbms_cloud_oci_aid_ai_service_document_create_processor_job_response_t; 
begin 
-- Step 1: Define the document location 
l_object_location := dbms_cloud_oci_ai_document_object_location_t( 
namespace_name => 'xxxxxxxxxxx', 
bucket_name => 'bucket-xxxx-xxxx', 
object_name => 'general/doc.pdf' 
); 

l_object_locations := dbms_cloud_oci_ai_document_object_location_tbl(l_object_location); 
l_input_location := dbms_cloud_oci_ai_document_object_storage_locations_t( 
source_type => 'OBJECT_STORAGE_LOCATIONS', 
object_locations => l_object_locations 
); 

-- Step 2: Define the output location 
l_output_location := dbms_cloud_oci_ai_document_output_location_t( 
namespace_name => 'xxxxxxxxxxxxxx', 
bucket_name => 'bucket-xxxx-xxx', 
prefix => 'results' 
); 

-- Step 3: Define processor config 
l_features := dbms_cloud_oci_ai_document_document_feature_tbl(dbms_cloud_oci_ai_document_document_feature_t('TEXT_EXTRACTION' 
)); 
l_processor_config := dbms_cloud_oci_ai_document_processor_config_t('GENERAL'); 

-- Step 4: Create job details 
l_job_details := dbms_cloud_oci_ai_document_create_processor_job_details_t( 
input_location => treat(l_input_location as dbms_cloud_oci_ai_document_input_location_t), 
output_location => l_output_location, 
compartment_id => 'ocid1.tenancy.oc1.xxxxxxxxxxxxxxxxxx', 
processor_config => l_processor_config 
); 

-- Step 5: Call the job creation function 
l_response := dbms_cloud_oci_aid_ai_service_document.create_processor_job( 
create_processor_job_details => l_job_details, 
region => 'eu-frankfurt-1', 
credential_name => 'CRED_NAME' 
); 
end;

ERROR

ORA-06502: PL/SQL: value or conversion error: cannot assign supertype instance to subtypeORA-06512: at "C##CLOUD$SERVICE.DBMS_CLOUD_OCI_AID_AI_SERVICE_DOCUMENT", line 3130ORA-06512: at "C##CLOUD$SERVICE.DBMS_CLOUD_OCI_AID_AI_SERVICE_DOCUMENT", line 3206ORA-06512: at "C##CLOUD$SERVICE.DBMS_CLOUD_OCI_AID_AI_SERVICE_DOCUMENT", line 7784

Comments
Post Details
Added on Jul 17 2025
1 comment
25 views