Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug for tables with pk and a domain witg sys_guid() as default #61

Open
ljvankempen opened this issue Oct 17, 2024 · 0 comments
Open

bug for tables with pk and a domain witg sys_guid() as default #61

ljvankempen opened this issue Oct 17, 2024 · 0 comments

Comments

@ljvankempen
Copy link

In oracle 23ai I have created a domain
create domain do_uuid
as raw(16) default sys_guid() not null
annotations (UI_display 'UUID', Classification 'uuid')
display lower(
substr(lpad(rawtohex(uuid),32,'0'),1,8)||'-'||
substr(lpad(rawtohex(uuid),32,'0'),9,4)||'-'||
substr(lpad(rawtohex(uuid),32,'0'),13,4)||'-'||
substr(lpad(rawtohex(uuid),32,'0'),17,4)||'-'||
substr(lpad(rawtohex(uuid),32,'0'),21));

Create table x
add cp_id domain do_uuid,
nam varchar2(40) default 'test'

this gives a error in de generated the api with
om_tapigen.compile_api(p_table_name => 'X'
,p_enable_column_defaults => TRUE);

procedure and function create_rows

Make a workaround as follows:

FUNCTION util_get_column_data_default
(
p_table_name IN VARCHAR2
,p_column_name IN VARCHAR2
,p_owner IN VARCHAR2 DEFAULT USER
) RETURN VARCHAR2 AS
v_return all_tab_columns.data_default%TYPE;
--- HACK LVK

--- When having a primary with a domain default value sys_guid()
--- this function give the value sys_guid() back but with a length of 40
--- If you concatenate a string to THIS is not done (see list_params_w_pk )

/*
  CURSOR c_utc IS
    SELECT data_default -- LVK
      FROM all_tab_columns
     WHERE owner = p_owner
       AND table_name = p_table_name
       AND column_name = p_column_name;
BEGIN
  OPEN c_utc;

  FETCH c_utc
    INTO v_return;

  CLOSE c_utc;

  RETURN substr(v_return
               ,1
               ,4000);
               */

BEGIN
SELECT a.data_default_vc
INTO v_return
FROM all_tab_columns a
WHERE owner = p_owner
AND table_name = p_table_name
AND column_name = p_column_name;

IF instr(v_return
        ,'sys_guid()') = 1
THEN
  v_return := 'sys_guid()';
END IF;

RETURN(v_return);

END util_get_column_data_default;


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant