Adding an additional column to a collection on Oracle SODA

21 Views Asked by At

I'm trying to add an additional column to a default collection that was created using Oracle SODA. The collection currently has 5 columns, ID, CREATED_ON, LAST_MODIFIED, VERSION and JSON_DOCUMENT. What I'm trying to do is to add an additional column that refers to the type of JSON_DOCUMENT that I'm storing. I'm trying to do this by manipulating the metadata part of the collection. The default metadata of the collection is this:

{
 "schemaName" : "mySchemaName",
 "tableName" : "myTableName",
 "keyColumn" :
 {
    "name" : "ID",
    "sqlType" : "VARCHAR2",
    "maxLength" : 255,
    "assignmentMethod" : "UUID"
 },
 "contentColumn" :
 {
    "name" : "JSON_DOCUMENT",
    "sqlType" : "BLOB",
    "compress" : "NONE",
    "cache" : true,
    "encrypt" : "NONE",
    "validation" : "STANDARD"
 },
 "versionColumn" :
 {
   "name" : "VERSION",
   "method" : "SHA256"
 },
 "lastModifiedColumn" :
 {
   "name" : "LAST_MODIFIED"
 },
 "creationTimeColumn" :
 {
    "name" : "CREATED_ON"
 },
 "readOnly" : false
}

What I have currently managed to do is reduce the number of columns to 2, using this metadata:

'{
        "keyColumn":{
            "assignmentMethod": "CLIENT"
        },
        "contentColumn": {
            "sqlType": "CLOB"
        }
    }'

which gives me only 2 columns.

I have also tried to add a new custom column to the metadata, something like this:

{
 "schemaName" : "mySchemaName",
 "tableName" : "myTableName",
 "keyColumn" :
 {
    "name" : "ID",
    "sqlType" : "VARCHAR2",
    "maxLength" : 255,
    "assignmentMethod" : "UUID"
 },
 "contentColumn" :
 {
    "name" : "JSON_DOCUMENT",
    "sqlType" : "BLOB",
    "compress" : "NONE",
    "cache" : true,
    "encrypt" : "NONE",
    "validation" : "STANDARD"
 },
    "contentColumn" :
 {
    "name" : "CUSTOM_COL",
    "sqlType" : "BLOB",
    "compress" : "NONE",
    "cache" : true,
    "encrypt" : "NONE",
    "validation" : "STANDARD"
 },
 "versionColumn" :
 {
   "name" : "VERSION",
   "method" : "SHA256"
 },
 "lastModifiedColumn" :
 {
   "name" : "LAST_MODIFIED"
 },
 "creationTimeColumn" :
 {
    "name" : "CREATED_ON"
 },
 "readOnly" : false
}

but the collection created by this also has the 5 default columns. Any help in letting me know where I'm going wrong, what I'm missing is appreciated.

For reference, the script I'm running to create the collection is this:

DECLARE
  l_collection  SODA_COLLECTION_T;
  l_metadata    VARCHAR2(32767);
BEGIN
  l_metadata := '{
 "schemaName" : "schema_name",
 "tableName" : "table_name",
 "keyColumn" :
 {
    "name" : "ID",
    "sqlType" : "VARCHAR2",
    "maxLength" : 255,
    "assignmentMethod" : "UUID"
 },
 "contentColumn" :
 {
    "name" : "JSON_DOCUMENT",
    "sqlType" : "BLOB",
    "compress" : "NONE",
    "cache" : true,
    "encrypt" : "NONE",
    "validation" : "STANDARD"
 },
    "contentColumn" :
 {
    "name" : "CUSTOM_COL",
    "sqlType" : "BLOB",
    "compress" : "NONE",
    "cache" : true,
    "encrypt" : "NONE",
    "validation" : "STANDARD"
 },
 "versionColumn" :
 {
   "name" : "VERSION",
   "method" : "SHA256"
 },
 "lastModifiedColumn" :
 {
   "name" : "LAST_MODIFIED"
 },
 "creationTimeColumn" :
 {
    "name" : "CREATED_ON"
 },
 "readOnly" : false
}';
    
  l_collection := DBMS_SODA.create_collection('TestCollection2', l_metadata);

  IF l_collection IS NOT NULL THEN
    DBMS_OUTPUT.put_line('Collection ID : ' || l_collection.get_name());
  ELSE
    DBMS_OUTPUT.put_line('Collection does not exist.');  
  END IF;
END;

Please let me know if any other information is needed. Thanks.

0

There are 0 best solutions below