Getting list of items from one table indirectly associated with another

I have a database containing 3 tables. One is a list of employees, one is a list of companies that are clients and another is the projects each employee is working on. The projects table is the only connection between the employee and the company. An employee is working on a project for a specific company. I need to find a list of companies someone is working for given the employee's ID. How would I do this? I've done direct queries before, but never anything that involves going through another table. I have an explanation of my tables below.
Employee ------------- Project ----------- Company
Name ------------------ Name --------------- Name
ID -------------------> EmployeeID
------------------------ CompanyID ----------> ID

I did something like this..It works for MS Access 2000 but not SQL Server 2000. (http://forum.java.sun.com/thread.jsp?forum=48&thread=270102)
What I have is one main table, joined to 3 other tables, and each one of them have one category in common, and they are in a many-to-one relationship with the main table.
The Function category in the main table is the same as the Function_Name category in the others
For ex)
Main Table
Function Description Context Actions Notes
sample blah blah blah blah
Table 1
Function_Name ArgName ID
sample x 1
sample y 2
Table 2
Function_Name Return_Codes ID
sample z 1
sample m 2
sample n 3
Table 3
Function_Name Function_Called ID
sample t 1
What i needed to do was retrieve all these records from the different tables if I only had the value to the Name field.
This is the code I used:
<code>
String dataSourceName = "<fill in your dataSourceName>";
String dbURL = "jdbc:odbc:" + dataSourceName;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch (Exception e){System.out.println("Couldn't connect to driver.");}
try{
Connection con = DriverManager.getConnection(dbURL, "","");
Statement stmt = con.createStatement();
//gui3.staticName is the data in the Function or Function_Name Field
ResultSet result = stmt.executeQuery("SELECT * FROM function_description WHERE (((Function)='"+ gui3.staticName + "'));");
while(result.next()){
function.setText(result.getString("Function"));
description.setText(result.getString("Description"));
notes.setText(result.getString("Notes"));
actions.setText(result.getString("Actions"));
context.setText(result.getString("Context"));
ResultSet result2 = stmt.executeQuery("SELECT Return_Codes FROM return_code_description WHERE (((Function_Name)='"+ gui3.staticName + "')) ORDER BY Return_Codes ASC;");
while(result2.next()){
rCodes.addElement(result2.getString("Return_Codes"));
ResultSet result3 = stmt.executeQuery("SELECT ArgName FROM Arg WHERE (((Function_Name)='"+ gui3.staticName + "')) ORDER BY ArgName ASC;");
while(result3.next()){
args.addElement(result3.getString("ArgName"));
ResultSet result4 = stmt.executeQuery("SELECT Function_Called FROM Function_Called WHERE (((Function_Name) = '"+ gui3.staticName + "')) ORDER BY Function_Called ASC;");
while (result4.next()){
fcall.addElement(result4.getString("Function_Called"));
}catch (SQLException e) {System.out.println(e.getMessage());}
</code>
So when you get the ID can't you Select the data from the products table that matches it, and then take the Name field for that and search for it in the Company table? I think you can do embedded search statements. another way would be
Select <blah>
while(result.next)
Select <blah>
hope this helps

Similar Messages

  • How to get the data from one table and insert into another table

    Hi,
    We have requirement to build OA page with the data needs to be populated from one table and on save data into another table.
    For the above requirement what the best way to implement in OAF.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    Thanks

    You can achieve this in many different ways, one is
    1. Create another VO based on the EO which is based on the dest table.
    2. At save, copy the contents of the source VO into the dest VO (see copy routine in dev guide).
    3. commiting the transaction will push the data into the dest table on which the dest VO is based.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    if by table you mean a DB table, then no, you can have a VO based on multiple EOs which will do DMLs accordingly.Thanks
    Tapash

  • How do I read from one table and write to another identical table?

    I am very new to Oracle. I am trying to do something that should be very simple.
    I am trying to read from one table in SQL and then write to another
    Identically formatted table. I keep getting various errors. Could someone please
    post some vey simple code that will work so that I can play around with it?
    Any help would be greatly appreciated.
    Thanks,
    Ron

    Thanks, but I must be missing something.
    I have two tables, SONGLIST and SETLIST.
    The second line by itself works just fine on either table.
    Here is the code I used following your seggestion, along with it's error message.
    Hope you can help. Thanks again...
    INSERT INTO SETLIST
    SELECT TITLE FROM SONGLIST WHERE ROTATION <> 'X'
    ORA-00947: not enough values

  • How to best take sections from one document to merge with another Indesign document

    I am looking for most efficient way to take a section from one document to merge with a section from another document?  We have a book that needs updating, taking a section from one document to merge into another.  We have typically copied and paste each page, but there are 20+ pages involved.  Does anyone have a better way?

    Open both documents.
    With source document active, In pages panel, select pages that are to be copied to the destination document
    Right Click (or use panel menu) and select Move Pages ...
    Double check that correct page range is noted
    Select destination document
    select where in document pages should appear (beginning, end, after or before page X)

  • Error when copying items from one table to another

    I am trying to copy data from 2 archive tables within an
    Access database to their twin production tables. The first table
    copies perfectly with the code:
    <CFQUERY NAME="moveArchAttach" datasource="faaco2">
    INSERT INTO tbl_Attachment ( PostID, Attachment, AttachNote,
    AttachName )
    SELECT tbl_Attachment_Archived.PostID,
    tbl_Attachment_Archived.Attachment,
    tbl_Attachment_Archived.AttachNote,
    tbl_Attachment_Archived.AttachName
    FROM tbl_Attachment_Archived
    </CFQUERY>
    However, when trying to use similar code on the other table:
    <CFQUERY NAME="moveArchPost" datasource="faaco2">
    INSERT INTO tbl_Posting ( Title, FirstName, LastName,
    PhoneNumber, RoutingSymbol, Email, IniDate, ComDate, SOLNBR,
    PhaseCode, ProcCode, Posting, Password, RegionCode )
    SELECT tbl_Posting_Archived.Title,
    tbl_Posting_Archived.FirstName, tbl_Posting_Archived.LastName,
    tbl_Posting_Archived.PhoneNumber,
    tbl_Posting_Archived.RoutingSymbol, tbl_Posting.Email,
    tbl_Posting.IniDate, tbl_Posting.ComDate, tbl_Posting.SOLNBR,
    tbl_Posting.PhaseCode, tbl_Posting.ProcCode, tbl_Posting.Posting,
    tbl_Posting.Password, tbl_Posting.RegionCode
    FROM tbl_Posting_Archived
    </CFQUERY>
    I receive the error:
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
    Expected 9.
    Any help would be greatly appreciated, I am at a loss and
    I've tried everything. Thank you.

    I realized my error immediately after posting this topic and
    subsequently have resolved this error. On 9 of the values, I have
    listed the wrong table in the SELECT statement. This is why one
    needs to take breaks instead of staring at a screen forever :).
    Thank you anyway!

  • I need help figuring out how to Link Data from one table in Sharepoint to another table in Sharepoint and make it dynamic

    Hi Everyone,
    I am working on a project that uses SharePoint 2010 for repository and we have multiple tables that we are using.
    One table is a list of the various projects we are working on (workstreams)
    The other is a table with various notes and such, to include meeting notes for the various projects.
    Currently we are just copying the shortcut from the meeting notes table and adding it in as a link in the workstreams status table.
    I need to find out if there is some sort of way to make this process dynamic so that when a new note is added for, lets say workstream #1 in the notes table, it will automatically propogate into the notes link section for workstream #1.
    Is this even possible??
    And if so how would I do it
    I haven't done much with modifying SharePoint in several years, and would Truly appreciate any and all help with this.
    Thanks in advance
    IKE

    Hi IKE,
    According to your description, my understanding is that you want to create a link in the workstreams list linked to the associated item of the notes list.
    Assuming the workstreams list has  Title column and another column called “Note” used to linked to notes list, and the notes list has Title column and another column used to store note.
    Then you can create a workflow on the notes list with SharePoint Designer 2010, and in the workflow, using “Update ListItem” action. And in the workflow Start Options, select “Start workflow automatically when an item is created”.
    For the workflow action, you can set as the screenshot:
    For the string in the String Builder, you need to open an item of notes list, then copy the URL of the display form and paste here, the URL will look something like this:
    http://sp/Lists/notes/DispForm.aspx?ID=1&Source=http%3A%2F%2Fsp%2FLists%2Fnotes%2FAllItems%2Easpx&ContentTypeId=0x0100300025278693CE49A5E3A394B23AD9E1&IsDlg=1
    Now, you need to replace the ID of the item using [%Current Item:ID%], for example in the above link, delete the number 1 and add [%Current Item:ID%].
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • How to read LONG RAW data from one  table and insert into another table

    Hello EVERYBODY
    I have a table called sound with the following attributes. in the music attribute i have stored some messages in the different language like hindi, english etc. i want to concatinate all hindi messages and store in the another table with only one attribute of type LONG RAW.and this attribute is attached with the sound item.
    when i click the play button of sound item the all the messages recorded in hindi will play one by one automatically. for that i'm doing the following.
    i have written the following when button pressed trigger which will concatinate all the messages of any selected language from the sound table, and store in another table called temp.
    and then sound will be played from the temp table.
    declare
         tmp sound.music%type;
         temp1 sound.music%type;
         item_id ITEM;
    cursor c1
    is select music
    from sound
    where lang=:LIST10;
    begin
         open c1;
         loop
              fetch c1 into tmp; //THIS LINE GENERATES THE ERROR
              temp1:=temp1||tmp;
              exit when c1%notfound;
         end loop;
    CLOSE C1;
    insert into temp values(temp1);
    item_id:=Find_Item('Music');
    go_item('music');
    play_sound(item_id);
    end;
    but when i'm clicking the button it generates the following error.
    WHEN-BUTTON-PRESSED TRIGGER RAISED UNHANDLED EXCEPTION ORA-06502.
    ORA-06502: PL/SQL: numeric or value error
    SQL> desc sound;
    Name Null? Type
    SL_NO NUMBER(2)
    MUSIC LONG RAW
    LANG CHAR(10)
    IF MY PROCESS TO SOLVE THE ABOVE PROBLEM IS OK THEN PLESE TELL ME THE SOLUTION FOR THE ERROR. OTHER WISE PLEASE SUGGEST ME,IF ANY OTHER WAY IS THERE TO SOLVE THE ABOVE PROBLEM.
    THANKS IN ADVANCE.
    D. Prasad

    You can achieve this in many different ways, one is
    1. Create another VO based on the EO which is based on the dest table.
    2. At save, copy the contents of the source VO into the dest VO (see copy routine in dev guide).
    3. commiting the transaction will push the data into the dest table on which the dest VO is based.
    I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
    if by table you mean a DB table, then no, you can have a VO based on multiple EOs which will do DMLs accordingly.Thanks
    Tapash

  • BI - ABAP To pick the field from One table and link with 2nd table

    Hello, I am stuck to write the correct abap code. Requirement is that My Client BMW  California require the below:
    <b>1.</b>  list of invoices (BELNR) that a has tcode = FB01 and FBVB" from Table BKPF.  Account Number field (BELNR) is there in 0fiap_4 Data source
    <b>2.</b> Now Link the above invoice Number (BELNR)  that a has tcode = FB01 and FBVB" from Table BKPF to BMW Custom Table I_BMW_WI. - Field "PAT ID" which is the cocatenation of OBJNR (Object Number), Invoice Number and Purchase Year.  where PICK only thos PAT ID where "TYPEID"  Value = "BMW" in table I_BMW_WI.
    To solve Number 1 Please fix my abap code and help me to write the Code to Solve Number 2 and Link #1 AND #2.
    Please help me soon
    Code # 1
    case I_datasource.
    WHEN '0FI_AP_4'.
    loop at C_t_data into l_s_DTFIAP_3.
    l_tabix = sy-tabix.
    clear I_BMW_WI.
    if sy-subrc = 0.
    select single * from BKPF into I_BKPF where BELNR = l_s_DTFIAP_3-BELNR.
    LOOP AT I_BKPF into I_FINAL WHERE
    Code below is not working
    (I_BKPF-TCODE = ‘FV50’) OR (I_BKPF-TCODE = ‘FB01’)
    I_FINAL-BELNR = I_BKPF-BELNR
    modify I_FINAL.
    endloop
    modify C_t_data from l_s_DTFIAP_3  index l_tabix.
    endif.
    endloop.
    endcase
    Code # 2 -
    Please help with templates.
    Thanks
    Soniya Kapoor

    Hi,
    Ad Code #1
    First of all the key for BKPF consists of:
    BUKRS, BELNR and GJAHR so I think you should use all key fields in your SELECT statement:
    select single * from BKPF into I_BKPF
    where BUKRS = l_s_DTFIAP_3-BUKRS and
          BELNR = l_s_DTFIAP_3-BELNR and
          GJAHR = l_s_DTFIAP_3-GJAHR.
    And why do you test SY-SUBRC after CLEAR ?
    Your IF statement should be after SELECT...
    And last but not least when you are using SELECT SINGLE you always get only one record so what is the purpose of LOOP statement ?
    Try following code:
    case I_datasource.
    WHEN '0FI_AP_4'.
      loop at C_t_data into l_s_DTFIAP_3.
        l_tabix = sy-tabix.
        select single * from BKPF into I_BKPF
          where BUKRS = l_s_DTFIAP_3-BUKRS and
                BELNR = l_s_DTFIAP_3-BELNR and
                GJAHR = l_s_DTFIAP_3-GJAHR.
        if sy-subrc = 0.
          if (I_BKPF-TCODE = ‘FV50’) OR
             (I_BKPF-TCODE = ‘FB01’).
            I_FINAL-BELNR = I_BKPF-BELNR
            modify I_FINAL.
          endif.
          modify C_t_data from l_s_DTFIAP_3 index l_tabix.
        endif.
      endloop.
    endcase.
    regards
    Krzys

  • Transferring items from one warehouse to another

    I have been trying to transfer items from one of our warehouses to another using oStockTransfer and I keep getting the error [OWTR.filler], No Matching Records found (ODBC 2028).  The template is looking for a Business Partner Code.  When I keep the BP (CardCode) column in the .csv file and tell DTW to update and add new object, I receive the error BP does not exist.
    Please help.

    Hi!
    Try to add the same document, manually. wheather any error is coming ?

  • Transfer of line items from 1 reconciliation A/c to another reconciliation

    Hi Experts
    Can you please suggest me how to carry on transferring line items from one reconciliation A/c to another reconciliation A/c, is there any recommendation to this
    pls suggest
    Regards
    Sreenivasulu

    Hi Sreenivasalu,
    [Check this Thread|changing reconciliation account on Vendor Master.]
    Hope this will be useful for you
    Regards
    Andrew

  • I keep getting the message that my computer is associated with another apple id. I have already removed the device from the other apple id but I still get the message. How long does it take to update?

    I am trying to download a tv show that I purchased and I get the message that my laptop is already associated with another apple id. I knew it was my wifes id so I went into her account and removed the association. I still get this message even though there is no other apple id associated with the laptop now.

    That's not how it works. Once a device (including a computer) is associated with an Apple ID it cannot be switched for 90 days. See this Apple KB article for more information: http://support.apple.com/kb/HT1420.

  • [Forum FAQ] How to configure a Data Driven Subscription which get multi-value parameters from one column of a database table?

    Introduction
    In SQL Server Reporting Services, we can define a mapping between the fields that are returned in the query to specific delivery options and to report parameters in a data-driven subscription.
    For a report with a parameter (such as YEAR) that allow multiple values, when creating a data-driven subscription, how can we pass a record like below to show correct data (data for year 2012, 2013 and 2014).
    EmailAddress                             Parameter                      
    Comment
    [email protected]              2012,2013,2014               NULL
    In this article, I will demonstrate how to configure a Data Driven Subscription which get multi-value parameters from one column of a database table
    Workaround
    Generally, if we pass the “Parameter” column to report directly in the step 5 when creating data-driven subscription.
    The value “2012,2013,2014” will be regarded as a single value, Reporting Services will use “2012,2013,2014” to filter data. However, there are no any records that YEAR filed equal to “2012,2013,2014”, and we will get an error when the subscription executed
    on the log. (C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\LogFiles)
    Microsoft.ReportingServices.Diagnostics.Utilities.InvalidReportParameterException: Default value or value provided for the report parameter 'Name' is not a valid value.
    This means that there is no such a value on parameter’s available value list, this is an invalid parameter value. If we change the parameter records like below.
    EmailAddress                        Parameter             Comment
    [email protected]         2012                     NULL
    [email protected]         2013                     NULL
    [email protected]         2014                     NULL
    In this case, Reporting Services will generate 3 reports for one data-driven subscription. Each report for only one year which cannot fit the requirement obviously.
    Currently, there is no a solution to solve this issue. The workaround for it is that create two report, one is used for view report for end users, another one is used for create data-driven subscription.
    On the report that used create data-driven subscription, uncheck “Allow multiple values” option for the parameter, do not specify and available values and default values for this parameter. Then change the Filter
    From
    Expression:[ParameterName]
    Operator   :In
    Value         :[@ParameterName]
    To
    Expression:[ParameterName]
    Operator   :In
    Value         :Split(Parameters!ParameterName.Value,",")
    In this case, we can specify a value like "2012,2013,2014" from database to the data-driven subscription.
    Applies to
    Microsoft SQL Server 2005
    Microsoft SQL Server 2008
    Microsoft SQL Server 2008 R2
    Microsoft SQL Server 2012
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    For every Auftrag, there are multiple Position entries.
    Rest of the blocks don't seems to have any relation.
    So you can check this code to see how internal table lt_str is built whose first 3 fields have data contained in Auftrag, and next 3 fields have Position data. The structure is flat, assuming that every Position record is related to preceding Auftrag.
    Try out this snippet.
    DATA lt_data TYPE TABLE OF string.
    DATA lv_data TYPE string.
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename = 'C:\temp\test.txt'
      CHANGING
        data_tab = lt_data
      EXCEPTIONS
        OTHERS   = 19.
    CHECK sy-subrc EQ 0.
    TYPES:
    BEGIN OF ty_str,
      a1 TYPE string,
      a2 TYPE string,
      a3 TYPE string,
      p1 TYPE string,
      p2 TYPE string,
      p3 TYPE string,
    END OF ty_str.
    DATA: lt_str TYPE TABLE OF ty_str,
          ls_str TYPE ty_str,
          lv_block TYPE string,
          lv_flag TYPE boolean.
    LOOP AT lt_data INTO lv_data.
      CASE lv_data.
        WHEN '[Version]' OR '[StdSatz]' OR '[Arbeitstag]' OR '[Pecunia]'
             OR '[Mita]' OR '[Kunde]' OR '[Auftrag]' OR '[Position]'.
          lv_block = lv_data.
          lv_flag = abap_false.
        WHEN OTHERS.
          lv_flag = abap_true.
      ENDCASE.
      CHECK lv_flag EQ abap_true.
      CASE lv_block.
        WHEN '[Auftrag]'.
          SPLIT lv_data AT ';' INTO ls_str-a1 ls_str-a2 ls_str-a3.
        WHEN '[Position]'.
          SPLIT lv_data AT ';' INTO ls_str-p1 ls_str-p2 ls_str-p3.
          APPEND ls_str TO lt_str.
      ENDCASE.
    ENDLOOP.

  • How to copy List item from one list to another using SPD workflow using HTTP call web service

    Hi,
    How to copy List item from one list to another using SPD workflow using HTTP call web service.
    Both the Lists are in different Web applications.
    Regards, Shreyas R S

    Hi Shreyas,
    From your post, it seems that you are using SharePoint 2013 workflow platform in SPD.
    If that is the case, we can use Call HTTP web service action to get the item data, but we cannot use Call HTTP web service to create a new item in the list in another web application with these data.
    As my test, we would get Unauthorized error when using Call HTTP web service action to create a new item in a list in another web application.
    So I recommend to achieve this goal programmatically.
    More references:
    https://msdn.microsoft.com/en-us/library/office/jj164022.aspx
    https://msdn.microsoft.com/en-us/library/office/dn292552.aspx?f=255&MSPPError=-2147217396
    Thanks,
    Victoria
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to move items from one list to other

    hi all,
    in jsp page i have twolist boxes. i want to move item from one list to other list on click of add or move button. can u plz suggest me an answer for the above. thank u
    Regards sangeet

    This link should help. Remove from one list and add to the other using Javascript.
    http://www.mredkj.com/tutorials/tutorial006.html

  • Javascript help to copy selected items from one list to another list on same site

    Hello,
    So I have a request that I am not sure how to handle. I have created a page with a list view webpart that displays all the items from one list.
    The user is then supposed to select off multiple list items and click on a button (most likely a ribbon button) that will take the selected items and copy them to another list on the same SharePoint site.
    I would like to do this with JavaScript, but have only found an example that copies library items to another library.

    Hi KansaiKel,
    According to your description, my understanding is that you want to copy selected list items to another list.
    I suggest you can use JavaScript Client Object Model to achieve it.
    Here is a code snippet for your reference:
    <script type="text/javascript">
    var context = SP.ClientContext.get_current();
    var siteUrl = 'http://sp2013sps/sites/test';
    var clientContext = new SP.ClientContext(siteUrl);
    var web = context.get_web();
    context.load(web);
    var sourceId = SP.ListOperation.Selection.getSelectedList();
    var source = web.get_lists().getById(sourceId);
    var oList = context.get_web().get_lists().getByTitle('Copy');
    context.load(oList);
    var selectedItems = SP.ListOperation.Selection.getSelectedItems(context);
    alert('debut');
    for(var i in selectedItems)
    var currentItem = source.getItemById(selectedItems[i].id);
    context.load(currentItem);
    context.executeQueryAsync(Function.createDelegate(this,test),Function.createDelegate(this,error));
    function test(sender, args){
    var itemCreateInfo = new SP.ListItemCreationInformation();
    var oListItem = oList.addItem(itemCreateInfo);
    oListItem.set_item('Title', currentItem.get_item('Title'));
    oListItem.update();
    oList.update();
    alert('done');
    function error(sender, args){ alert('error');}""
    </script>
    Here is a detailed article for your reference:
    Complete basic operations using JavaScript library code in SharePoint
    Best Regards
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Zhengyu Guo
    TechNet Community Support

Maybe you are looking for

  • Action Link in obiee 11g for a Hierarchy Drill Down Level

    Hi Requirement is: We have a Time Dimension Hierarchy with drill down Levels(Year, Qtr, Month, Day). So now i wanted to provide an action link on detailed column(day) which will navigate to other report. I have tried doing it but unable to get the ac

  • Question about HP 110-414 Dual Monitor

    HP site says the 110-414 supports dual monitor and it looks like it does.  But what adapter do I need?  I bought a Passive DVI-D adapter no go.  Any ideas? Thanks! Jim

  • Knowing which Row was selected when Hide/Show is clicked

    Hi everyone, I have an advanced table, with some search criteria that works. I have added a "detail" flag and when I click the link Hide/Show, the details are displayed. How can I get in the code which Hide/Show link was clicked? I am more interestin

  • Sublinks within a page - i.e .back to top

    anyone know how to link to text further down on same page and have a "back to top" link at bottom of page? I know this is very simple, but can't seem to figure it out in iWEb '09. Thanks thanks!!

  • JSP usebean setProperty property is not working ??

    I am new to this forum so not sure whether I put my concern in correct category or not. I have the following piece of code in my JSP <jsp:useBean id="bean" class="com.cdr.settlement.bean.MassUpdateUtilityBean" scope="request"> <jsp:setProperty name="