Skip to Main Content
Feature Request FR-2096
Product Area Developer Experience
Status CLOSED

3 Voters

Add an anydata column to the APEX_COLLECTIONS

jaughenbaugh Public
· Oct 19 2021

Idea Summary
Add an anydata type column to the APEX_COLLECTIONS package and objects

Use Case
It would leverage the full capabilities of the APEX collection while allowing the user to store datatypes based on the row rather than the column.  This can be useful when creating dynamic forms.

Example of working solution package: (not all inclusive but functional)

create or replace PACKAGE BODY "PKG_ANYDATA" as

--------------------------------------------------------------------------------
function f_anydata_to_clob
(p_input sys.anydata)
return clob
as
 l_retvar clob;
 l_var_type varchar2(100);
begin
 if p_input is not null then

   -- get the variable source type
   l_var_type := ltrim(p_input.gettypename,'SYS.');

   case l_var_type
     when 'BINARY_DOUBLE' then l_retvar := to_clob(anydata.AccessBDouble(p_input));
     when 'BINARY_FLOAT' then l_retvar := to_clob(anydata.AccessBFloat(p_input));
     when 'CHAR' then l_retvar := to_clob(anydata.AccessChar(p_input));
     when 'CLOB' then l_retvar := to_clob(anydata.AccessClob(p_input));
     when 'DATE' then l_retvar := to_clob(to_char(anydata.AccessDate(p_input),'YYYY.MM.DD'));
     when 'INTERVAL DAY TO SECOND' then l_retvar := to_clob(anydata.AccessIntervalDS(p_input));
     when 'INTERVAL YEAR TO MONTH' then l_retvar := to_clob(anydata.AccessIntervalYM(p_input));
     when 'NCHAR' then l_retvar := to_clob(anydata.AccessNchar(p_input));
     when 'NCLOB' then l_retvar := to_clob(anydata.AccessNClob(p_input));
     when 'NUMBER' then l_retvar := to_clob(anydata.AccessNumber(p_input));
     when 'NVARCHAR2' then l_retvar := to_clob(anydata.AccessNVarchar2(p_input));
     when 'RAW' then l_retvar := to_clob(anydata.AccessRaw(p_input));
     when 'TIMESTAMP' then l_retvar := to_clob(anydata.AccessTimestamp(p_input));
     when 'TIMESTAMP WITH TIMEZONE' then l_retvar := to_clob(anydata.AccessTimestampTZ(p_input));
     when 'TIMESTAMP WITH LOCAL TIMEZONE' then l_retvar := to_clob(anydata.AccessTimestampLTZ(p_input));
     when 'UROWID' then l_retvar := to_clob(anydata.AccessURowid(p_input));
     when 'VARCHAR' then l_retvar := to_clob(anydata.AccessVarchar(p_input));
     when 'VARCHAR2' then l_retvar := to_clob(anydata.AccessVarchar2(p_input));
     else null; 
   end case;

 end if;

 return l_retvar;
exception
 when others then
   raise;
end f_anydata_to_clob;
--------------------------------------------------------------------------------
function f_clob_to_anydata
(p_input in clob
,p_data_type in varchar2)
return anydata
as

 l_input clob := p_input;
 l_retvar anydata;
 l_stmt varchar2(4000);

begin

 if l_input like '%~%' then
   l_input := replace(l_input,'~',chr(10));
 end if;

 if p_data_type = 'DATE' then 
   l_stmt := 'select sys.anydata.convert'||p_data_type||'(to_date(:a,''YYYY.MM.DD'')) val1 from dual';  
 elsif p_data_type = 'DATETIME' then 
   l_stmt := 'select sys.anydata.convert'||p_data_type||'(to_date(:a,''YYYY.MM.DD'')) val1 from dual';  
 elsif p_data_type = 'NUMBER' then 
   l_stmt := 'select sys.anydata.convert'||p_data_type||'(to_number(:a)) val1 from dual';
 else
   l_stmt := 'select sys.anydata.convert'||p_data_type||'(:a) val1 from dual';  
 end if;
 begin 
   execute immediate (l_stmt) into l_retvar using p_input;
 exception
   when others then
     l_retvar := null;
 end;

 return l_retvar;
exception
 when others then
   raise;
end f_clob_to_anydata;
--------------------------------------------------------------------------------

end pkg_anydata;

This request is likely a duplicate of FR-599.

Comments

Comments

  • jayson hanes Admin OP 4.4 years ago

    It seems fair to mark this feature request as a duplication of 599

  • jaughenbaugh OP 4.4 years ago

    While I agree that this is in the same vein as 599 it is different in that they were asking for additional number columns and this is specifically asking for an anydata type to be added as a column.  Other cases aside i think the anydata would be ideal as a full replacement for all columns in the apex_collection I'm not sure there is enough cause to revamp it entirely

  • jayson hanes Admin OP 4.4 years ago

    Thanks for the feedback - we will be reviewing these ideas.