Hi,
I have interactive grid build on table emp( eid ,ename, created_date,created_user,updated_date ,updated_user).
Columns (created_date,created_user,updated_date ,updated_user) are disabled columns .
What I want ?
When adding records,Initialize columns created_date,created_user with values systimestamp ,app_user_id .(Default not work correct)
When modify ename column update columns updated_date ,updated_user with values systimestamp ,app_user_id.
Note: I don't want to use database trigger to do this ,I want dynamic action .
RashadContributor
afzal
step -1
set default value for only column- created_date,created_user
note-- not for ,updated_date ,updated_user column
step-2 make "created_date,created_user,updated_date ,updated_user" as readonly "always"
step-3 process- interactive gride automatic process (dml)
Target Type--- pl/sql code
begin
case :APEX$ROW_STATUS
when 'C' then
insert into emp_test(empno,ename,sal,created_date,created_user) values(:empno,:ename,:sal,:created_date,:created_user);
when 'U' then
update emp_test
set empno=:empno,
ename =:ename,
sal = :sal,
updated_date = to_date(sysdate,'dd/mm/yyyy hh24:mi:ss'),
updated_user =20
where empno=:empno;
when 'D' then
delete emp_test
where empno=:empno;
end case;
end;
Rashad
I appreciate this solution, and have tried it before.
But it is not useful in the event that the number of fields is many, meaning that you need write huge insert and update statements for all fields, and this is not logical.
Rashad
This my table
CREATE TABLE L_ADDRESSES_TYPE(
TYPE_ID NUMBER(2) ,
TYPE_NAME VARCHAR2(50) NOT NULL,
TYPE_STATUS NUMBER(1) DEFAULT 1 ,
C_DATE DATE DEFAULT SYSTIMESTAMP NOT NULL,
C_USER NUMBER(6) NOT NULL,
U_DATE DATE DEFAULT SYSTIMESTAMP NOT NULL,
U_USER NUMBER(6) NOT NULL
);
ALTER TABLE L_ADDRESSES_TYPE ADD CONSTRAINT L_ADDRESSES_TYPE_PK PRIMARY KEY (TYPE_ID);
ALTER TABLE L_ADDRESSES_TYPE ADD CONSTRAINT L_ADDRESSES_TYPE_AR_UK UNIQUE (TYPE_NAME) ;
ALTER TABLE L_ADDRESSES_TYPE ADD CONSTRAINT L_ADRS_TYPE_STUS_CK CHECK( TYPE_STATUS IN (0,1));
I build interactive grid on this table with the following dynamic action :
1:-------------------------
name : AfterResourceLoad
when
event:Resource Load
Selection type:Columns
Region:Type of Addresses
Columns:C_DATE,C_USER,U_DATE,U_USER
Action : Disable
Selection type:Columns
Columns:C_DATE,C_USER,U_DATE,U_USER
2:---------------------------
name : onChangeItems
when
event:Change
Selection type:Columns
Region:Type of Addresses
Columns:TYPE_NAME,TYPE_STATUS
Client-side Condition:
Type:Item/Column is not null
Component Type:Column
Column:TYPE_ID
True Action:(means update for me)
Action : Enable
Selection type:Columns
Columns:C_DATE,C_USER,U_DATE,U_USER
Action : Set Value
Set type:SQL Statement
SQL Statement:select SYSTIMESTAMP,:P0_APP_USER_ID from dual;
Items to Submit: TYPE_NAME,TYPE_STATUS
Affected Elements
Selection Type:Columns
Columns:U_DATE,U_USER
False Action:(means insert for me)
Action : Enable
Selection type:Columns
Columns:C_DATE,C_USER,U_DATE,U_USER
Action : Set Value
Set type:SQL Statement
SQL Statement:select SYSTIMESTAMP,:P0_APP_USER_ID from dual;
Items to Submit: TYPE_NAME,TYPE_STATUS
Affected Elements
Selection Type:Columns
Columns:C_DATE,C_USER
3:---------------------------------
name : onLoseFocus
when
event:Lose Focuse
Selection type:Columns
Region:Type of Addresses
Columns:TYPE_NAME,TYPE_STATUS
Action : Disable
Selection type:Columns
Columns:C_DATE,C_USER,U_DATE,U_USER
Upon execution, everything works very normally,
but when trying to add more than one row and try save them, the following error occurs:
ORA-01400: cannot insert NULL into ("MCM"."L_ADDRESSES_TYPE"."C_DATE")
Although there is a value for the column(C_DATE) in IG.
Rashad
Hi guys,
I think that working with items or columns which its status are hidden or disable not working in APEX.
I have been searching for a long time, but all solutions are useless.
Through my many attempts, I found a solution, which is not to make the items or columns hidden or disable , but rather than this ,leave it enabled and work on it with a dynamic action in order to prevent the users from modifying data .
Event:Get Focuse
Action:Cancel Event
That is.