Skip to Main Content

SQL & PL/SQL

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Quick SQL issue

Sanjay SikderDec 17 2024 — edited Dec 17 2024

If a table is created using /auditcols through Quick SQL, then Update Date and Update By not null are suggested and also triggers without any conditions, Update_By, Update_Date are suggested. If someone creates a table by default, then during data insertion, auto data is inserted in the Update_By, Update_Date columns. I think this is a mistake.

Below is the suggested Query and ****screenshot:

-- create tables
create table item_test (
id number generated by default on null as identity
constraint item_test_id_pk primary key,
item_name varchar2(200 char),
created date not null,
created_by varchar2(255 char) not null,
updated date not null,
updated_by varchar2(255 char) not null
)
;

-- triggers
create or replace trigger item_test_biu
before insert or update
on item_test
for each row
begin
if inserting then
:new.created := sysdate;
:new.created_by := coalesce(sys_context('APEX$SESSION','APP_USER'),user);
end if;
:new.updated := sysdate;
:new.updated_by := coalesce(sys_context('APEX$SESSION','APP_USER'),user);
end item_test_biu;
/

-- load data

-- Generated by Quick SQL Tuesday December 17, 2024 12:22:49

/*
ITEM_TEST /auditcols
ID num /pk
ITEM_NAME VC200

# settings = { semantics: "CHAR", language: "EN", APEX: true }
*/

Comments
Post Details
Added on Dec 17 2024
4 comments
214 views