SQL & PL/SQL :: Entire Insert Script Row Will Be Inserted Into Cbxrdlog Table Sqltext Column
Aug 24, 2011
I have 2 tables. Cbxrd and Cbxrdlog. If the Cbxrd table having creation date column. when it inserts the row. if the column is null value. then the entire insert script row will be inserted into Cbxrdlog table sqltext column.
i have attached the trigger script. when i execute the table but i shows error like
"Ora-0756 Quoted String not properly terminated".
"Ora-04098: trigger os_wm_sit_owner.cbx trigger is invalid and failed revalidation.
INSERT ALL INTO test_abc VALUES (1,12345,34567,87654) INTO test_abc VALUES (2,17345,37567,87754) INTO test_abc VALUES (3,12745,34767,87674) INTO test_abc VALUES (4,17045,30567,80754) INTO test_abc VALUES (5,12740,34067,87604) SELECT * FROM dual;
CREATE TABLE test_b (id NUMBER, col VARCHAR2(10), coltype_id NUMBER);
What I need to do is to convert the columns col1, clo2, col3 in test_abs into rows in test_b. but I need to do this so that the column name is what determines the value of colytype_id.So in test_b values will look like:
I know this is an old thread and I just started working with triggers. I want to check if the data being inserted is already in the table and if not insert it:
create or replace trigger t_triggername before insert on tbl_tablename for each row begin if(:new.user_id <> :old.user_id) then insert into tbl_tablename(user_id, location) values (:new.user_id, :new.location); end if; end;
what if I wanted to keep the user but only update location if the user is already in the table. I've tried doing it this way:
create or replace trigger t_triggername before insert on tbl_tablename for each row begin if(:new.user_id <> :old.user_id) then insert into tbl_tablename(user_id, location)
We have a requirement, to highlight an entire column of a classic report based on a query to red. So if the search of the report returns column1, column2 as the output. Column 2 (text) should be highlighted in red across all results rows.
In some forum responses, I see using some id format, one can try to highlight a single column in a row. Not sure how can this be done across the whole column of multiple rows.
I am trying to insert In multiple table where one tbl PK is FK of other , I achieved that functionality using Instead of Insert trigger.(PK is handled by another trigger) -- main functionNow On successfully insert i need to captured the PK in Hidden variable to pass it on further for more insert on other table (Pk again being Fk to this table)--- secondary function
I am facing a problem in bulk insert using SELECT statement.My sql statement is like below.
strQuery :='INSERT INTO TAB3 (SELECT t1.c1,t2.c2 FROM TAB1 t1, TAB2 t2 WHERE t1.c1 = t2.c1 AND t1.c3 between 10 and 15 AND)' ....... some other conditions.
EXECUTE IMMEDIATE strQuery...These SQL statements are inside a procedure. And this procedure is called from C#.The number of rows returned by the "SELECT" query is 70.
On the very first time call of this procedure, the number rows inserted using strQuery is 70. But in the next time call (in the same transaction) of the procedure, the number rows inserted is only 50.And further if we are repeating calling this procedure, it will insert sometimes 70 or 50 etc. It is showing some inconsistency.On my initial analysis it is found that, the default optimizer is "ALL_ROWS". When i changed the optimizer mode to "rule", this issue is not coming.I am using Oracle 10g R2 version.
If i have a table, my_table, with 20 columns, and i have something like:
declare ... begin for r in (select * from my_table) loop insert into my_table (...) values (...) end loop; end;
So, I want to insert a row into that table, with values for all columns being those returned by the for loop, but without a column (i'm giving the value for that column).For example, the first 19 rows should contain the values from the currently record in 'for.. loop', and the last column to contain a static value.Is it possible to do this, without specifying in the 'values' clause, something like (r.col1, r.col2, .... r.col19, 'G')? meaning other insert method.
select 'SID ' || l1.sid ||' is blocking ' || l2.sid blocking from v$lock l1, v$lock l2 where l1.block =1 and l2.request > 0 and l1.id1=l2.id1 and l1.id2=l2.id2;
BLOCKING -------------------------------------------------------------------------------------------------- SID 142 is blocking 241
SQL> select sid,SERIAL# from v$session where sid in (142,241); SID SERIAL# ---------- ---------- 142 40643 241 16500
Now if I am trying to find what exactly getting executed under those two sid I get info for only one.
SQL> select a.SQL_ID,a.SQL_TEXT from v$sqltext a, v$session b where a.ADDRESS=b.SQL_ADDRESS and a.HASH_VALUE=b.SQL_HASH_VALUE and b.sid=241; SQL_ID SQL_TEXT ------------- ---------------------------------------------------------------- d11mmj6wj4046 DELETE FROM OTABATCHEPTTABLE WHERE EPT_ID=0001471142180000002
BUT FOR OTHER SID I DONT HAVE ANY ENTRY IN SQLTEXT
SQL> select a.SQL_ID,a.SQL_TEXT from v$sqltext a, v$session b where a.ADDRESS=b.SQL_ADDRESS and a.HASH_VALUE=b.SQL_HASH_VALUE and b.sid=142; no rows selected
FIND OUT WHAT EXACTLY ITS RUNNING AND WHY I AM NOT GETTING THE SQLTEXT FOR A SID?
i used sql loader to import data from csv file to my db.but every time the columns places are changed.o i need dynamic way to insert data into correct column in the table.
in csv file contains column name and i insert this data to temp table, after that i want to read data over column name.also i read the column names from (All_Tab_Columns) to make combination of column name between temp table and All_Tab_Columns table to insert data to right place...
that I need to insert into Child using seq_parent but I want to insert the same sequence for each group of rRef. I dont know how to do that using SQL not PL/SQL.
I have a table where there is no sequence maintained and there is no time stamp column to track the inserted record.How do I find the latest inserted record in the table.
I am using an Oracle Forms application. When you click a check-box in the form and save it,a record is inserted to a log table, they say. The DB schema has over 1000 tables and over50 log tables. Is there way using the data dictionaly to find out which table was inserted tomost recently? I don't have access to the Forms code. My goal is to find out the table that the Form inserted the log entry to.
I have one table in which I want to restrict some records from being inserted. I don't want to put any checked constraints. e.g. consider following table
transaction( id number primary key, txn_date timestamp(7), payee varchar2(40), amount number, memo varchar2(40), ref_num number )
I want to write SQL which should not inset duplicate record.
e.g.
I have written one as bellow:
insert into transaction select 1, to_date('2009-12-12','YYYY-MM-DD'), 'Payee1', 12, 'Test', 212 from dual where (select count(*) from transaction where txn_date=to_date('2009-12-12','YYYY-MM-DD') and payee='Payee1' and amount=12)=0;
Can I use exists/not exists, which query will be more appropriate. (Please consider that fields which I am using to filter out the duplicate transactions does not contain primary key.)
Can I write such SQL. Or do i check for duplicate rows one by one and then filter the duplicate records.
I have a table which is getting populated from a source. I dont have a time-stamp column in the table. Is there anyway to find the time when a record was inserted into the table?
I got html source code inserted into the table as CLOB (or BLOB). And I would like to search a some word from that.When I find a some value I can write this one into the column.It would be easy if this code is xml but isnt.
My scenario is to insert values into 'out' column by comparing 's' and 'IP' columns of temp table.The exact situation is at first need to go to ip column,take a value and then go to source column and check for the same value of ip which is taken previously.Then after corresponding ip of that source column should be inserted back in previous source column.
The situation is marked clearly in file which i am attaching with '--' comments at respective places.I am also pasting the code which i tried out,unfortunately it is giving error as exact fetch returns more than requested number of rows since there are duplicates in the table.I tried it using nested for loops.Also implemented using rowid,but it didnt work.
fixing the errors or if there is any new logic that can be implemented.
DECLARE i_e NUMBER(10); BEGIN FOR cur_1 IN(SELECT IP from temp where IP IS NOT NULL) LOOP FOR cur_2 IN(SELECT IP from temp where s=cur_1.IP)
I have a complex sql query that fetches 88k records. This query uses a global temporary table which is the replica of one of our permanent tables. When I do Create table..select... using this query it inserts only fewer records. But when I make the query point to the permanent table it inserts all 88k records.
1. I tried running the select query separately using temp and perm table. Both retrieves 88k records.
2. From debugging I found that this problem occurred when we were trying to perform a left outer join on an inline view.
However this problem got resolved when I used the /*+ FIRST_ROWS */ hint.
From my limited oracle knowledge I assume that it is the problem with the query and how it is processed in the memory.
I am using oracle developer 10g. I want to know the status of the printer where i want to print. If the running report is printing or in queue then a record is to be inserted into a table as audit-trail of printing. Idon't want to do it manually.
I can see that I can use REUSE_DATAFILES & TABLE_EXISTS_ACTION to overwrite tables by default, but is there a recognised way of replacing the entire DB with the impdp? Do I just create the instance, (with the init file) and not build/init the tables, or what? I'll experiment, but I'm just interested if there is a DBA best practice for this sort of thing.
I have a table with a column of type blob. Now i want to create a procedure which will insert into that table. But I don't like to create a directory. How can i solve this.
I want to insert a row like this:
insert into table x(image) values('d:photo est.jpg');
Backup your entire database, without archived logs, while the database is open for user activity. This backup should be the base for an incremental backup strategy
When I am trying to insert record from tbl_mittal into tbl_temp table. I am facing "ORA-14400: inserted partition key does not map to any partition" error
SQL> insert into tbl_temp select * from tbl_mittal; insert into tbl_temp select * from tbl_mittal * ERROR at line 1: ORA-14400: inserted partition key does not map to any partition
AS tbl_mittal is having hugh number of records so I am providing only few rows from tbl_mittal table as test data.