Several FKs to the same table

Hello,
I have a master table with several Forign Keys – all of them to the same table. In order to display a column from the lookup table I'm using a select like:
select     m.code,
     m.lcode1, f1.label,
     m.lcode2, f2.label,
     m.lcode6, f6.label
from       MTABLE m,
     FTABLE  f1,
     FTABLE  f2,
     FTABLE  f6
Where      m.lcode1 = f1.code  and
     m.lcode2 = f1.code and
     m.lcode6 = f6.codeIs this the correct and optimal way of doing it?
Thanks for the help,
Arie.

Arie,
It sounds like perhaps the best way might be to create your forms/reports based upon a view instead of the underlying tables (especially if you are running 10gR1 or 10gR2).
I say this because:
1. With 10g (maybe even back in 9i?), you can create INSTEAD_OF triggers, so instead of manipulating (insert, update or delete) the view, the trigger has the code to perform the action to the underlying base tables instead.
2. This makes development easier, since all your joins are pre-defined in one place instead of re-creating them in numerous places.
3. Grants can be issued to the views, instead of the various tables, with just select privs to the lookup tables.
4. Change your join conditions to use the JOIN syntax, LEFT OUTER JOIN, etc., whatever is appropriate for your query. It's much easier to (eventually) figure out and maintain when you have multiple join conditions (especially against multiple tables), when any or all of them could null.
For details on the JOIN syntax or the INSTEAD_OF triggers, try the on-line Oracle documentation (I'm at home today and don't have all my reference material handy).
I'm using the above with great success (so far). I'm swamped with different work projects and different bosses and different priorities, so anything that makes my life easier is worth a couple hours of research, even if I have to do it from home in my off-time (if I can fit it into my schedule). I've been working on an HTMLDB (AppEx) application for over a year now, but I've probably only spent about 40-60 hours actually working on it, so I'm always forgetting most of what I've previously learned and done.
Bill Ferguson

Similar Messages

  • Compare several records in the same table

    Hello, i´m writing a BAT file so i can export some information that i query.
    I have a automatic integration that from time to time checks if there is any new client´s and generates a trigger.
    If an error ocurs i it will repeat the process until the client is in the database.
    I cannot create tables or modify structure.
    My problem is that i need to compare the most updated record with the field CLIENT_ID
    Let me give up an example:
    Table A
    CLIENT_ID CREATEDTIME ERROR_MESSAGE
    0 01-01-2009 Sucess
    1 01-01-2009 Error
    2 01-01-2009 Sucess
    1 02-01-2009 Sucess
    3 02-01-2009 Sucess
    4 02-01-2009 Error
    I need to compare client "1" created on 01-01-2009 that gived Error with all new records to see if is Sucess and my
    query should only return the client_ID "4" and export with sqlplus
    Could you please help me out?

    with my_tab as (select 0 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
                    select 1 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Error' error_message from dual union all
                    select 2 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
                    select 1 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
                    select 3 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
                    select 4 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Error' error_message from dual)
    -- end of test data set up to mimic a table called "my_tab"
    select client_id
    from   my_tab
    group by client_id
    having max(decode(error_message, 'Error', 1, 2)) = 1;should do what you want.
    Edited by: Boneist on 05-Jan-2009 16:06
    Hmm, not quite.... thinking of an amendment if the answer to BluShadow's question is Yes
    Aha,
    with my_tab as (select 0 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
                    select 1 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Error' error_message from dual union all
                    select 2 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
                    select 1 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
                    select 3 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
                    select 4 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Error' error_message from dual union all
                    select 1 client_id, to_date('03/01/2009', 'dd/mm/yyyy') createdtime, 'Error' error_message from dual)
    -- end of test data set up to mimic a table called "my_tab"
    select client_id
    from   my_tab
    group by client_id
    having max(decode(error_message, 'Error', 1, 2)) keep (dense_rank last order by createdtime) = 1;(which happens to be a more generalised form of what Frank's posted below!)

  • Several chain steps loaing the same table

    I have several files coming from different places that my chain will use to update a table. I have set up a file arrival event for each file, so that when it arrives it is loaded into the same table. The problem is i don't know when each file will be arriving. What's the best way to setup the job chain so there aren't several loads to the same table happening at the same time?
    thanks.

    hi,
    Maybe it is possible to use dbms_lock to restrict access to the table to only one loading step at a time e.g. instead of loading the table, first get a lock, then load into it, then release the lock.
    I can't think of how to set this up cleanly using chain logic.
    -Ravi

  • Several dates in the same field and table

    Hey!
    I need dates of different work phases, in order to calculate the duration of each phase separately in SAP-Query. The dates are situated in the same tables and fields (f.ex. actual start dates of work phase 1, phase 2, phase 3, etc. are all located in table AFVV and field ISDD). But I need them separately. So is the only option to create separate fields for the dates of each work phase?
    Maria

    Hi
    SDN is itself a one-point source for anything related to SAP. (You can check eLearning etc for the same)
    But still, here is one for you to start learning ABAP [http://abap-gallery.blogspot.com/2007/07/step-by-step-learning-abap.html|http://abap-gallery.blogspot.com/2007/07/step-by-step-learning-abap.html]
    Regards
    Raj

  • How do I sum across the same table in multiple sheets?

    So I'm trying to figure out an annoying problem.
    I have a largish (100's) amount of data with each collection being a table in a sheet, one sheet per data collection. This means I have 100's of sheets, each with the same table name and layout. Each sheet has several hundred data points in it.
    How do I do a sum across all of the same table in all the sheets?
    For example I want to do Sum('Data Sheet Number *'::'Table 1'::A1) to get a sum of everything in all the A1 cells of all the sheets named 'Data Sheet Number ' followed by anything (I'm using the star in the same way one would do it in a shell...)
    Thanks!
    Message was edited by: unusedusername
    Message was edited by: unusedusername

    To respond to WWJD: I was handed the data and I don't have any control over it's format...
    I found the answer in the forums though, so I guess I'm answering my own question
    http://discussions.apple.com/thread.jspa?messageID=6203991&#6203991
    The auto-filling INDIRECT reference worked very well for me.

  • SMQ2 Error :Several modes with the same number  at activity 2N

    Hi,
    We have some Ques stuck in APO inbound "Several modes with the same number  at activity 2N". Can anybody help me to fix this.?
    Sameer.

    Hi Sameer, indeed your issue seems to be linked to PDS creation. Your PDS CIF jobs must be failing if I am not wrong.
    You would need to identify which PDS in APO (or which version in R/3) has issues.
    Go to CQ transaction mentioned earlier, select teh row containing the issue, and then click on the display icon on the right side top. This will show you the entries in the internal tables taht were being passed on in the CIF.
    From here, you need to identify the production version from R/3 that is having issue. I don't have a stuck queue at hand, so can't tell you which table would contain information. Somewhere you would find out the name of the product/location that is having issue, and then you need to check what is the issue with the version. Seems the same mode is being used multiple times in some activity, or in R/3 side, the same resource is being used multiple times in a single activity.
    Thansk - Pawan

  • Selecting specific records out of the same table with PICS

    Post Author: nambi
    CA Forum: Formula
    I have a Database table in which we have information for our paint codes,
    This database when accessed through our will display the types of tests we do for the products we manufacture, we manually enter in these results through the software.  When I open up this same table in access I noticed that each test we do is displayed as new entry under the same product, therefore I have several entries for the same product code, and since we have several tests for each I am unable to specifically pull out the data I need.
    For example I need to create a data sheet for our customers displaying the bake time for these all our products the Product code (formkey) is listed multiple times but all I need is to record the Bake (TargetAlphaValue) time. Out of this table I will also need to report on the Gloss. If I use the record selection I am only able to display one type of test although I will need to specify other types as well.  This is the area I have the problem with,
    I have shown in a jpg what I am looking for, would anyone here know how to pull out only the TargetAlphaValue and associate it to the bake and formkey?  Then do the same with the Gloss test and pull up the TargetAlphaValue for that it would be of great help

    Can you be more precise , please :
    - which table stores the people identities ? (I call this one Identity)
    - which table gives the class where the student works in (I cal l this one Claa_attendees)
    - which table gives the instructor of a class (I call this one Class)
    If your issue is that you have one table which stores Itendities , and you need to display Student identity and Instructor Identity, you have to call this table twice in your query , using table aliases . I mean :
    Select Stud_iden.name, Instr_iden.name
    From Identity Stud_iden, Identity Instr_iden, Class_attendees, Class
    Where Class.clas_id = class_attendees.class_id
    and class.instructor_id = Instr_iden.people_id
    and class_attendees.student_id = Stud_iden.people_id
    Is this what you need to do ?

  • How to populate data in the same table based on different links/buttons

    Hi
    I'm using jdeveloper 11.1.4. I have a use case in which i need to populate data in the same table based on click of different links.
    Can anyone please suggest how can this be achieved.
    Thanks

    I have a use case in which i need to populate data in the same table based on click of different linksDo you mean that you need to edit existing rows ?
    What format do you have the date in - table / form ?

  • Data of column datatype CLOB is moved to other columns of the same table

    Hi all,
    I have an issue with the tables having a CLOB datatype field.
    When executing a simple query on a table with a column of type CLOB it returns error [POL-2403] value too large for column.
    SQL> desc od_stock_nbcst_notes;
    Name Null? Type
    OD_STOCKID N NUMBER
    NBC_SERVICETYPE N VARCHAR(40)
    LANGUAGECODE N VARCHAR(8)
    AU_USERIDINS Y NUMBER
    INSERTDATE Y DATE
    AU_USERIDUPD Y NUMBER
    MODIFYDATE Y DATE
    VERSION Y SMALLINT(4)
    DBUSERINS Y VARCHAR(120)
    DBUSERUPD Y VARCHAR(120)
    TEXT Y CLOB(2000000000)
    NBC_PROVIDERCODE N VARCHAR(40)
    SQL> select * from od_stock_nbcst_notes;
    [POL-2403] value too large for column
    Checking deeply, some of the rows have got the data of the CLOB column moved in another column of the table.
    When doing select length(nbc_providercode) the length is bigger than the datatype of the field (varchar(40)).
    When doing substr(nbc_providercode,1,40) to see the content of the field, a portion of the Clob data is retrieved.
    SQL> select max(length(nbc_providercode)) from od_stock_nbcst_notes;
    MAX(LENGTH(NBC_PROVIDERCODE))
    162
    Choosing one random record, this is the stored information.
    SQL> select length(nbc_providerCode), text from od_stock_nbcst_notes where length(nbc_providerCode)=52;
    LENGTH(NBC_PROVIDERCODE) | TEXT
    -------------------------+-----------
    52 | poucos me
    SQL> select nbc_providerCode from od_stock_nbcst_notes where length(nbc_providerCode)=52;
    [POL-2403] value too large for column
    SQL> select substr(nbc_providercode,1,40) from od_stock_nbcst_notes where length(nbc_providercode)=52 ;
    SUBSTR(NBC_PROVIDERCODE
    Aproveite e deixe o seu carro no parque
    The content of the field is part of the content of the field text (datatype CLOB, containts an XML)!!!
    The right content of the field must be 'MTS' (retrieved from Central DB).
    The CLOB is being inserted into the Central DB, not into the Client ODB. Data is synchronized from CDB to ODB and the data is reaching the client in a wrong way.
    The issue can be recreated all the time in the same DB, but between different users the "corrupted" records are different.
    Any idea?

    939569 wrote:
    Hello,
    I am using Oracle 11.2, I would like to use SQL to update one column based on values of other rows at the same table. Here are the details:
    create table TB_test (myId number(4), crtTs date, updTs date);
    insert into tb_test(1, to_date('20110101', 'yyyymmdd'), null);
    insert into tb_test(1, to_date('20110201', 'yyyymmdd'), null);
    insert into tb_test(1, to_date('20110301', 'yyyymmdd'), null);
    insert into tb_test(2, to_date('20110901', 'yyyymmdd'), null);
    insert into tb_test(2, to_date('20110902', 'yyyymmdd'), null);
    After running the SQL, I would like have the following result:
    1, 20110101, 20110201
    1, 20110201, 20110301
    1, 20110301, null
    2, 20110901, 20110902
    2, 20110902, null
    Thanks for your suggestion.How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • Open several PDFs in the same Reader window using tabs for each document

    How do I open several PDFs in the same Reader window using tabs for each document?  I'm using Reader 11.0.03 and Windows 7.  

    That would be a nice feature!  Suggest it at https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform - hopefully it will make it into Reader XII.

  • I have photos from several cameras of the same event, how do I combine them?

    I have photos from several cameras of the same events.  How can I sort them together, three pics of the same horse from three cameras side by side; I can't move pics from one camera source to another in a folder.

    Languare is critical since it is all we have to communicate with
    Folders in iPhoto do not hold photos - folders hold only other folders or albums
    If you are speaking of events then you simply merge the events (drag one onto another or select two or more and use the merge events command - for the photos to be "side by side" the three camera's time/date setting will have to be identical as photos will be sorted by time/date - if they are not you can correct by selecting the photos in an event (before merging) and using the adjust time and date command or you can make a smart album for the camera and select the photos and use the adjust time and date command
    LN

  • I have several copies of the same track - how do I remove extra tracks?

    First, I am now running iTunes for windows, 11.1.3.8
    My computer is a laptop running Windows 7.
    I have an iPod classic that I try to sync with it.
    I have a mix of songs downloaded from Amazon (sorry guys) or ripped from CD's. 
    A year ago, iTunes started creating several copies of the same track.  For example, if I wanted to listen to Adam Ant, I'd have three copies of "Desperate, but not serious" and one copy of something else and two copies of "Room at the Top."
    So, I deleted the extra tracks.  Sometimes this was horrid because if I deleted the wrong track, the other tracks wouldn't work, but they all looked the same (same number of bytes, no numbers at the end of the titles, etc) so I had to be careful. 
    I cursed, a lot, so after a time I deleted iTunes completely, then started over.  That seemed to fix it.
    BUT, today, I have the same problem.
    It's random.  Not every album is effected.  Not every song on a certain album is effected.  It's not just songs I ripped, or songs I downloaded.  There's nothing you can point at and go "AHA!"
    Furthermore...this might be a separate problem, but my iPod is not always recognized by iTunes, and some of the songs on the iPod get skipped.  Again, no way of telling which songs it doesn't like...it skips some ripped, some downloaded.  No correlation that one can easily track.
    What I would like to do is fix iTunes then reset the iPod and start over, I guess?
    Any ideas?  Thank you all in advance.

    Apple's official advice is here... HT2905 - How to find and remove duplicate items in your iTunes library. It is a manual process and the article fails to explain some of the potential pitfalls.
    Use Shift > View > Show Exact Duplicate Items to display duplicates as this is normally a more useful selection. You need to manually select all but one of each group of identical tracks to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks, however this works best when performed immediately after the dupes have been created.  If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin. This can happen, for example, if you start iTunes with a disconnected external drive, then connect it, reimport from your media folder, then restart iTunes.
    Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See this thread for background. Please take note of the warning to backup your library before deduping, whether you do so by hand or using my script, in case something goes wrong.
    (If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed)
    tt2

  • Multiple and conditions in the same table

    Ok I am going to kick myself for this, but I can't figure it out. I am trying to figure out how to find employees which match multiple criteria in the same table.
    create table emp
    (empno number,
    name  varchar2(10))
    create table skills
    (skill_id   number,
    skill_code varchar2(20))
    create table emp_skills
    (empno    number,
    skill_id number,
    rating   number)
    insert into emp values(1, 'SMITH');
    insert into emp values(2, 'JONES');
    insert into skills values (1, 'SQL');
    insert into skills values (2, 'PLSQL');
    insert into skills values (3, 'JAVA');
    insert into emp_skills values(1,1, 8);
    insert into emp_skills values(1,2, 9);
    insert into emp_skills values(1,3, 10);
    insert into emp_skills values(2,1,9);
    insert into emp_skills values(2,2,2);
    insert into emp_skills values(2,3,7);Now I need to come up with a query finding all employees who match all 3 of the following criteria:
    1) Have at least a 5 rating in SQL
    2) Have at least a 6 rating in PLSQL
    3) Have at least a 7 rating in JAVA
    So using this I would expect to return only SMITH since his/her skills meet all 3 criteria. I dont want to use OR in my query since I want all 3 to match not just one of them.
    I have a feeling I will need to self join the table - but this is going to be part of a dynamic query for APEX where the users can choose the skills and ratings they want employees to adhere to, so I dont know the number of criteria or the exact criteria in advance. But I figure if I can get a proof of concept SQL I can make it work dynamically.
    Any ideas are appreciated - sorry for the long post but I figure more detail is better

    with es1 as(
    select s.skill_code, es.empno, es.rating
    from skills s, emp_skills es
    where s.skill_id = es.skill_id
    /* main */
    select e.*
    from emp e
    where
    exists
    (select 'x' from es1
    where es1.rating >= 5
    and es1.skill_code = 'SQL'
    and es1.empno = e.empno)
    and
    exists
    (select 'x' from es1
    where es1.rating >= 6
    and es1.skill_code = 'PLSQL'
    and es1.empno = e.empno)
    and
    exists
    (select 'x' from es1
    where es1.rating >= 7
    and es1.skill_code = 'JAVA'
    and es1.empno = e.empno)
    -- Addition (Another example)
    with es1 as(
    select s.skill_code, es.empno, es.rating
    from skills s, emp_skills es
    where s.skill_id = es.skill_id
    /* main */
    select e.*
    from emp e
    where
    (select count(distinct es1.skill_code) from es1
    where
    ((es1.rating >= 5 and es1.skill_code = 'SQL')
    or
    (es1.rating >= 6 and es1.skill_code = 'PLSQL')
    or
    (es1.rating >= 7 and es1.skill_code = 'JAVA')
    and es1.empno = e.empno)
    =3;

  • How can I align two different text row in the same table in two different way (one centered and the other one on the left)?

    Hi,
    I want to center two different text row that are in the same table but one on the center and the other one on the left. I put a <span> tag hoping that it has been overwhelmed the table's class properties The .bottomsel's font-family and the .Cig84's font-family and colour work but the text-align don't: they're both on the left.
    These are my source and CSS codes:
    Source:
    <table width="600" border="0">
      <tr>
        <td class="bottomref"><p><span class="bottomsel">| <a href="index.html" target="_self">Main</a> | <a href="about.html" target="_self">About</a> | <a href="clients.html" target="_self">Clients</a> | <a href="contact.html" target="_self">Contact</a> |</span><br />
          <span class="credits">Credits: <span class="Cig84">Cig84</span></span></p></td>
      </tr>
    </table>
    CSS:
    .bottomsel {
      text-align: center;
      font-family: Georgia, "Times New Roman", Times, serif;
    .credits {
      text-align: left;
    .Cig84 {
      color: #F00;
      font-family: "Comic Sans MS", cursive;

    Use paragraph tags with CSS classes.
    CSS:
         .center {text-align:center}
         .left {text-align:left}
    HTML:
    <table width="600" border="0">
      <tr>
        <td class="bottomref">
              <p class="center">This text is center aligned</p>
              <p class="left">This text is left aligned</p>
        </td>
      </tr>
    </table>
    Nancy O.

  • How can I export several versions at the same time?

    Greetings -
    I'm looking for something that I may just be missing, and hoping someone here can point me in the right direction.
    Basically, I'd like to be able to select an image in my library and export several versions at the same time. For example, I select a photo and export JPG, TIFF and PSD versions in one shot without having to run three separate export requests - essentially a batch action. I can't imagine that this isn't built in already - I'm just assuming that I'm missing something obvious.
    Thanks in advance for any advice anyone might have.
    John.

    Fwiw, I've not seen this requested before.
    This kind of Export option is very typical, Kirby, when the rendering of the exported version will take a long time, for example for video or audio. Then you can share several formats at once, to render a version suitable for the web, for viewing on the computer, or the iPhone at the same time. That is really useful, if you render a movie at a full HD resolution and don't have to do it again for an iPhone/iPod version.
    QuickTime 7 does this for the "File > Export for Web" option, for example. You can get three versions of your final movie at the same time.
    And I just checked, the new iMovie Theater does this as well, when sharing a movie to the Theater:
    When you add a movie, trailer, or clip to the Theater, iMovie creates versions of your movie tailored for local playback, playback on an iOS device, and streaming.
    Come to think about it - exporting a webpage from Aperture will also export thumbnail sized images plus a larger version for downloading.

Maybe you are looking for

  • SQLDeveloper 4.0 hangs on Windows 7 64 Bit

    Hi, I just downloaded the brand-new SQLDeveloper 4.0 Production (4.0.0.13.80 64 Bit with jdk7). When I try to start it starts with a progress bar but hangs after about 10% I tried to delete all old folders in d:\User Profile\MyUser\AppData\Roaming \S

  • Drop file in finder

    I am developing a Java application for Macintosh. I have successfully implemented (via handleOpenFile and pList) that a double click on the relevant file type will open the application which then reads the file. I would also like to be able to open a

  • Images from Event gone!

    I was looking at old photos and I see that two events are gone. The thumbnail is there, the meta data is there, but the large image is not! It appears that my camera is overwriting images with hte same name? I've tried rebuilding the library... i've

  • Error during application of the NLS patch 6678700 for 6678700_ZHS language

    FAILED: file XLIFFLoader.class on worker 8 for product xdo username XDO. Time is: Thu Feb 24 2011 10:54:01 Assigned: file XLIFFLoader.class on worker 1 for product xdo username XDO. Time is: Thu Feb 24 2011 10:54:01 Assigned: file XLIFFLoader.class o

  • Hiding navigation when viewing DVD on screen

    Does anyone know of a way to hide the navigation symbols that pop on screen (ie: when you hit the play button)? My boss wants to do a presentation by way of DVD. I've set it up to pause at chapter markers so all he has to do is hit play when he is re