Execute Immediate To Dynamically Build A Trigger?
Apr 25, 2011
We have developed a code which builds a trigger on a atble dynamically at run time usinf Dynamic SQL command Execute immediate.
create or replace
PROCEDURE GENERATE_TRIGGER
(
P_TNAME IN VARCHAR2
[Code].....
I am not usre if the error is due to insufficient privileges as we are able to build tabl;e in the system dynamically using the above mentioned command.
View 1 Replies
ADVERTISEMENT
Oct 23, 2013
I'm working with old code that uses dbms_sql.execute to build/execute dynamic sql. In our case, the user can select varying columns(I think up to 20) with different where conditions as needed.
After building the sql, here's an example
WITH ph AS
(SELECT ph.* FROM po_header ph WHERE 1 = 2),
pf AS
(SELECT DISTINCT pf.order_id, pf.fund
FROM po_fau pf, ph
WHERE 1 = 1
AND ph.order_id = pf.order_id
[code]....
Where table records for
po_header = ~567746
po_fau = ~2153570
and PK "order_id" is a NUMBER(10) not null and a snippet of the code looks like
nDDL_Cursor := dbms_sql.open_cursor;
dbms_sql.parse(nDDL_Cursor, sSQLStr, 2);
FOR x IN 1 .. nCols LOOP
sCols(x) := '';
dbms_sql.define_column(nDDL_Cursor, x, sCols(x), 100);
END LOOP;
nError := dbms_sql.execute(nDDL_cursor);
why when the "execute" statement is fired off the elapsed time takes ~4.5 seconds but If I change "1 = 1" above to "1 = 2" it takes ~.2 seconds. If I run the above query interactively it takes ~.2 seconds. Shouldn't the above query when joining
ph.order_id = pf.order_id
return zero rows back instantly or does the "dbms_sql_execute" do some other type of parsing internally that takes cpu time.
View 14 Replies
View Related
May 3, 2013
We have an requirement to create xml data for entire database (selected tables) which are in hierarchy.Procedure should read node_mapping table having parent and child tables relationship info and build XML Select statement.
Currently it is building SQL statement whenthere are one parent having multiple childrens i.e Dept having emp, emp_act, emp_rsch..but when child node are having childrens then it is not working - it has to repeatedly call this procedure (recursive) and build below given SQL statement.
1. To change procedure to build xml sql statement when there are multiple childrens to child nodes (hierarchy)
2. To format the output in xml data
We are using ORACLE 11G and WINDOWS 7
CREATE TABLE node_mapping
(
NODE_ID NUMBER(5) PRIMARY KEY,
PARENT_NODE VARCHAR2(100),
CHILD_NODE VARCHAR2(100),
PARENT_NODEID VARCHAR2(50),
CHILD_NODEID VARCHAR2(50)
[code]....
View 1 Replies
View Related
May 8, 2013
We have an requirement to build (XML) Select statement dynamically based on the mapping table (which is in hierarchy format)
I have removed xml keyword, so query will not work. but need procedure which will recursively check mapping table (parent and child table) and build below given select statement.
Example 1:
SELECT dname,
(select ename,
[Code]....
View 8 Replies
View Related
Jan 2, 2011
I have a procedure p1 in schema s1.i want to call this procedure in schema s2 dynamically.how can i do?
View 4 Replies
View Related
Jul 9, 2013
I have to audit some table to log all modifications (inserts, updates, deletes). I wrote the following trigger (works as expected) :
-- Trigger for DOCUMENT table audit
CREATE OR REPLACE TRIGGER TAUDIT_IUD_DOCUMENT
AFTER INSERT OR UPDATE OR DELETE ON DOCUMENT
FOR EACH ROW
DECLARE
l_user VARCHAR2(64);
[code].........
Is there any way I can improve this ?I mean getting columns name and value (:NEW and :OLD) dynamically, instead of specifying them one by one (the trigger will have to be updated in case a new column is added). Something like this :
FOR i in 1..DOCUMENT.COLUMN_COUNT LOOP
l_row := l_row || DOCUMENT.COLUMN_NAME(i) || :NEW.COLUMN_VALUE(i) || l_separator;
END LOOP;
View 6 Replies
View Related
Dec 3, 2010
I have created a procedure to build trigger dynamically using Dynamic SQL. Here procedure created successfully, when we execute the procedure to build trigger getting the following error.
Note: We are able to create a Trigger, but it is INVALID. if we get the code of a trigger and execute, trigger created a successfully with Valid Status.
ERROR:
ORA-24344: success with compilation error
ORA-06512: at "APPS.CREATE_TRIGGER", line 28
ORA-06512: at line 2
SQL*Plus internal error state 2087, context 47:0:0
Unsafe to proceed
View 2 Replies
View Related
Jun 13, 2010
I want to make a trigger , to store values that are affected during any DML(insert,update,delete).
CREATE OR REPLACE TRIGGER generate_log
BEFORE INSERT OR UPDATE
ON EMPLOYEE
FOR EACH ROW
DECLARE
[code]....
View 8 Replies
View Related
Apr 17, 2013
I am trying to use execute immediate in a trigger. See the below example
create table test_tbl(col1 number,col2 varchar2(10), col3 date);
create table test_tbl_log as select * from test_tbl where 1 = 2;
create or replace trigger test_trig
after insert or update or delete on test_tbl
for each row
declare
v_str varchar2(4000);
[code].......
insert into test_tbl values(3,'test',sysdate);
I got the Error : -1008->ORA-01008: not all variables bound
In the execute immediate statement if I change the v_using_str variable to :new.col1,:new.col2,:new.col3 trigger is running fine. But here I have to create trigger on all the tables in my schema and I dont want to list all the column names for each table manually and I am using a for loop to build the v_using_str string in my original code.
View 2 Replies
View Related
Feb 6, 2007
I've been asked to look into ways I an execute an application with a trigger. I know I could set some database flag and have an application look at the flag and execute an application based on this, but my boss really doesn't wanna go down this route.
I was told I can use either C or java within the trigger somehow to execute an application (for example notepad.exe)
View 1 Replies
View Related
Apr 2, 2013
I want to execute a db trigger once for updation of more than one record on a single primary key. The updation would be made by a 10g form by using the common tabular data block.
View 1 Replies
View Related
Jan 30, 2013
i try to make trigger to execute immediate create or replace view
(
CREATE OR REPLACE TRIGGER xxxx
BEFORE INSERT ON table1
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
declare
l number ;
v_ddl varchar2(4000);
v_job number;
[code]....
it give me error for insuffition privilage in execute immediate and after i make GRANT CREATE ANY TRIGGER TO user give me error can't commit in trigger.
View 8 Replies
View Related
Sep 13, 2011
I have a problem in my form. In my form there are 4 blocks and in one of the block i have a button. In which i put a code same as below:
BEGIN
IF NAME_IN('SYSTEM.FORM_STATUS') = 'CHANGED'
THEN
CLEAR_FORM(NO_VALIDATE);
END IF;
PROCEDURE ABC;
END;
So as per code i want to clear all the changes in form for current session and want to call the procedure ABC after that. But it is not calling the procedure ABC. And what would i do to perform the same?
View 19 Replies
View Related
Nov 9, 2009
I would like to create a trigger that will execute a stored procedure when a package/function/procedure is compiled. I tried creating an update trigger on user_objects, but it statues aI cannot create that trigger tyoe on views.
View 1 Replies
View Related
Jul 18, 2013
I'm trying to build a query capture the below information. Table looks something like below .
RoomSubjectStudentsA1Science10A1Maths20B1Science15B2English25C1Deutsch20A1French15C1English10
How can i write a query so that i takes the average of students in each room and display the output? I need to write a query so that it also picks up any new rooms and students added. Average is sum of total students in room by number of times each room is specified.
eg: A1 is listed 3 times a the result would be 10+20+15 divided by 3.
A1 B1 B2 C115 15 20 15
View 7 Replies
View Related
Jul 28, 2010
I installed oracle11g on my computer ,when im going to build demo its not working.its giving a error like this.
sys>conn u1/u1
error accesing PRODUCT_USER_PROFILE
warning product user profile information not loaded
you may need to run PUPBLD.SQL AS SYSTEM
connected
u1>@?/sqlplus/demo/demobld unable to open file "/oraeng/app/oracle/product/11.1.0/sqlplus/demo/demobld.sql"
View 1 Replies
View Related
Aug 3, 2011
I am an absolute neophyte at this. I'm fairly good at SQL, but have not administrated a database before.
I am trying to take a backup from our production database and restore it to a fresh install of Oracle 10.2 on a Windows 2003 server using RMAN - but I am not getting very far. Software versions are all the same. I have access to the manuals, but it seems like every link I follow adds more questions than it answers.
I have gone through the wizard and set up oracle on the new box - that all seemed to go smoothly. In order for this to work, do I need to set up the database with the same DBID as the one in the backup files? Or is there a way to import the data from the backup and have it build the database from those files?
I'm not sure I'm even asking the right questions. Do any of y'all know of a tutorial that would walk me through this process step by step?
View 4 Replies
View Related
Jun 19, 2012
we get daily a full dump from our customer. We have to build the differences of tables (deltas) and load them in separate tables.
There some questions, requiremenst and restrictions:
1) Is it possible the merge the dumps ?
2) How to build the differences as the easiest ?
3) The whole process (import, merge, extract) should be run in batch.
4) We have only a solid knowledge and liitle time for doing.
View 1 Replies
View Related
Jun 21, 2011
select a default table in oracle as we do in teradata, below is the syntax of teradata.
select 'XXX' as Curr,
'BUS OBJ ' as acq_nm
from (select 1 as one) Union
select 'ALL' as Curr, from (select 1 as one).
so I need the same select in oracle.
View 3 Replies
View Related
Feb 26, 2010
I want to build a hierarchy and output it into a sub-report. Since the data in few hierarchy fields exceeds 4000 characters and therefore m getting the ORA-01489 error and the entire report was failing.
So i have used user aggregate function to print the out put. I have also used row_number() to print sequence in query output.
the query that i am using is
SELECT pr_id,
REPLACE (REPLACE (twadmin.STRAGG2(distinct RPAD (to_number(curr), 2, ' ') || ')' || NVL (DECODE (medical, NULL, clinical, medical), 'UNKNOWN') || '###' ||
RPAD (' Causality as per rport ', 50, ' ') || ': ' || reporter || '###' ||
RPAD (' Causality as per report2 ', 50, ' ') || ': ' || hospital || '###' ||
RPAD (' Dechallenge', 50, ' ') || ': '|| dechallenge || '###' ||
RPAD (' Rechallenge', 50, ' ') || ': '|| rechallenge), ',', CHR(10)), '###', CHR (10)) causality
[code]......
the output of the query is
ID Causality
-- ------
3755101 )Blisters (Blister)
Causality as per report1: Probable
Causality as per report2: Possible
Dechallenge : Not Applicable
Rechallenge : Not Applicable
2 )Mental status changes (Mental status changes)
[code].......
but the expected out put is
ID Causality
-- ------
3755101 )Blisters (Blister)
Causality as per report1: Probable
Causality as per report2: Possible
Dechallenge : Not Applicable
Rechallenge : Not Applicable
[code]........
but it should be as
1)
2)
3)
..
..
..
10)
11)
12) for the values in the causality field
View 25 Replies
View Related
Dec 18, 2012
I have created a VIEW with a column containing user-defined aggregated values(stores the output in varchar2 data type). Some of the records exceed the maximum limit, for example varchar2(4000). I was suggested a PL/SQL function to check the length and build a string if necessary..
CREATE OR REPLACE
FUNCTION SUBURL(col1 IN VARCHAR2, col2 IN varchar2)
RETURN varchar2
[Code].....
Here, I got the following error,
Error(4,25): PLS-00103: Encountered the symbol "," when expecting one of the following:
:= . ( @ % ; not null range default character
View 14 Replies
View Related
Jun 27, 2012
I have built a Menu Framework using the following instructions.
[URL]........
I am facing 2 problems.
1. If the user is in a child application and clicks logout. He is taken to the login screen of the master application (Correct), but once he enters login details, he is returned to the child application (False). I think he should be returned to the Home page of the Master application.
2. If I set Session Timeouts in the Edit Security Attributes of the applications. Then if the user is timed out, he is sent to the login screen of the Master application (Correct). If he then logs in, he is sent the the Home page of the Master application (Correct).
Now if he clicks a link to a child application he is then sent back to the Master application login screen. He then has to login again. He is sent to the Master Home page and everything is then ok.
View 1 Replies
View Related
Jan 8, 2009
We can execute dynamic sql using both execute immediate and ref cursor..But what is the difference between the two and performance-wise which is better?
View 5 Replies
View Related
Jul 8, 2010
Is it possible to build index partition in parallel?I tried following command
alter index <index_name> rebuild partition <partition name> online parallel 5;
It executed without complaining, but want to know if index partitions can be build in parallel?
View 3 Replies
View Related
Oct 9, 2009
I am trying to modify an existing form in oracle apps. I copied all the necessary objects and modified the form. I can compile the object in windows. When I am trying to compile the object in Linux server using SSH I am getting the following error.
FRM-91500: Unable to start/complete the build.I am using the following command for compile
f60genm userid=apps/apps batch=yes module= FORMNAME.fmb module_type=form.
View 3 Replies
View Related
Mar 17, 2010
i have a doubt in building a query.
I have a table with fields
job_no activity Date
101 anchorage 20/01/2010
102 berthing 25/01/2010
103 sailing 29/01/2010
If i want to know the status of the ship on the date '22/01/2010' It has to show as 'anchorage', becoz on '25/01/2010' only it came to berthing from anchorage. How to write a query to achieve this.
View 12 Replies
View Related
Dec 28, 2012
I have a Linux box with the below configurations:-
Linux blrulvremoradb02 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
Last time my UNIX administrator have done a partition in this box. I have 100GB lun allocated to this box which is spilitted in two mount points.
/u01 is having 30GB and /u02 is having 70GB. I want to build a ASM in this box and install Oracle 11.2.0.1 and for that I need raw disk.
Is there any useful links or can you guide me to achieve this... My UNIX admin is on leave for new year and I want to do this by my own..
View 5 Replies
View Related
Jul 24, 2013
I have table A.Security:
CouponIssue_nameQuantity_typeCurrencySec_TypeSec_alias
1 a 56 USD AB 676
2 b 45 INR AB 143
3 c 32 JPY BA 200
and Table B.Security:
CouponIssue_nameQuantity_typeCurrencySec_TypeSec_alias
1 a 33 USD OB 676
9 b 21 NZD AC 143
8 c 19 GBP CA 200
build a Stored Proc which compares sepecific fields in the 2 tables and reports into a new table as:
A.Security.sec_aliasB.Security.sec_aliastable fieldA-valueB-value Compare
676 676 Security Currency USD USD Match
143 143 Security Currency INR NZD Not-Match
Fields to be compared are:
Quantity_type
Currency
Sec_type
The join between the tables A and B can be made on Sec_alias.Also, this is just a single pair of tables. Further I need to compare 5 more pairs of tables after this and report out of the new table.
View 23 Replies
View Related
Jun 29, 2013
I have a requirement wherein onclick of button I want to open/close list/popup (which is displayed below button, just like in select list) and can select any item from list to do some action.
View 7 Replies
View Related
Aug 24, 2012
When working in MS Access, I can build parametric queries, where I can input the date field for example at run-time. How can I do something similar in SQL Oracle
Example
SELECT Sector.Date, Sector.RNC, Sector.Site, Sector.Cell,Sector.PSC
FROM Sector
WHERE Sector.Date=[Enter Date];
View 15 Replies
View Related