Foreig Keys to different tables on the same field

Hi, respected Oracle Techs.:
My question is:
Is there a way to reference a field by Foreign Keys to two or more tables' keys in an mutually exclusive way? For example,
TABA.FIELDA references to TABB.FIELDA and exclusively,
TABA.FIELDA references to TABC.FIELDA, it means:
if child TABA.FIELDA does not exists in parent TABB.FIELDA it MUST exists in parent TABC.FIELDA and viceversa.
'One child looking for his existing parent...'
Thanks in advance.
LEONARDO.

Although I agree that combining tableB and tableC is probably the best way to go, if there is some really good reason that this cannot happen, you can use a trigger on tableA to enforce this rule. Something like:
CREATE OR REPLACE TRIGGER tableA_ref
BEFORE INSERT OR UPDATE ON tableA
FOR EACH ROW
DECLARE
l_isfound NUMBER(1) := 0;
BEGIN
   BEGIN
      SELECT 1 INTO l_isfound
      FROM tableB
      WHERE fielda = :new.fielda;
   EXCEPTION WHEN NO_DATA_FOUND THEN
      BEGIN
         SELECT 1 INTO l_isfound
         FROM tableC
         WHERE fielda = :new.fielda;
      EXCEPTION WHEN NO_DATA_FOUND THEN
         NULL;
      END;
   END;
   IF l_isfound <> 1 THEN
      RAISE_APPLICATION_ERROR (-20001,'Referential Integrity Check Failed');
   END IF;
END;The example assumes that fields unique in both tableB and tableC.
TTFN
John

Similar Messages

  • Can I display different tables at the same time?

    Hello all,
    This is probably a newbie question but is it possible to display different tables at the same time? I'm using SQL Developer 1.5.5 and I seem to be unable to display more than one table at the same time, whenever i chose to open another table, the old table disappears. In other words, the table display just switches to your new choice in the table list navigator. Any ideas anyone?
    Regards,
    wf

    Menu item "Tools -> Preferences -> Database -> ObjectViewer Parameters"; make sure "Automatically Freeze Object Viewer Windows" is checked.
    HTH.
    Ed. H.

  • Different fonts in the same field

    Is it possible to format a single field with two different fonts. I have concatenated two database columns to get this field. But I want different fonts for the two columns. I could achieve this by using a format trigger and placing some html tags. But this solution only works if the output is in HTML style sheets. It does not work if I want the output to be in PDF. Does anybody know how to achieve it in PDF? Is it possible at all (from what I have seen it isn't). I will be grateful for any help in this direction.
    Thanks
    Janaki

    Hi!
    Try this:
    Let say you have scott/tiger and emp-table and want to concatenate and print ename and job in the same field but with different fonts.
    1. In the Database model you have the columns seperate as usual.
    2. Create a boileplate text field and put &ENAME &JOB in this field.
    3. Select &ENAME and set the right font to it, set another font for &JOB.
    4. Run and test. This should work...

  • Retrieving data from different tables in the same time crash

    Hi
    this is probably the wrong way to do it, but this is how I did:
    - I wanted a screen with 3 datagrids components retrieving data from 3 different tables.
    - I could make it work while enabling 1 or 2 of them.  When the 3 are enabled, I get this error:
    btw its a huge msg, I will trim it:
    ArgumentError: Can't find ManagedQuery or ManagedOperation named: getItems_paged     at mx.data::RPCDataServiceAdapter/executeQuery()[C:\depot\DataServices\branches\lcds_modeler 101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:325]     at mx.data::RPCDataServiceAdapter/processDataMessage()[C:\depot\DataServices\branches\lcds_m odeler101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:920]     at RPCDataServiceRequest/invoke()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\ projects\data\src\mx\data\RPCDataServiceAdapter.as:1668]     at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::invoke()[C:\depot\DataServices\branches\lcds_m odeler101\frameworks\projects\data\src\mx\data\DataStore.as:3343] ...  it continues forever. 
    the getItems_paged is a auto generated function inside the php class flex generates to handle the tables.
    Each of the datagrid is a custom component. I made so to avoid keeping a bunch of code lines in the main 'page'.
    Any suggestion to make it work smoothly?
    Thanks in advance,
    btp~

    Hi
    this is probably the wrong way to do it, but this is how I did:
    - I wanted a screen with 3 datagrids components retrieving data from 3 different tables.
    - I could make it work while enabling 1 or 2 of them.  When the 3 are enabled, I get this error:
    btw its a huge msg, I will trim it:
    ArgumentError: Can't find ManagedQuery or ManagedOperation named: getItems_paged     at mx.data::RPCDataServiceAdapter/executeQuery()[C:\depot\DataServices\branches\lcds_modeler 101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:325]     at mx.data::RPCDataServiceAdapter/processDataMessage()[C:\depot\DataServices\branches\lcds_m odeler101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:920]     at RPCDataServiceRequest/invoke()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\ projects\data\src\mx\data\RPCDataServiceAdapter.as:1668]     at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::invoke()[C:\depot\DataServices\branches\lcds_m odeler101\frameworks\projects\data\src\mx\data\DataStore.as:3343] ...  it continues forever. 
    the getItems_paged is a auto generated function inside the php class flex generates to handle the tables.
    Each of the datagrid is a custom component. I made so to avoid keeping a bunch of code lines in the main 'page'.
    Any suggestion to make it work smoothly?
    Thanks in advance,
    btp~

  • Get row count for different tables to the same line

    How can I get the row count for different tables in one line:
    SELECT count(A), count(B), count(C) from table tb_a A , tb_b B, tb_c C;
    Thanks!

    >
    Hi,
    How can I get the row count for different tables in one line:
    SELECT count(A), count(B), count(C) from table tb_a A , tb_b B, tb_c C;Something like this? One of the many uses for CTE's - Common Table Expressions - AKA
    subquery refactoring. Worth getting to know - very handy!
    with acount as
      select count(*) as counta from dual  -- put your table name here
    bcount as
      select count(*) as countb from dual  -- put your table name here
    ccount as
      select count(*) as countc from dual  -- put your table name here
    select a.counta, b.countb, c.countc from acount a, bcount b, ccount c;HTH,
    Paul...
    Edited by: Paulie on 25-Jul-2012 17:44

  • How to insert a UUID into multiple tables in the same form

    I am trying to insert a UUID into 2 different tables at the
    same time ie to let this be created in the form and then insert
    this ID into 2 linked tables in a database using Access.
    Does anybody have any suggestions on how to accomplish this?
    Thanks very much

    So you have one form that processes information for two
    tables, or do you
    have two forms (one for each table - except the UUID)?
    If it is one form just run two SQL insert statements. One for
    the primary
    table, then one for the related table.
    If it is two forms run the above two SQL statements then an
    update statement
    to finish filling the second table.
    Or am I completely misunderstanding the issue?
    Bryan Ashcraft (remove brain to reply)
    Web Application Developer
    Wright Medical Technology, Inc.
    Macromedia Certified Dreamweaver Developer
    Adobe Community Expert (DW) ::
    http://www.adobe.com/communities/experts/
    "weelco" <[email protected]> wrote in
    message
    news:esjtjj$qtc$[email protected]..
    > Thanks for your quick reply, and yes I do know how to do
    that however I
    > would
    > like to do this all in one form field so I would like to
    create the UUID
    > whith
    > the same form that also submits it to another table, is
    this possible or
    > do I
    > have to do that using multiple 'pages'?
    >

  • Two forms that update differrent tables on the same page?

    I tried to add two forms that update different tables on to one page.
    Problem is when I do that the forms gives me an error saying the field does not exist. It's like it is trying to update one table with the other tables fields.
    As an example Say I have one forms that is for people table and another one that is the Jobs table.
    When I go to update the people table, it sends the data for the jobs fields too I get an error like the field job description does not exist.
    I have two different forms for these and everything.
    I would hope it is possible to have two forms that update different tables on the same page.

    I was trying the exact same thing, but i managed to work round it by setting the steps to hide one region, so the user would enter the form see one region submit the region then direct back to the same page with the different region visible and the original hidden.
    I don't know if this would be acceptable for you...

  • Using !format on multiple occurrences of the same field

    I'm trying to use the @if function to apply formatting to two occurrences of a field, but am not having any luck so far.  The specific example is that I have two check boxes on the template, and would like to have only one of them checked at a time, using the same field in my data file for both check boxes.  The field that I'm using in my data file is:
    ^field ACCOUNT_TYPE
    And the only two possible values for that field are CHECKING and SAVINGS.  On the first ACCOUNT_TYPE checkbox, I have entered the following !format:
    @(If("@_$_."=="CHECKING","X"," "))
    And on the second ACCOUNT_TYPE check box it is
    @(If("@_$_."=="SAVINGS","X"," "))
    The @if statement works fine when I apply it to only one of the check boxes, but when I apply it to both, nothing populates into the field.  A simple solution would be to change the data, but doing so is not an option in this case for me.  Any help or alternate solutions is appreciated.  Thanks!

    Hi
    I treid different combination keeping the same field name for two radio buttons but it didnt work. You can work out with an alternate solution , keep different name for two radio buttons say : JF07 & JF08
    And under JF07 for !Format event : @(If("@JF03."=="SAVING","S",""))
    And under JF08 for !Format event : @(If("@JF03."=="CHECKING","C",""))
    where JF03 is the field name which may have one of two value : i.e either SAVING or CHECKING
    So your form consits of 2 radio buttons ( JF07,JF08) and one field label JF03. In your dat file you have to refer to first radio button that appears first on the form i.e left to right or top to bottom.(So whatever radio button is appearign first in the sequence on the form from left to right use that radio button in dat file.Here its JF07)
    ^symbolset 108
    ^page 1
    ^field JF03
    CHECKING
    ^field JF07
    ==========
    ^symbolset 108
    ^page 1
    ^field JF03
    SAVING
    ^field JF07
    Hope this layman's altenate solution will give you a bit of relief.
    thanks
    jaY

  • Mix source data with different granularity into the same fact table?

    I have two transaction tables "Incident (157 columns)" and "Unit (70 Colums)". For every "Incident" that happens there could be one or more records in the "Unit" table.
    As part of my data mart design, I have merged both the tables into a single Fact "Incident Fact (227 Columns)" and inserted the records from both the tables with a join condition between them [incident.IN_NUM = Unit.IN_NUM].
    Is this correct, is my question? or am I mixing source data with different granularity in the same fact table. Appreciate your help.
    Best Regards
    Bees

    Bees,
    Are the measures from 'Incident' , repeated for a given incident where it has more than one record in the Unit table ? If so, then the sum(indicent.measure) will give an incorrect result, no ?
    What requirement is there to physically merge the tables together outside of OBIEE? With OBIEE you could have one logical 'fact' table to present to report users, which sourced from seperate Incidents and Units tables and would stop the incorrect aggregations occuring. A common modelling piece in the same way would be Order Headers and Order Lines, quite common in OBIEE to have a logical 'Orders' fact which contained both Order header measures and Order line measures, this translates to your Incidents -> Units relationship.
    To do what I've mentioned, is relatively straight forward, you need a 'Dim - Incident' with two levels, Incident and Unit, mapp the unique identifiers in as the level keys and then use these levels to set the content levels correctly in your 2 logical tables sources for logical 'Fact' , ie Incidents LTS at incident level, Units LTS as units level.
    Hope this helps, let us know if you get stuck.
    Cheers
    Alastair

  • How to sum different column in the same table

    Hi everyone
    I would like to know how can I make the sum of different column in the same table using apex
    exple:
    TR_PROJ_BIL_TRIM.ENTPIDFISC as ENTPIDFISC,
        TR_PROJ_BIL_TRIM.EXEANNEE as EXEANNEE,
        TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV as PROJBILTRIMT1PREV,
        TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV as PROJBILTRIMT2PREV,
        trunc( TR_PROJ_BIL_TRIM.PROJBILTRIMT1PREV)+(TR_PROJ_BIL_TRIM.PROJBILTRIMT2PREV)
    from TR_PROJ_BIL_TRIM TR_PROJ_BIL_TRIM
    group by TR_PROJ_BIL_TRIM.ENTPIDFISC,TR_PROJ_BIL_TRIM.EXEANNEE
    but while trying to run this script i get this error message:"ORA-00979: not a GROUP BY expression"
    thanks for reading me and I hope to hear from you soon

    Hi,
    Your question do not have anything do with APEX.
    It is pure SQL question and you will get better answer this kind questions from SQL and PL/SQL forum
    You need have GROUP BY when you use aggregate functions like SUM.
    I assume you like just add two columns.
    Try
    SELECT ENTPIDFISC
        ,EXEANNEE
        ,PROJBILTRIMT1PREV
        ,PROJBILTRIMT2PREV
        ,trunc(PROJBILTRIMT1PREV) + (PROJBILTRIMT2PREV)
    FROM TR_PROJ_BIL_TRIM
    Regards,
    Jari

  • SUM two fileds from different rows from the same table

    I would like to SUM two fileds from different rows from the same table but I don't know how to do that.
    E.g.
    BillingTransactionsIndex      CreateDate      UserType      UserIndex      TransType      Reference      Total      Balance
    2      6/5/2008 15:02      1      51      1      150      -288.2      -288.2
    5      6/8/2008 11:55      1      51      1      157      -1.58674      -289.787
    In the table above I want SUM fields Total and Balance for the first row and the the next row SUM 2nd row Total with 1st row Balance
    Please help
    Thanks

    SQL> with tbl as
      2  (select 1 as ID,  90 as total from dual
      3          union all
      4  select 2 as ID,  23 as total  from dual
      5          union all
      6  select 3 as ID,  15 as total  from dual
      7          union all
      8  select 4 as ID,  20 as total  from dual)
      9  select id , total, sum(total) over (order by ID) as balance from tbl
    10  /
            ID      TOTAL    BALANCE
             1         90         90
             2         23        113
             3         15        128
             4         20        148
    SQL>

  • How do you insert new records into multiple tables using the same unique primary key?

    I’ve created a PHP site and MySQL server using a free app called XAMPP.  I have successfully created a form in Dreamweaver that will write data to a (name) table in the SQL database.  Here’s my question: How do you write to two (or more) tables in the same database and pass the same primary key to both tables?  In the SQL database, I defined the first field as ID and set it as the primary key with auto update.  So, when you insert a new record, it creates a unique primary key for that record.  In my form, I’m capturing info that needs to be stored to two tables at the same time; a Name table and Address table. Since the Name and Address tables use the ID field as the primary key, I believe I will need to pass the ID value from the Name table to the insert of the Address table to insure they both have the same primary key, right?

    No. You probably need the primary key from one table to be a foreign key in the other tables. In any case, I believe you can use two methods to obtain the auto generated key. First with SQL:
    http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html
    And the other using a PHP function:
    http://us3.php.net/mysql_insert_id

  • UPDATING A TABLE WITH SAME INFO FROM ANOTHER TABLE ON THE SAME DB

    0down votefavorite
    I am trying to update a table with info from another table on the same db with same table name. I just want the info to be the same , no primary key or constraint involve just a straight replacement of records and I keep getting errors WITH THE TABLE not
    being recignize. below is my query:
    UPDATE
    VNDFIL
    SET EOBTYP
    =  VNDFIL.EOBTYP, 
    EDI_X12_835_VERSION =  VNDFIL.EDI_X12_835_VERSION
    FROM
    AGERECOVERY
    WHERE
    VNDFIL.EOBTYP
    = VNDFIL.EOBTYP
    AND
    VNDFIL
    .EDI_X12_835_VERSION
    = VNDFIL.EDI_X12_835_VERSION

    Hi rotary,
    If those two same named tables are in the same database then they have to be in different schemas. If you mean they are in the same server instance, then they may be in different databases, besides the "table not being recognized" error,
    anyway you should use the fully qualified table names, that is database.Schema.Table(If across instances, ServerName should be prefixed) to avoid the table unrecognized error.
    Using Identifiers As Object Names
    With the fully qualified names, your update statement can be like below.
    UPDATE
    db1.schema1.VNDFIL
    SET EOBTYP = srcTbl.EOBTYP, EDI_X12_835_VERSION = srcTbl.EDI_X12_835_VERSION
    FROM
    db1.schema2.VNDFIL srcTbl
    WHERE
    db1.schema1.VNDFIL.EOBTYP = srcTbl.VNDFIL.EOBTYP AND
    db1.schema1.VNDFIL.EDI_X12_835_VERSION = srcTbl.VNDFIL.EDI_X12_835_VERSION
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Does Pool & Cluster tables has the same structure in both Dictionary and Db

    ------------ Exists with the same structure both in dictionary as well as in database exactly with the same data and fields
    a. Pool Table
    b. Cluster Table
    c. Transparent Table
    d. All the above
    To my knowledge, I know transparent table has the same structure in both Dictionary and database.
    Can anyone tel me the answer for the above question.. whether it is
    c. Transparent table
    or
    d. All the above

    Transparent Table:
    A physical table definition in the database for the table definition which is stored in the ABAP Dictionary for transparent tables when the
    table is activated. The table definition is translated from the ABAP Dictionary to a definition of the particular database.
    A transparent table in the dictionary has one to one relationship with a table in the database.
    For each transparent table in the data dictionary there is one associated table in the database.The database table has the same name, the same number of fields and fields have same names as the transparent table definition. Transparent tables are used to hold application data. Application data is master data or transaction data used by an application.
    e.g. master data - table of customers
    Transaction data - order placed by the customers.
    Pooled tables:
    Pooled tables can be used to store control data (e.g. screen sequences,program parameters or temporary data). Several pooled tables can be
    combined to form a table pool. The table pool corresponds to a physical table on the database in which all the records of the allocated pooledtables are stored.
    Pooled table in R/3 has a many to one relationship with a table in the database. For one table in the database there are many tables in the R/3 data dictionary.R/3 uses pooled tables to hold large number of very small tables. You might create a table pool if yoou need to create hundreds of small tables that each hold only a few rows of data.
    Cluster tables :
    Cluster tables contain continuous text, for example, documentation.Several cluster tables can be combined to form a table cluster. Severallogical lines of different tables are combined to form a physical record in this table type. This permits object-by-object storage or
    object-by-object access. In order to combine tables in clusters, atleast parts of the keys must agree. Several cluster tables are stored in
    one corresponding table on the database.
    A cluster table is similar to pool table . It has many to one relationship with the table in the database.
    They are used to hold the data from a few(approximatelly 2 to 10) very large tables. They would be used when these tables have a part of their primary keys in common and if data in these tables are all accessed simultaneously.A cluster is advantageous in the case where data is accessed from multiple tables simultaneously and those tables have at least one of their primary key fields in common.Cluster table reduce number of database reads and thereby improves performance.

  • Passing different values to the same servlet

    Hi,
    Is there a way to pass different values to the same servlet?
    Background:
    I have a database that I query to acquire a list of customers, then I show each customer as a link, that when clicked will show details of that customer. (The customer table is dynamic so I can't create a new page for each customer)
    When using JSP what I do is
    //Do query database
    while (rst.next())
         String cust = rst.getString ("cust");
            out.write("<a href = \"cust2.jsp?cust=" + cust + " \" >" + cust + "</a> ");
    }Then on the cust2.jsp. I will use
    String str = request.getParameter ("cust");to acquire the customer to get details of.
    Is there a way to do the same using servlets?
    I could swap to JSP when creating this particular part of the project but it won't look good and it would help me learn a few things when there is another way.

    I want to know if there is a way to pass a variable from a webpage link like in my JSP example using servlets.
    Here is what I wanted to do:
    I have a webpage that contains customer names and each name has a link to the same servlet (let's say the link is famia/servb). I want servb to show detailed information about the customer my visitor clicked in the webpage.
    The logic I was thinking is to pass a variable to this servlet, then I can use that variable to know which customer should I query in my database. So that I can show the details to my users.
    Here lies my problem, I don't know how I can pass this variable, or even know which customer my visitor clicked. I can't use a new servlet for each client since the customer is in a database and if my customer base grows then I would need to create a lot more web page that does the same thing.
    The JSP example I gave is how I will be coding it if I am using JSP, but now I am using servlets. So I was wodnering if there is a way to do this using servlet. Or should I stay with using JSP for this particular logic and just call servb after the JSP page acquired the variable.
    I'm trying not to use "<original URL> + ? + <variable> = <value>" (eg: http://www.famia.net/customer?cust=famia) as the means for passing the variable. (or in the example as a means of passing variable cust with value famia)

Maybe you are looking for

  • Creating interactive buttons using images

    Background: I am trying to teach myself Java at home, since I lack the funds to take even a "community college" course. I understand a lot of the basics and can write various methods which work nicely, but I am stumbling a bit on understanding how to

  • Procedure timed out?

    We currently have a procedure that pulls data from other databaselink. This procedure takes quite a long time (2 hours+) to process and dump the data into one table. The user gets the browser timed out. Here are my questions: •     What happens to th

  • Changing Label of a Screen Fields

    In my FPP1 transaction, I want to use Other Last Name as Father's Name. How can i change the display text. I just want to change the display text. I have tried changing the Label through SE63 Transaction. But It does not reflect On the Screen.

  • Update display name of approval/request to something sensible

    I'm trying to update the display name / request summary to something that's easy to understand to the approver. Their is currently no template meachanism to support this. I've tried to update the request's displayname in a workflow activity, however

  • Updating iphone problem

    im updating the iphone 4 to ios 6.1.3 and it apper error (14) and i don,t know what to do i need an answer information about the device ios 4.3.3 iphone 4