Trigger Query

Hi All,
I need help with the below scenario.
My requirement is to create an insert and update trigger on table say 'product_config'. Insert trigger works as expected but there is some issue with delete trigger.
Insert trigger will check if the product_id is already present in the setup table. If yes, then it will not do anything else it will insert the product_id and sub_prod_id in the setup table.(This way there will always be unique records in setup table)
In product_config table, there can be same product_ids with different seq number as illustrated below.
Delete trigger will check if the product_id of the row which is being deleted is there in any other row in product_config table. If yes, no data is deleted from setup else delete the product_id/sub_prod_id from setup.
Sample Data:
create table product_config(seq number not null,product_id char(5) not null,sub_prod_id varchar2(5));
alter table product_config add constraint pk_product primary key(seq);
create table setup (product_id varchar2(5) not null);
alter table setup add constraint pk_product1 primary key(product_id);
create or replace trigger insert_trigger
after insert on product_config
for each row
declare
v_count number:=0;
begin
select count(*) into v_count from setup where product_id=:new.product_id;
if v_count=0 then
insert into setup values(:new.product_id);
end if;
select count(*) into v_count from setup where product_id=:new.sub_prod_id;
if v_count=0 then
insert into setup values(:new.sub_prod_id);
end if;
end;
create or replace trigger delete_trigger
after delete on product_config
for each row
declare
v_count number:=0;
PRAGMA AUTONOMOUS_TRANSACTION;
begin
select count(*) into v_count from setup s,product_config p where s.product_id=p.product_id and p.product_id=:old.product_id;
if v_count=0 then
delete from setup where product_id=:old.product_id;
end if;
select count(*) into v_count from setup s,product_config p where s.product_id=p.product_id and p.product_id=:old.sub_prod_id;
if v_count=0 then
delete from setup where product_id=:old.sub_prod_id;
end if;
commit;
end;
insert into product_config values(1,'12345','ABC');
insert into product_config values(2,'12345','BCD');
insert into product_config values(3,'12345','CDE');
insert into product_config values(4,'12345','DEF');
commit;
Once the above insert statements are executed, insert_trigger fires and data in setup table is as below
select * from setup;
12345
ABC
BCD
CDE
DEF
Now when I try to delete the rows one by one.'12345' is not getting deleted frm setup table.
Example:
delete from product_config where seq=1;---ABC gets deleted... FINE
delete from product_config where seq=2;---BCD gets deleted... FINE
delete from product_config where seq=3;---CDE gets deleted... FINE
delete from product_config where seq=4;---DEF gets deleted... FINE BUT 12345 should also get deleted as there is no other record of this product_id which is present in product_config.
Please advice.
Thanks
Dave

>
delete from product_config where seq=4;---DEF gets deleted... FINE BUT 12345 should also get deleted as there is no other record of this product_id which is present in product_config.
>
No - it should not get deleted by your code since there IS a record for DEF when your code checks.
>
select count(*) into v_count from setup s,product_config p where s.product_id=p.product_id and p.product_id=:old.product_id;
if v_count=0 then
delete from setup where product_id=:old.product_id;
end if;
>
The above code attempts to delete the PARENT record. The next code will delete the CHILD record.
So for the last delete of DEF the code determines that there IS still a child record DEF for parent 12345 and does not delete the parent.
Then your code deletes the CHILD record for DEF leaving the parent without any children.
You need to delete the children first - then if there are no children left delete the parent.
The use of an AUTONOMOUS transaction will also cause problems. If you do a DELETE of a record but then ROLLBACK that delete the trigger will still execute and delete the child and maybe the parent anyway.
NEVER perform non-transactional operations in a trigger. NEVER.
See my reply Posted: Mar 20, 2012 7:37 PM in this recent thread and be sure to read the last reply by an expert whose name you will recognize
Re: Procedure calling Inside a trigger
>
repetition is the key to success.
repetition is the key to success.
did I mention:
NEVER do anything non-transactional in a trigger (with the glaring exception of an autonomous transaction used to log and error message in a table - that is the ONLY valid use of autonomous transaction in any context I've ever seen - an error logging routine)
The original poster should
a) probably not use a trigger
b) definitely not use an autonomous transaction

Similar Messages

  • Trigger query not executed and havenot any exception

    Hello all,
    I am using oracle 10g lite database, and i m firing a create trigger query, but it is not executed on console, when i try at console at this trigger query after that no one query will fire,
    Plzzzzzzzzzzzzzzzzzzz help me
    my used table is
    1. create table t1 ( c1 int, c2 int);
    2. create table t2 (c1 int, c2 int);
    3. Create trigger System.check after insert on system.t1 For each Row begin Insert Into system.t2 ( c1,c2 ) Values (1,1) ;end ;
    Thankx in advance
    Pankaj

    Triggers are supported on the client side in newer versions:
    11.2.1 Creating Java Stored Procedures
    To create a stored procedure, perform the following:
    1.
    Create the class that you want to store in Oracle Database Lite. You can use any Java IDE to write the procedure, or you can simply reuse an existing procedure that meets your needs.
    When creating the class, consider the following restrictions on calling Java stored procedures from SQL DML statements:
    When called from an INSERT, UPDATE, or DELETE statement, the method cannot query or modify any database tables modified by that statement.
    When called from a SELECT, INSERT, UPDATE, or DELETE statement, the method cannot execute SQL transaction control statements, such as COMMIT or ROLLBACK.
    Note:
    Any SQL statement in a stored procedure that violates a restriction produces an error at run time.
    2.
    Provide your class with a unique name for its deployment environment, since only one Java Virtual Machine is loaded for each Oracle Database Lite application. If the application executes methods from multiple databases, then the Java classes from these databases are loaded into the same Java Virtual Machine. We recommend that you prefix the Java class name with the database name to ensure that the Java class names are unique across multiple databases.
    3.
    If you are executing any DML statements in your Java stored procedure, then—in order for these statements to exist within the same transaction—you must pass an argument of type java.sql.Connection as the first argument in the method. You must have the Connection object in order to prepare and execute any statements. Oracle Database Lite supplies the appropriate argument value of the Oracle Lite database Connection object for you; the application executing the method does not need to provide a value for this parameter.

  • Sql server 2008/2012 Trigger Query

    
    Hi All,
    I am trying to create a SLQ server trigger so that when TAS1 code is 003 then change the HRSCODE to OTHR. Would anyone be able to provide me with a sample code as to do this please ?

    Are you looking for something like the below code
    IF OBJECT_ID('EMPLOYEE') IS NOT NULL
    DROP TABLE EMPLOYEE
    GO
    /* Create employee table if it does not exist */
    CREATE TABLE EMPLOYEE
    EMPID INT PRIMARY KEY,
    FNAME VARCHAR(25),
    LNAME VARCHAR(25),
    GO
    /* Populate employee table with sample rows */
    INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME)
    VALUES (500, 'John','Smith'),
    (501, 'Alex','Admas'),
    (502, 'Eric','James'),
    (503, 'Shaun','Marsh')
    GO
    /* See the table records from both tables. We have four rows in both tables */
    SELECT * from EMPLOYEE
    CREATE TRIGGER TRG_InsertSyncEmp
    ON dbo.EMPLOYEE
    AFTER INSERT AS
    BEGIN
    UPDATE T1
    SET FNAME='Jayaram'
    FROM EMPLOYEE T1 WHERE EMPID=(SELECT EMPID FROM INSERTED where FNAME='Prashanth')
    END
    GO
    INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME) VALUES (505, 'Prashanth', 'jayaram')
    select * from EMPLOYEE
    --Prashanth

  • On Insert Trigger Query

    Hi All,
    I have a procedure which inserts records in table A .
    Without changing the procedure I want to check if new record inserted by procedure is existing in table B. If exists in table B skip the record.
    Can somebody please advise me the best practice in the situation .
    Thanks

    Example :
    --Session 1
    SQL> create table table1 (id number);
    Table created.
    SQL>
    SQL> create table table2(id number);
    Table created.
    SQL>
    SQL> insert into table2 values (1);
    1 row created.
    SQL>
    SQL>
    SQL> create or replace trigger table1_trg
      2  before insert or update on table1
      3  for each row
      4  declare
      5  duplicate EXCEPTION;
      6  ct number;
      7  begin
      8      select id into ct from table2 where id=:new.id;
      9      raise duplicate;
    10      exception when no_data_found then null;
    11                when duplicate then raise_application_error(num=>-20001, msg=>'Record key is already in table2');
    12  end;
    13  /
    Trigger created.
    SQL> 
    SQL> select * from table1;
    no rows selected
    SQL> select * from table2;
            ID
             1
    SQL> insert into table1 values (1);
    insert into table1 values (1)
    ERROR at line 1:
    ORA-20001: Record key is already in table2
    ORA-06512: at "H89UCBAC.TABLE1_TRG", line 8
    ORA-04088: error during execution of trigger 'H89UCBAC.TABLE1_TRG'
    --You're happy, you have an error as you want
    SQL>
    SQL> insert into table1 values (2);
    1 row created.
    --You're happy, it works because id=2 is not into table2
    SQL>
    SQL> select * from table1;
            ID
             2
    SQL> select * from table2;
            ID
             1
    SQL> commit;
    Commit complete.
    Session 1 Add a value in table2
    SQL> insert into table2 values (3);
    1 row created.
    Session 2 Add a value in table1
    SQL> insert into table1 values (3);
    1 row created.
    Session 1 commit
    SQL> commit;
    Commit complete.
    Session 2 commit
    SQL> commit;
    Commit complete.
    --Unfortunately, I have the id=3 in the two tables
    SQL> select * from table1;
            ID
             2
             3
    SQL> select * from table2;
            ID
             1
             3
    SQL>
    SQL>
    SQL> To resume, it's better to implement the control on application level.
    Nicolas.

  • How to activate JDBC debugging for SPRING 3.1? Oracle trigger problems ...

    Hi,
    I have some trigger problems. I created a trigger to update a certain column each time a new record is inserted or an existent record is updated. I use Oracle 10g. If I create the trigger and execute an insert query via the XE client everything works fine. However, when I use a spring 3.1 setup with Hibernate and OJDBC driver, I get an
    java.sql.SQLException: ORA-04098: trigger 'LOCALUSER_PROP_TRIG' is invalid and failed re-validation
    And if I execute a show error trigger query I get an invalid SQL query error.
    I can easily activate Hibernate debugging and I can see that the prepared statement by Hibernate is just fine, but I was wondering if I could see the full sql sent by the JDBC driver to the server. Maybe seeing the actual query sent to the server would provide new insight of what could be wrong in the Hibernate setup. Does any one what could be wrong and eventually how could setup jdbc to output debug info? Thanks a lot,
    Cristian

    Which platform is the database running on ??
    Other things you should check -
    when debugging the EJB, JDev
    3.1 looks through your IIOP connections to find the one to use.
    Make sure that the IIOP connection that JDev is using for the debugging matches the IIOP connection that the EJB client application is using.
    raghu
    null

  • Approval Query for AP Invoices Containing Budget Related GL Account

    Hi Experts,
    I would like to create a approval template for all AP invoices that include a GL account that is related to the budget. Can you please help me with the approval query?
    Thank you!
    Jane

    Hello Gordon Du,
    "B1 approval will only apply to document level. If you want to check line level, only the first line can be subjected to."
    I was thinking to trigger the approval process based on a document (AP invoice) containing relevant cost centres on a line by line basis as entered via one of the enabled dim fields.
    Writing a trigger query for each cost centre effected? This does not appear to be a good solution, what is a better direction. Is there another way? (PO are not yet used via SAPB1)
    Currently my invoices add, but do not trigger the approval process based on my attempts thus far.
    Can the originator manually choose an approval pathway?
    If this is against posting etiquette delete and advise.
    I am a relative newbie to SAP B1, so am happy to be pointed to relevant help files. I arrived via  google searching and arrived here.
    Thankyou.

  • Explain Plan for Procedure

    Hi,
    For getting the explain plan for a query, we use the statement
    "explain plan for " + Query
    Similarly, to get an explain plan for a procedure, do we have any way like
    "explain plan for " + "Execute " + Procedure
    How do we get an explain plan for a procedure that is executed
    Thanks in Advance.

    teckfreak wrote:
    Hi Robert,
    I am working on an utility application which will execute the procedure and show the explain plan to the user for him to analyze the explain plan and take necessary steps for optimization. I am showing the Procedure inputs to the user, allowing him to enter values and taking them and executing the procedure. I am setting the trace and extracting the explain plan for the procedure using TKPROF utility and showing it to the user.
    While doing so, the trace file is stored in udump folder. I am accessing the trace file from TKPROF utility. I am able to run the TKPROF from the command prompt. But if I try automating the TKPROF command in a .NET application using Process.Start, it says "Not able to access the file.". I tried giving full permissions to Everyone and it still throws the error. Kindly guide me how to proceed.. A different approach that you might want to consider (as indicated by William):
    - Flush the shared pool and use a unique MODULE description for each execution of your procedure (e.g. using DBMS_APPLICATION_INFO.SET_MODULE), e.g. using a logon trigger
    - Query V$SQL for your unique MODULE description and run DBMS_XPLAN.DISPLAY_CURSOR for each corresponding child cursor found (SQL_ID + CHILD_NUMBER) in the shared pool. This plan generation could be automated using a procedure
    The result of this approach corresponds to the tracing using TKPROF since it will provide the actual execution plans used at runtime rather than separate EXPLAIN PLAN results which might differ from the actual plans.
    This assumes that your shared pool is sufficiently large to hold all the child cursor created by your procedure without aging them out while the procedure is running. It's probably also only applicable to an environment where not too much work is being done while running this test and the recommended flushing of the shared pool.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Call_form problem oracle form 10g

    Hi,
    We create some forms. Next Using Call_form in menu bar we call another form, next we call another form.
    Example:
    Form A -> Form B -> Form C
    It's working fine.
    But, 'Form C' did not retrieve all data.
    EXAMPLE:
    'WHEN-NEW-FORM-INSTANCE' - TRIGGER
    Query : "SELECT NO, NAME, MOBILE INTO :EMP.NO, :EMP.NAME, :EMP.MOBILE FROM EMP".
    The above query did not work. Only Display First Record, First Column Data(:EMP.NO).
    If i open the same 'Form C' in directly. It's working fine.
    What is the problem? How can i solve this problem?

    I try Your Solution, it's not working.
    Code:
    Declare
    CURSOR PRE_CUR IS
    SELECT PRE_CHAR_PRODUCT_MASTER,
    PRE_NO_PRODUCT_MASTER,
    PRE_CHAR_CUSTOMER_MASTER,
    PRE_NO_CUSTOMER_MASTER
    FROM PREFIX_MASTER;
    ITEM1 NVARCHAR2(100);
    ITEM2 NUMBER;
    ITEM3 NVARCHAR2(100);
    ITEM4 NUMBER;
    BEGIN
    OPEN PRE_CUR;
    FETCH PRE_CUR INTO ITEM1, ITEM2, ITEM3, ITEM4;
    :PREFIX_MASTER.PRE_CHAR_PRODUCT_MASTER := ITEM1;
    :PREFIX_MASTER.PRE_NO_PRODUCT_MASTER := ITEM2;
    :PREFIX_MASTER.PRE_CHAR_CUSTOMER_MASTER := ITEM3;
    :PREFIX_MASTER.PRE_NO_CUSTOMER_MASTER := ITEM4;
    CLOSE PRE_CUR;
    END;
    . I have another form. In this form Master/Detail . Detail have 6 Column.
    When i click 'When-Button-Pressed' Trigger. I am using Cursor(Select Statement) and FOR Loop(Fetch data to fields).
    The Detail block only display first 2 column data.
    If i open same Form, directly(Using Form Builder) , it's working fine. Retrieve all record and displayed all column.
    Why? How to solve this problem.

  • POPULATE_TABLE

    Hi, the forms procedure POPULATE_TABLE is automatically invoked within the block trigger (QUERY-PROCEDURE) when querying procedure based blocks. This procedure fails when an empty recordset is returned.
    To aviod this error, in these cases I return a null record. This in turn causes problems with the update/insert procedures (as now this record is modified as an update - rather than insert procedure when changes are made to it).
    I have worked around this problem but wonder whether there is something I am un aware of which would simplify the problem.
    TIA
    DG

    Using DefaultTable model you have addRow
    DeleteRow methods.
    http://www.codetoad.com/java_jtable.asp
    There in createBlankElement() method
    7 blank values are for 7 columns. Just
    put your database values there.

  • Help with INSERT INTO ... RETURNING ... INTO ...;

    Hi,
    I have 2 tables. In 1st one, I insert a record, and a PRE-INSERT based trigger modify value of columns CODE. I then need to insert a record in my 2nd table with the value insert in TABLE1.CODE (FK/PK). I tried to use returning clause like this :
    PROCEDURE CONVERTIR_DOCVENTE(PCODE IN CHAR) IS
    VCODE TABLE1.CODE%TYPE;
    BEGIN
    INSERT INTO TABLE1 ... RETURNING CODE INTO VCODE;
    INSERT INTO TABLE2 VALUES(VCODE);
    END;
    It does not work (ORA-00933: SQL command not properly ended at line 4)
    any idea ?
    null

    TABLE1 : CODE CHAR(10) PK,DESIG VARCHAR2(100)
    TABLE2 : CODE CHAR(10) PK,TABLE1_CODE CHAR(10) FK,DESIG VARCHAR2(100)
    Both have a sequence on CODE
    I need to insert in TABLE1 'My master record' and in TABLE2 'Child record 1' and 'Child record 2'.
    When I insert 'My master record' in TABLE 1 (INSERT into TABLE1(DESIG) values('My master record')), a trigger query my sequence and fetch CODE column. When I then insert 'Child record 1' and 'Child record 2', I need to know the value inserted in TABLE1.CODE to insert it in TABLE2.TABLE1_CODE (INSERT into TABLE2(TABLE1_CODE,DESIG) values(??????,'Child record X')). That's why I need to use RETURNING clause in the first INSERT order.
    But it doesn't works (ORA-00933: SQL command not properly ended at line 4)
    Note : All my orders are in a stored procedure.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Riaz Shahid ([email protected]):
    Hi!
    Would u clearifiy ur point please so that i can advise you. Feel free to mail me.
    Regards
    <HR></BLOCKQUOTE>
    null

  • URGENT!!passing variables to ref-cursor stored procedures

    I have build forms6 block base ona stored procedures with ref
    cursor.
    But....it's impossible to pass variables from block.item to
    in-out parameter of ref cursor..to make a where clause for
    example!!
    I've tried all..but nothing happens..
    Can someone help me?
    Thanks..
    null

    Manish Wadhwa (guest) wrote:
    : Gigi (guest) wrote:
    : : I have build forms6 block base ona stored procedures with ref
    : : cursor.
    : : But....it's impossible to pass variables from block.item to
    : : in-out parameter of ref cursor..to make a where clause for
    : : example!!
    : : I've tried all..but nothing happens..
    : : Can someone help me?
    : : Thanks..
    : >>
    : It is not possible to send values as parameter to the stored
    : procedure because, oracle uses the trigger query-procedure for
    : calling the stored procedure and it does not entertain any
    : changes to that trigger. This is a problem with block based on
    : stored procedure, we have also tried it with table of records
    : instead of ref cursor, but doesn't work.
    : Manish
    Thanks Manish..
    i was afraid about that..
    But ..i ask to myself(retoric question..) it's possible the
    development oracle team build a "black box" like a stored
    procedure with ref o table of records who permit to select
    million of records in few second( i selected 5 million of records
    in 2 seconds..) and cannot permit to passing variables to these
    cursor.. every end users production forms must be working in
    this way..I don't understand..
    Gigi
    null

  • Multiple Rows Update / Refresh Toplink Query when database trigger involved

    Hi everybody!
    I have two easy troubles for you; the platform is the same as the SRDemo Toplink version.
    1.     Multiple Rows Update: I want to update with mergeEntity method, multiple rows for an isolated table; that method receives a parameter that I try to bind with the iterator "dataProvider" but it only merges the first row, not all, any other combination returns an error.
    What I want to do is to have a form (like tabular forms in Apex) that lets me update multiple rows in a single page. ¿May anyone tell me how to do it?
    2.     Refresh Toplink Named Query: I have a list on a page with two columns. From another page, a button does an action that fires a database trigger that updates one of the columns on the list´s page. When I go back to the list, it is not updated; however, the CacheResults´s property is set to false on the iterator.
    Thanks in advance,
    Alejandro T

    I didn't use it (yet), but - you might take a look. You'll find a [url http://www.oracle.com/technetwork/developer-tools/apex/application-express/apex-plug-ins-182042.html]Timer plug-in on this page. It is a dynamic action which allows you to periodically fire other dynamic actions in the browser. For example use the timer to refresh a region every five minutes. You can perform any dynamic action you want using this infrastructure.So I was thinking: you might use it to run a dynamic action which would check whether something changed in that table (I suppose you'll know the way) (for example, a database trigger might set a flag in some table, timestamp or similar), and - if you find that something really changed - refresh the page.
    As I said, I never used it so that's pure theory. Someone else might know better, though.

  • Post query trigger problem in master detail oracle forms

    Hello experts,
                        I am new in oracle forms n using Fission middleware 10g with oracle forms 11g at windows 7 platform.
    I have made a master detail form using a tab canvas.There is a database column STUDENTID and it is in my student tab with a TBL_STUDENTENTRY data block.Now I Have an another tab named previous_education with TBL_STUDENT_PREVIOU_EDU datablock here there is also a database column STUDENTID and corresponding field in my  previous_education TAB under TBL_STUDENT_PREVIOU_EDU  datablock.Now i want to add a display item to show  student name corresponding to STUDENTID.For this I have tried to make a select query in TBL_STUDENT_PREVIOU_EDU data block POPST_QUERY TRIGGER.
    begin
    select STUDENTNAME into :TBL_STUDENT_PREVIOU_EDU.STD_NM   from TBL_STUDENTENTRY where STUDENTID=:TBL_STUDENTENTRY.STUDENTID;
    end;
    But, This trigger is not fired at runtime,Please suggest me what is going wrong and give me the solution.
    Thank You
    AADITYA.

    http://www.club-oracle.com/forums/post_query-problem-in-oracle-forms-t9751/#post23794 ,  This is the link at where  I have tried to show my problem with the help of an image,Please get the link:
    thanx
    regards Aaditya.

  • Master-Detail Form - implementing some thing like Post-Query trigger

    Hi all,
    I am struggling to implement an eqivalent of a post-query trigger in Oracle Forms. Please bear with me as I am trying to explain in detail what the problem is.
    Here is my situation.
    I have three tables EMP, DEPT and LOCATION. I created a Master/Table pages on EMP and DEPT.
    Basic relationships.
    Each LOCATION has one or more DEPTs; Each DEPT is at one and only one LOCATION.
    Each DEPT has one ore more EMPs; Each EMP is assigned to only and only DEPT.
    Not getting too complicated, here are the table layouts:
    LOCATION:
    ID number(10,0) not null,
    NAME varchar2(20) not null
    DEPT
    ID number(10,0) not null,
    NAME varchar2(20) not null,
    LOC_ID number (10,0) not null foreign key from LOCATION
    EMP
    ID number(10,0) not null,
    NAME varchar2(20) not null,
    DEPT_ID number (10,0) not null foreign key from DEPT
    Assume I have all the constraints, BIU triggers, sequences defined properly.
    I am using the APEX page wizard to create a Master/Detail Form on DEPT and EMP. The first page is the Master Report on DEPT. I want to display the Location Name on this page also. Because the Master Report allows
    you to change the query, I was able to add the Location Name as part of the
    query. This was very simple.
    Select a.name "Department_Name",
    b.name "Location"
    from dept a, location b
    where a.loc_id = b.id
    Moving on, In the Master Detail Form, I would like to get the Location Name as part of the first Region (Dept Region).
    In this region, I would like to include the Location Name also. So my first region on the Master Detail form includes:
    Dept Id: ________
    Dept Name: _______
    Location Name: __________
    As Region are automatically populated using using a Fetch Row from EMP table (Automated Row Fetch) on an After Header process point, I don't have a way of including the Location as part of query. So I created a Region level Item called Location Name, made it Display only.
    In the old SQL*Forms, or Oracle Forms days, I used to use a Post-Query trigger, or Post-Change trigger to fire on the Loc_Id column to populate the Location Name. Simple fetch like:
    Select name
    into :P80_location_name
    from location
    where loc_id = :P80_loc_id
    However, I am struggling to implement some thing simple like this in APEX. Tried creating a processes, computatations etc, but nothing is working.
    I have seen some previous responses to fetching values from a foreign table
    using a button or AJAX script, but this should be very basic. What am I
    missing here?
    Appreciate any insights.
    Thanks.
    John

    Hi John,
    I'm not too familiar with the post-query triggers in Oracle Forms, but the use of a List of Values (LOV) on your LOCATION table might do the trick for you. If you create a dynamic LOV based on your LOCATIONS table, it can then be referenced by the LOC_ID item on the Master-Detail page, to display the Location Name. You could try doing the following:
    1. Create a new dynamic LOV, LOCATIONS, using a query similar to the following:
    select Name d, ID r
    from LOCATION
    order by 1
    2. Edit the "Create" button on the Master report page, and in the "Optional URL Redirect" section set "Request" to CREATE. Click Apply Changes, to save the setting.
    3. Edit the LOC_ID item on your Master-Detail page, and set the following:
    * in the "Name" region change the "Display As" setting to Select List
    * in the "Label" region change the Label to Location Name.
    * in the "List of Values" region set the "Named LOV" to LOCATIONS
    * in the "Read Only" section, set the condition to Request != Expression 1, and set Expression 1 to CREATE.
    Click Apply Changes to save the settings.
    When you run the pages now, the Location Name field will appear as Read-Only when editing a selected Master row. The item will appear as a Select List when the user clicks "Create" on the Master page, to create a new Master row.
    I hope this helps.
    Regards,
    Hilary

  • Why same query runs on isqlplus but not in Forms/Reports trigger

    Hi,
    I have one query in which I extract one column with parent table join if I run same query on isqlplus prompt it works but if I run same on Forms/Reports trigger it says found "select" where something else expected.
    below is an example .
    select em1.mreading, em1.grid_code,
    (select em.mreading from energy_mreading em where em.grid_code=em1.grid_code and em.transformer_code=em1.transformer_code
    and em.bus_bar=em1.bus_bar and to_date(to_char(em.r_date,'dd/mm/yyyy'),'dd/mm/yy') = to_date('02/01/07' ,'dd/mm/yy') - 1)
    as Yreading
    from energy_mreading em1
    where to_date(to_char(em1.r_date,'dd/mm/yyyy'),'dd/mm/yy')= to_date('02/01/07' ,'dd/mm/yy')
    Any one can help me, is there any restriction/limitations in Forms/Reports triggers.
    Thanks, Khawar.

    In forms and cursors you can not use scalar subqueries as you do. You have to use joins!
    select
         em1.mreading
        ,em1.grid_code
        ,em.mreading as Yreading
    from
        energy_mreading em1
       ,energy_mreading em
    where 1=1
        and trunc(em1.r_date) = to_date('02/01/2007','dd/mm/rrrr')
        and em.grid_code = em1.grid_code
        and em.transformer_code = em1.transformer_code
        and em.bus_bar = em1.bus_bar
        and trunc(em.r_date) = trunc(em1.r_date) - 1
    Try this, hope it works.

Maybe you are looking for

  • Lightroom 5 key doesn't work

    I have purchase Lightroom5 upgrade version for MAC and just re-install my mac and install lightroom5. however, it said my key doesn't work. should i install lightroom 3 then install lightroom5 upgrade version instead of install lightroom 5 directly?

  • Managing a mailing list in numbers. Duplicate Entries?

    Hi Everyone- I'm a newbie to these forums, and have done a brief search but didnt seem to find anything relevant, but if anyone can point me in the right direction, I would be most grateful. I have been using Numbers to manage a large mailing list of

  • Layout generation with VSS

    Hello all, I am in the process of designing a phase locked loop based frequency synthesizer. I successfully simulated the PLL. The PLL chip was simulated using the Phase frequency detector/charge pump and the divider provided in VSS element browser.

  • May i know how to copy music from my computer?

    may i know how to copy music from my computer to ipad?

  • Silverlight plug-in problem

    Have just downloaded Silverlight which appeared to install OK but when I try to run it I get a window that says "need to check that the programme will work" but this step had already been completed during the installation. Has anyone got it to work?