Can I select a set of rows from a table and directly insert that into a table or the same table in SQL?
Tag : sql , By : Ir0nh1de
Date : March 29 2020, 07:55 AM
To fix this issue You can do something like that, but you cannot Select * if you want to change a column value: Insert into employee ( employeeId, someColumn, someOtherColumn )
Select 2, someColumn, someOtherColumn
From employee
Where employeeId=1
|
Oracle APEX Trigger - Can I affect 'Table A' when I execute a trigger on the insert of 'Table B'?
Date : March 29 2020, 07:55 AM
it should still fix some issue You are confusing Apex and database concepts: triggers are part of the database, not of Apex. The syntax for the trigger would be: CREATE OR REPLACE TRIGGER "DEFAULT_LOG_ENTRY" AFTER insert on "MAIN_APEX"
for each row
begin
insert into apex_logs (log_entry, log_date, circulation,
main_pk_ref, techwriter)
values ('This log page was established. Actions and communcations are captured from this date and time onward.'
, sysdate
, 'External'
, :new.main_pk
, :new.TECHWRITER);
end;
|
Is it good to create some intermediate table or directly use WITH query. Given that the table is a big table
Date : March 29 2020, 07:55 AM
this one helps. You should try it. Oracle does not (necessarily) materialize CTEs. That means that the entire query gets optimized, which no unnecessary reads and writes. In many cases, this results in a more efficient query plan.
|
can not insert row in a table while data redirecting from parent table to child table in trigger(stored procedure)
Date : March 29 2020, 07:55 AM
To fix the issue you can do I am using postgres version: PostgreSQL 9.2.4 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.7.2-5) 4.7.2, 64-bit , My problem is solved in this way... CREATE OR REPLACE FUNCTION insert_tsttbl1_hourbase() RETURNS TRIGGER AS $$
BEGIN
RAISE NOTICE 'Hi...%', NEW;
Execute 'set search_path to ' || TG_TABLE_SCHEMA|| '';
INSERT INTO tsttbl1_hour0 values (NEW.*);
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
|
mysql select from table B where condition is not met on table B directly, but through join on table A
Date : March 29 2020, 07:55 AM
it helps some times Given two tables A and B, which look like: , You could use: SELECT *
FROM Table_b
WHERE A_id IN (SELECT A_Id
FROM Table_b
WHERE LENGTH(Value) = 4);
╔══════╦═══════╗
║ A_id ║ Value ║
╠══════╬═══════╣
║ 3 ║ Goat ║
║ 3 ║ Cow ║
╚══════╩═══════╝
|