Query to link ORDR, ODLN, OINV, ORIN

Dear Experts,
Can anybody help me how to develop a query to get Delivary Doc No, Invoice No , Credit Memo No generated for  each sales order according to Posting Date. ie. I need a report like this
Post.Date      SO.No     Deliv.No     Inv.No   CreditMemo.No
we are using SBO 2007 B PL 8
Regards
Srini

hi,
try this:
SELECT DISTINCT dbo.ORDR.DocDate, dbo.ORDR.DocNum AS SO_No, dbo.ODLN.DocNum AS Del_No, dbo.OINV.DocNum AS InvoiceNo, dbo.ORIN.DocNum AS CreditNo
FROM         dbo.ORIN INNER JOIN
                      dbo.RIN1 ON dbo.ORIN.DocEntry = dbo.RIN1.DocEntry RIGHT OUTER JOIN
                      dbo.ORDR LEFT OUTER JOIN
                      dbo.DLN1 INNER JOIN
                      dbo.ODLN ON dbo.DLN1.DocEntry = dbo.ODLN.DocEntry INNER JOIN
                      dbo.OINV INNER JOIN
                      dbo.INV1 ON dbo.OINV.DocEntry = dbo.INV1.DocEntry ON dbo.ODLN.DocEntry = dbo.INV1.BaseEntry ON dbo.ORDR.DocEntry = dbo.DLN1.BaseEntry ON
                      dbo.RIN1.BaseEntry = dbo.OINV.DocNum
in here it only relation SO - DO - AR - ARC . you can use  BaseType field in (DLN1 ,INV1 ,RIN1  ) distinguish base document.
thanks,
H2

Similar Messages

  • Plz help don't know how to create a query and link it to a UDF

    hi,
    i am new to business one and however hard i am trying to use a query to link it to a UDF, it is not working. i think i am doing the whole thing wrong,so ill just post one problem i have and if any one of u can explain to me in steps i may be able to learn to link other queries and UDFs.so plz help me out .
    problem:
    i want to display the account balance of every customer/vendor whenvever i open a marketing document. i have created a UDF for the marketing documents in the title with name and description 'account balance'.
    Now how do i link the customer/vendor name field to this UDF so that the query generated will show the account balance of the corresponding customer/vendor.plz tell me in steps as to what tables to choose ,what fields to choose, what conditions and relatoins to use in a query wizard
                                                                                    thank you

    hi,
    A/R invoice
    for name UDF:
    SELECT T0.CardName FROM OCRD T0 WHERE T0.CardCode = $[OINV.CardCode]
    for balance UDF:
    SELECT T0.Balance FROM OCRD T0 WHERE T0.CardCode = $[OINV.CardCode]
    A/P invoice
    for name UDF:
    SELECT T0.CardName FROM OCRD T0 WHERE T0.CardCode = $[OPCH.CardCode]
    for balance UDF:
    SELECT T0.Balance FROM OCRD T0 WHERE T0.CardCode = $[OPCH.CardCode]
    FOR OTHER FORMS ONLY CHANGE THE END OF THE QUERY    FOR Example
    $[OPCH.CardCode]
    OPCH  is the table name, change it to other table.
    save the query and set it to customer code for refresh in A/R invoice
    save the query and set it to Vendor code for refresh in A/P invoice
    regards
    sandip

  • Linking ORDR to POR1 and OPOR.

    Hi Experts,
        Is there a way to link OPOR and POR1 to ORDR to show ORDR.[CardName]? I want to show the ORDR.[CardName] with the details of OPOR and POR1 in a query.
    Thanks and Regards,
    Christian

    Hi,
    1. Only possible if you create PO directly from SO through procurement document (SO-->Logistics tab).
    2. If you have common field between ORDR and  OPOR, then you can link these tables.
    Thanks & Regards,
    Nagarajan

  • Run a query on linked tables to create a new datasource

    Using Crystal XI
    I have a report that draws from two data sources.  They can't be joined at the server side, but they are linked in Crystal Database Expert. 
    I can't figure out if Crystal gives me a way to write an SQL Query to run an aggregate function referencing both tables.  The results of this query would be the datasource for a graph in the report.  I'm wondering if Crystal gives me a way, maybe through subreports, to write the query I need.
    More concretely:
    And I want to include in my datasource alarmId, Hour and the Maximum amount of calls received in any one hour for any one station (this maximum is to provide scale for a graph)
    In one table nameed AlarmStartTimes I have data like
    Alarms
    AlarmID  Hour    Recipient
    Alarm1       8       Joe
    Alarm23  10      Mark
    Alarm60  7      Joe
    Alarm95  8      Linda
    In another I have data like
    EELocation
    Recipient   Location
    Joe         Station1
    Mark         Station2
    Linda          Station1
    So if I could just join my talbes at the server side I'd use a query like:
    select *, max(select count(AlarmID) from Alarms, EELocation from Alarms Join EELocationo on Alarms.Recipient=EELocation.Recipient group by Hour, Location) AS  from Alarms
    Anyway, that's probably got a syntax error or 4 in it, but you get the idea.
    I can't group on the database side.  Since Crystal is able to link the two tables and successfully group them out by Location, it seems like there should be some way for me to run a query against the tables reflecting that existing link, but I can't see how to do it.
    The reason I can't link on database side is that the data is in two databases, and it's not known what the location of the databases is at report-writing time.  The location of the databases gets set via the Crystal API when the report is launched from an application.

    Since you have 2 datasource in the report you are limited on what you can use in crystal, such as crystal will not allow you to use sql expressions.

  • Export SQL query from link or button

    I want to list several 'canned' SQL queries on one page as buttons or links; and have the result of selection be an immediate extract/download to excel of the data.
    How can I best do this?
    I suppose I could create separate hidden regions with their own reports that could somehow be referenced in the link. I would like to avoid doing all that, if I can create a package or process that includes the SQL query and that can be called in the link.
    Thanks in advance,
    Rich
    Edit:
    Found 'Report Query' functionality in Apex v3.2.1: However I am unable to get this to work; tells me my printer is not set up. I don't want to print the detail, I want it to be downloaded into excel... I don't have a printer configured - & don't want to. The URL provided for download as attachment is:
    f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=reportname
    I also have no page 0.
    Help?
    Edited by: rdarlin2 on Sep 16, 2011 11:14 AM

    rdarlin2 wrote:
    I want to list several 'canned' SQL queries on one page as buttons or links; and have the result of selection be an immediate extract/download to excel of the data.
    How can I best do this?
    I suppose I could create separate hidden regions with their own reports that could somehow be referenced in the link. I would like to avoid doing all that, if I can create a package or process that includes the SQL query and that can be called in the link.10,000ft overview of one way to do this:
    <li>Create a package with private functions that return the SQL for each "canned query", and a public switch function that returns a query function based on an input parameter:
    create or replace package qry
    is
      function selector (p_req_qry in varchar2) return varchar2;
    end qry;
    create or replace package body qry
    is
      function emp_qry return varchar2
      is
      begin
        return 'select * from emp';
      end emp_qry;
      function dept_qry return varchar2
      is
      begin
        return 'select * from dept';
      end dept_qry;
      function selector (p_req_qry in varchar2) return varchar2
      is
      begin
        return
          case p_req_qry
            when 'EMP' then emp_qry()
            when 'DEPT' then dept_qry()
          end;
      end selector;
    end qry;
    /<li>Create 2 pages
    <li>On page 2 create a standard SQL report region of type SQL Query (PL/SQL function body returning SQL query):
    Region Source
    return qry.selector(:request);*(o) Use Generic Column Names (parse query at runtime only)*
    Maximum number of generic report columns
    number of columns in your biggest query
    Report Template
    export: CSV
    <li>On page 1 create an HTML region (or use an APEX list) with a link for each query, where the REQUEST component of the URL is the parameter used to select a query in the <tt>qry.selector</tt> function:
    <ul>
      <li>&lt;a href="f?p=&APP_ID.:2:&SESSION.:EMP"&gt;Emp</a></li>
      <li>&lt;a href="f?p=&APP_ID.:2:&SESSION.:DEPT"&gt;Dept</a></li>
    </ul>However this begs the question: Why bother? What's Excel got that APEX hasn't?

  • Query using link server to an Oracle database failswhile similar query works

    I have two queries almost the same that use a link to an Oracle database. One works ok, the other is a copy of the first with a few fields selects removed.  The first one works fine, the copy fails with: Cannot get the data of the row from the OLE DB
    provider "OraOLEDB.Oracle" for linked server "linkname".
    They are so similar, why would one work but not the other? 
    First query, this one works:
    SET
    ANSI_NULLS ON
    GO
    SET
    QUOTED_IDENTIFIER ON
    GO
    CREATE
    PROCEDURE [dbo].[procedure_name]
    -- Add the parameters for the stored procedure here
    @Begindate  Datetime,
    @Enddate Datetime
    AS
    BEGIN
    --SET NOCOUNT ON added to prevent extra result sets from
    --interfering with SELECT statements.
    SET NOCOUNT
    ON;
    -- Insert statements for procedure here
    select p.patientid, p.testid,
    mdx."Dx_4", td.acquisitiondatetime_dt, td.democompletedatetime_dt,
    td.editdatetime_dt,
    CAST(STUFF(STUFF(mn."Arrival_Time_9",
    9, 0,
    ' '), 12, 0,
    AS datetime)
    as Arrival_date,
    CAST(STUFF(STUFF(mt."Comp_D_T_22",
    9, 0,
    ' '), 12, 0,
    AS datetime)
    as Order_date, td.confirmdatetime_dt
    (CAST(DATEDIFF
    (MINUTE,
    CAST (STUFF
    (STUFF
    (MN."ARRIVAL_TIME_9", 9,0,
    ' '), 12, 0,
    AS DATETIME), TD.DEMOCOMPLETEDATETIME_DT) 
    as char(10))
    + 'min')
    AS "ARRIVAL TO COMPLETE",
    (CAST(DATEDIFF
    (MINUTE,
    CAST (STUFF
    (STUFF
    (MT."COMP_D_T_22", 9,0,
    ' '), 12, 0,
    AS DATETIME), TD.DEMOCOMPLETEDATETIME_DT)
    as char(10))
    + 'min') 
    AS "ORDER TO COMPLETE"
    from linknametosqldb.sqldbname.dbo.tstpatientdemographics
    as p inner
    join linknametosqldb.sqldbname dbo.tsttestdemographics
    as td on p.testid
    = td.testid
    left
    outer join linknametooracledb."M01Tab01_Main" mn
    on td.visitnumber
    = mn."Pt_Acct_5"
    inner
    JOIN linknametooracledb."M01Tab06_Ord" mt
    ON mn."Master_Recid_1"
    = mt."Master_Recid_1"
    inner
    join linknametooracledb."M01Tab09_Dx" mdx
    on mn."Master_Recid_1"
    = mdx."Master_Recid_1"
    where td.location
    in (2, 4)
    and mt.order_4
    like 'EKG%' 
    and mdx."Dx_4"
    like '%Chest Pain%'
    and
    (td.acquisitiondatetime_dt
    >= @Begindate and td.acquisitiondatetime_dt
    < @Enddate)
    order
    by p.patientfullname_last, p.patientfullname_first
    END
    GO
    Second query, copied from first with some fields selects removed, this does not work:
    SET
    ANSI_NULLS ON
    GO
    SET
    QUOTED_IDENTIFIER ON
    GO
    CREATE
    PROCEDURE [dbo].[procedure_name_2]
    -- Add the parameters for the stored procedure here
    @Begindate  Datetime,
    @Enddate Datetime
    AS
    BEGIN
    --SET NOCOUNT ON added to prevent extra result sets from
    --interfering with SELECT statements.
    SET NOCOUNT
    ON;
    -- Insert statements for procedure here
    select p.patientid, mdx."Dx_4",
    td.democompletedatetime_dt,
    CAST(STUFF(STUFF(mn."Arrival_Time_9",
    9, 0,
    ' '), 12, 0,
    AS datetime)
    as EDIS_Arrival_date,
    (CAST(DATEDIFF
    (MINUTE,
    CAST (STUFF
    (STUFF
    (MN."Arrival_Time_9", 9,0,
    ' '), 12, 0,
    AS DATETIME), TD.DEMOCOMPLETEDATETIME_DT) 
    as char(10))
    + 'min')
    AS "ARRIVAL TO COMPLETE"
    from linknametosqldb.dbo.tstpatientdemographics
    as p inner
    join linknametosqldb.dbo.tsttestdemographics
    as td on p.testid
    = td.testid
    left outer
    join linknametooracledb."M01Tab01_Main" mn
    on td.visitnumber
    = mn."Pt_Acct_5"
    inner
    JOIN linknametooracledb."M01Tab06_Ord" mt
    ON mn."Master_Recid_1"
    = mt."Master_Recid_1"
    inner
    join linknametooracledb M01Tab09_Dx" mdx
    on mn."Master_Recid_1"
    = mdx."Master_Recid_1"
    where td.location
    in (2, 4)
    and mt.order_4
    like 'EKG%' 
    and mdx."Dx_4"
    like '%Chest Pain%'
    and
    (td.acquisitiondatetime_dt
    >= @Begindate and td.acquisitiondatetime_dt
    < @Enddate)
    order
    by p.patientid
    END
    GO
    Thanks very much for any help with this.

    * Consider putting parentheses around the 3 oracle tables so the 3 of them can possibly be treated as a unit.  Assuming there's some performance impact due to the linked server, this MIGHT help, may do a little joining over on the Oracle side of
    the world.  In either case, it's a little cleaner.  They syntax below, including a few extra line breaks for clarity, should be correct.  (try the change to the ON clause suggested above too, though).
    The parentheses will not help much. SQL Server will remote (as the term is) the query to the Oracle instance if this appears to have a lower cost and there is nothing the blocks remoting.
    On the other hand, OPENQUERY can be an alternative to ensure that this happens:
     left outer join
        OPENQUERY (linknametooracledb,
                   'SELECT ...
                    FROM   "M01Tab01_Main" mn
                    JOIN   "M01Tab06_Ord" mt ON mn."Master_Recid_1" = mt."Master_Recid_1"
                    JOIN   "M01Tab09_Dx" mdx on mn."Master_Recid_1" = mdx."Master_Recid_1"') mn on td.visitnumber = mn."Pt_Acct_5"
    But this presumes that you there are no columns from the SQL Server side that are used to select data from the Oracle side. That is, the above could lead to far much data being brought across the wire.
    Then again, this does not really seem to relate to the original problem where a stored procedure was not working at all. That problem is not very easy to assist with since code post is the not the authentic code as pointed out in the thread. For instance
    inner JOIN linknametooracledb."M01Tab06_Ord"
    Has nothing to do with Oracle, but accesses a table in the schema linknametooracledb.
    I think to help dmcm, you need a really good crystal ball - at least as long he/she does not share the actual code.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Query Question - Linking in Time Span Data to Point-in-Time References

    I am trying to pull historical data from a time-span table of records, using another point-in-time reference. I have been unsuccessful.
    I've thrown some sample tables and data together to illustrate what I am seeking:
    Create Table EmployeeInfo (
           id Number(10,0),               -- Employee ID Number
           Name VarChar2(32 Byte),        -- Employee Name
           CurrentShift VarChar2(2 Byte)  -- Current Employee Shift
    Create Table ShiftChanges (
           id Number(10,0),               -- Employee ID that this shift change record is for
           ChangeDate Date,               -- Date that this Change Took Place
           OldShift VarChar2(2 Byte),
           NewShift VarChar2(2 Byte)
    Create Table TimeCard(
           id Number(10,0),               -- Employee ID Number for this Timecard
           WorkDay Date,                  -- What Day is this Timecard for?
           Hours Float(63)                -- Number of Hours worked.
    COMMIT;
    INSERT INTO EmployeeInfo VALUES (100,'John Doe','Days')
    INSERT INTO EmployeeInfo VALUES (101,'Jane Doe','Days');
    INSERT INTO TimeCard VALUES (100, to_date('01012010','ddmmyyyy'), 10.5);
    INSERT INTO TimeCard VALUES (101, to_date('01012010','ddmmyyyy'), 10);
    INSERT INTO TimeCard VALUES (100, to_date('02012010','ddmmyyyy'), 9);
    INSERT INTO TimeCard VALUES (101, to_date('02012010','ddmmyyyy'), 10.5);
    INSERT INTO TimeCard VALUES (100, to_date('03012010','ddmmyyyy'), 8);
    INSERT INTO TimeCard VALUES (101, to_date('03012010','ddmmyyyy'), 7);
    INSERT INTO ShiftChanges VALUES (100, to_date('02012010','ddmmyyyy'), 'Nights', 'Days');
    COMMIT;I could do a query such as:
    SELECT TC.id,
           EM.Name,
           TC.Workday,
           EM.CurrentShift AS Shift
    FROM   TimeCard TC,
           EmployeeInfo EM
    WHERE  (TC.ID=EM.ID(+));But it will not give me the historical shift, only the current. Since John Doe changed shifts on Jan 2 from Nights to Days, the above query would not reflect it.
    I have attempted to join the historical table using a less-than operator. This doesn't work since more than one row can be returned.
    SELECT TC.id,
           EM.Name,
           TC.Workday,
           SC.NewShift AS Shift
    FROM   TimeCard TC,
           EmployeeInfo EM,
           ShiftChanges SC
    WHERE  (TC.ID=EM.ID(+)) AND
           (TC.ID=SC.ID(+) AND TC.WORKDAY<=SC.WORKDAY(+));The problem stems from the fact that you need to examine multiple records in one table in order to obtain the correct historical data for the other.
    The following SQL script {color:green}does work{color} - if the values are defined ahead of time.
    DEFINE EMPID=101;
    DEFINE CHGDATE=to_date('01/01/2010','dd/mm/yyyy');
    SELECT SQ.Shift
    FROM   (SELECT  ShiftChanges.NewShift AS Shift,
                    RANK() OVER (ORDER BY ShiftChanges.ChangeDate DESC) R
            FROM    ShiftChanges
            WHERE   ShiftChanges.id = &EMPID AND
                    ShiftChanges.ChangeDate <= &CHGDATE
            ) SQ
    WHERE R = 1However, I have been unsuccessful in adapting it to the example tables I provided. If I insert the query as an inline subquery* in the select statement, it won't work, since the criteria is nested two levels down, and I can only get parent values within the first level.
    I haven't thought of a way I can do this using a nested subquery - I keep running into that problem - how do you link in Time-Span data with a point-in-time reference.
    Any ideas / enlightening thoughts?
    Thank You
    {size:8}_SELECT * FROM V$VERSION information:_
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
    PL/SQL Release 9.2.0.8.0 - Production
    "CORE     9.2.0.8.0     Production"
    TNS for 32-bit Windows: Version 9.2.0.8.0 - Production
    NLSRTL Version 9.2.0.8.0 - Production
    {size}
    user10879184 re-wrote the original post on 29-Mar-2010 1:21 PM to reflect suggestions made by poster.

    I changed the tables to hold VARCHAR2(6) shift information and your query to reference the ChangeDate column.
    I also assume you meant to link a TimeCard entry with the most previous ShiftChange entry rather than one that occurs after the time worked (TC.WORKDAY>=SC.CHANGEDATE(+) rather than TC.WORKDAY<=SC.CHANGEDATE(+)):
    Another issue you don't take into account the case where there has been no shift change. In that event you need the current shift from the EmployeeInfo table which is taken care of with the NVL function.
    You correctly note that multiple shift change records will result in duplicate TimeCard records though your test data fails to check for that condition. I added this row:
    SQL> INSERT INTO ShiftChanges VALUES (100, to_date('03012010','ddmmyyyy'), 'Days', 'Nights'); Now it is apparent
    SQL> SELECT TC.id,
      2         EM.Name,
      3         TC.Workday,
      4         NVL(SC.NewShift,EM.CurrentShift) AS Shift
      5  FROM   TimeCard TC,
      6         EmployeeInfo EM,
      7         ShiftChanges SC
      8  WHERE  TC.ID=EM.ID(+) AND
      9         TC.ID=SC.ID(+) AND TC.WORKDAY>=SC.CHANGEDATE(+);
            ID NAME                             WORKDAY   SHIFT
           100 John Doe                         01-JAN-10 Days
           100 John Doe                         02-JAN-10 Days
           100 John Doe                         03-JAN-10 Days
           100 John Doe                         03-JAN-10 Nights
           101 Jane Doe                         01-JAN-10 Days
           101 Jane Doe                         02-JAN-10 Days
           101 Jane Doe                         03-JAN-10 Days
    7 rows selected.The reason for the duplicate Jan3 time is the two shift change records. We are matching both ShiftChange records that occured before the 3rd.
    We also see that your test data has John starting out on Days and then shifting from Nights to Days on the 2nd for no real change. Fixing that:
    SQL> DELETE from ShiftChanges where ID = 100;
    2 rows deleted.
    SQL> INSERT INTO ShiftChanges VALUES (100, to_date('02012010','ddmmyyyy'), 'Days', 'Nights');
    1 row created.
    SQL> INSERT INTO ShiftChanges VALUES (100, to_date('03012010','ddmmyyyy'), 'Nights', 'Days');
    1 row created.Then:
    SQL> SELECT TC.id,
      2         EM.Name,
      3         TC.Workday,
      4         NVL(SC.NewShift,EM.CurrentShift) AS Shift
      5  FROM   TimeCard TC,
      6         EmployeeInfo EM,
      7         (SELECT ID, Workday, ChangeDate, NewShift
      8          FROM
      9                 (SELECT TC2.ID, TC2.Workday, SC2.ChangeDate, SC2.Newshift,
    10                         MAX (SC2.ChangeDate) KEEP (DENSE_RANK LAST ORDER BY SC2.ChangeDate)
    11                                              OVER (PARTITION BY SC2.ID, TC2.Workday) AS Max_ChangeDate
    12                  FROM   ShiftChanges SC2,
    13                         TimeCard TC2
    14                  WHERE  TC2.Workday >= SC2.ChangeDate
    15                  AND    TC2.ID = SC2.ID
    16                  )
    17          WHERE   ChangeDate = Max_ChangeDate
    18          ) SC
    19  WHERE  TC.ID=EM.ID(+) AND
    20         TC.ID=SC.ID(+) AND
    21         TC.Workday=SC.ChangeDate(+) AND
    22         TC.Workday = SC.Workday(+);
            ID NAME                             WORKDAY   SHIFT
           100 John Doe                         01-JAN-10 Days
           100 John Doe                         02-JAN-10 Nights
           100 John Doe                         03-JAN-10 Days
           101 Jane Doe                         01-JAN-10 Days
           101 Jane Doe                         02-JAN-10 Days
           101 Jane Doe                         03-JAN-10 Days
    6 rows selected.The inline view finds the greatest ChangeDate less than the TimeCard Workday for each Workday.

  • Content query using linked property [WLP 9.2]

    Hi -
    I've set up a content type in WLP 9.2 that consists of three properties:
    - linkedDevice (Link-Property -> to Node of type Device)
    - linkedTariff (Link-Property -> to Node of type Tariff)
    - combinedPrice (Double-Property)
    Now I'm trying to get the price for such a combination of Device and Tariff by using the <cm:search> like this:
    <cm:search id="prices" query="linkedDevice contains '${device.id}'>
    I've made sure that ${device.id} is initialized to contain something like "/BEA Repository/12345" before calling cm:search.
    Unfortunately, I've not been able to query for Nodes using the tag libs / API so far - and I don't get any errors in the logs for the com.bea.content.manager.* classes.
    Any hints? Anybody? :-)
    Thanks,
    Alex

    Currently we dont support linked property in the metadata search(SQL search). So your search query will not work. But if you want to find out the nodes that link to a particular node, you can use our INodeManager.getNodeReferences(). Please refer to the javadoc of INodeManager for more information.

  • Query via linked server to DB2/NT gives different results

    I have a DB2 9.7 database I need to query. I'm testing from four separate SQL Servers.
    ServerA - SQL 2012 SP2
    ServerB - SQL 2012 SP1
    ServerC - SQL 2012 SP1 CU1
    ServerD - SQL 2012 SP1
    I set up a linked server from ServerA. I run QueryA, and am happy with the results.
    I create a linked server from ServerB. I run QueryA and get the message, "Error converting data type DBTYPE_DBDATE to datetime."
    I did the same test on ServerC. It works fine.
    If, inside OPENQUERY, I convert the datetime to a varchar, call it QueryB, it mostly works, but will be missing a small percentage of datetime values from that converted column when run on ServerB. If I run QueryB on the on ServerA, those missing
    values are there. Same for ServerC.
    At this point, I can think only that the main difference is the service pack and CU level. I can't find any documentation on updates that are relevant, but doesn't mean much.
    Then, I did the same test on ServerD. ServerD is at the same SP/CU level as ServerB. ServerD worked just fine. Apparently it's not the service pack or cumulative update level making the difference.
    My setup: On each server I loaded MS OLE DB Provider for DB2 Version 4.0. I used the same sp_addlinkedserver script with the same connection string on each server. QueryA and QueryB both used OPENQUERY. They were identical except for the CAST to varchar
    for a datetime field. This CAST became a call to a function VARCHAR on the DB2 server in later tests with the same result. 
    Of course, the only place I actually need this working is ServerB.
    tia,
    Steve

    Sure, with some obfuscation and shortening.
    On each server, (except the first where I had to figure it out), I went through the same process.
    Load MS OLE DB Provider for DB2 Version 4.0 version 9.0.1390.0
    Run the Create Linked Server query
    Run QueryA.
    Only on ServerB has this been a problem. 
    --Create Linked Server
    EXEC sp_addlinkedserver
    @server='LinkedServer',
    @srvproduct='Microsoft OLE DB Provider for DB2',
    @catalog='DBName',
    @provider='DB2OLEDB',
    @provstr='Provider=DB2OLEDB;User ID=Username;Password=Password;Initial Catalog=DBName;Network Transport Library=TCPIP;Host CCSID=1252;PC Code Page=1252;Network Address=127.0.0.1;Network Port=50000;Package Collection=MSDB2COL;Process Binary as Character=False;Units of Work=RUW;DBMS Platform=DB2/NT;Use Early Metadata=False;Defer Prepare=False;DateTime As Char=False;Rowset Cache Size=0;Datetime As Date=False;AutoCommit=True;Authentication=Server;Decimal As Numeric=False;Derive Parameters=True;LoadBalancing=False;Persist Security Info=True;Cache Authentication=False;Mode=Read;Connection Pooling=False;'
    --QueryA
    SELECT * FROM OPENQUERY(LinkedServer,'
    SELECT [ARRIVAL]
          ,[ACCT_CODE]
          ,[ACC_EVENT_ID]
          ,[TRANS_DATET]
          ,[AVAIL_DATE]
          ,[AVAIL_STATUS]
      FROM [DBName].[UserName].[TableName]
    ') AS TableNameLink
    --QueryB
    SELECT * FROM OPENQUERY(LinkedServer,'
    SELECT [ARRIVAL]
    ,[ACCT_CODE]
    ,[ACC_EVENT_ID]
    , CAST([TRANS_DATET] AS VARCHAR(26)) TRANS_DATET
    ,[AVAIL_DATE]
    ,[AVAIL_STATUS]
    FROM [DBName].[UserName].[TableName]
    ') AS TableNameLink
    --QueryC
    SELECT * FROM OPENQUERY(LinkedServer,'
    SELECT [ARRIVAL]
    ,[ACCT_CODE]
    ,[ACC_EVENT_ID]
    , VARCHAR([TRANS_DATET]) TRANS_DATET
    ,[AVAIL_DATE]
    ,[AVAIL_STATUS]
    FROM [DBName].[UserName].[TableName]
    ') AS TableNameLink

  • Abap query table link

    Experts Im doing an abap query then I just link the tables adr2 , adr3 , adr6 and lfa1 and lfb1 in infosets "join button"..then show the fields that I need in sq01.But I was wondering why my data becomes times 4..it repeatedly display my data in FOUR times..
    What do you think is the cause of that?

    dear,
    it depends on which table you selected first (Table join using basis table) and how do you insert next tables.
    i am talking about the info-set creation step.
    let's do a simple query.
    run SQ02. type new infoset name and hit Create.
    type name and type MARA for "Table join using basis table" radio button. Hit Continue.
    now insert (add) tables: MARC, MCHA, CABN, CAWN
    think about Inner Join or Left Outer Join !!'
    say, if you need to display all materials (even if not exist on plant) set Left Outer Join. if you're after materials existing on plant keep default Inner Join.
    friend, my example above is only the example.
    make sure you undertsand how to build a sap query in general.
    never set many tables at once. insert 2-3 tables, return to your query (SQ01) or create it, adjust it and test. step by step - table by table. add the new table in infoset, add the fields, generate it and come back to your query. adjust it and test.
    good luck!

  • Query for Linking Two Tables without Reference

    Hi Folks,
    Good Day!
    I have this dilemma on how to link two tables without a reference. In the Business Partner Master Data, there is a field for the Territory which is from the table OTER. This OTER focuses on its description. Once you have added the particular Territory for that Business Partner, it is being stored in the Territory field of the BP right? Our client wants to have an automated way of searching for the Business Partner's Profit Center in creating a Sales Order wherein it is the same as the Business Partner's Territory. The Profit Center is from the table OPRC.
    When I create a Sales Order, after I have entered the Business Partner/Customer Code, the Profit Center should have the value of the Profit Center Code wherein it is the Business Partner's Territory. My query will go like this:
    Enter the BP/Customer Code automatically the Profit Center code where Profit Name = BP's Territory.
    OTER and OCRD don't have connections. How can it be?
    I'm thinking of retrieving the Territory first before the Profit Center but can you suggest of any other way?
    Thank you much!
    Regards,
    Fringe

    Hi Fringe,
    Okay, I already understood your case here. I presume your configuration as follows:
    OTER (Territory)
    territryID - descript
    1 - Philippine
    2 - Indonesia
    3 - Germany
    OPRC (Cost Centre)
    PrcCode - PrcName
    25 - Philippine
    33 - Indonesia
    47 - Germany
    Was above illustration correct? Then, you could use this formatted search in Cost Centre / Dimension field in Sales Order rows
    SELECT PrcCode FROM OPRC WHERE PrcName=(
    SELECT TOP 1 descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0])
    However, I suggest you use a little bit different approach here. Since you can't define Territory Code / Territory ID (you could only type the Territory name, Philippine etc.), why don't you standardize Territory name with Cost Centre code? Let say, you define Philippine as PHI, Indonesia as INA, Germany as DEU and so on. Therefore, user can read the Cost Centre or more precisely Distribution Rules in Sales Order form in more familiar way.
    OTER (Territory)
    territryID - descript
    1 - PHI
    2 - INA
    3 - DEU
    OPRC (Cost Centre)
    PrcCode - PrcName
    PHI - Philippine
    INA - Indonesia
    DEU - Germany
    When FMS worked in Sales Order document, your user will read PHI instead of 25, should be more familiar to them. With that being said, you could use simpler FMS
    SELECT descript FROM OTER T0
    INNER JOIN OCRD T1 ON T0.territryID=T1.Territory
    WHERE T1.CardCode=$[OCRD.CardCode.0]
    You only need to maintain consistency between Territory Name and Cost Centre code. Just my two cents. Hope this help.
    Best Regards,
    Hendry Wijaya

  • Problems querying view link

    I have created a query page that uses a view link do a query. No rows are returned. However, their are several rows in both tables that are represented in the view link.
    Below is the code from the JSP.
    &lt;%@ page
    language="java"
    errorPage="errorpage.jsp"
    contentType="text/html;charset=windows-1252" %&gt;
    &lt;%@ page language="java" import = "oracle.jbo.html.*" %&gt;
    &lt;%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %&gt;
    &lt;%@ include file="ValidateCookie.inc" %&gt;
    &lt;html&gt;
    &lt;head&gt;
    &lt;META NAME="GENERATOR" CONTENT="Oracle JDeveloper"&gt;
    &lt;LINK REL=STYLESHEET TYPE="text/css" HREF="/webapp/css/bc4j.css"&gt;
    &lt;TITLE&gt;Query From&lt;/TITLE&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;jbo:ApplicationModule id="am"
    configname="XPA.XPAModule.XPAModuleLocal"
    releasemode="Stateful" /&gt;
    &lt;jbo:DataSource
    id="ds"
    appid="am"
    viewobject="View_Cu"
    rangesize='&lt;%=XPA.XPAConstants.XPA_RANGE_SIZE%&gt;'/&gt;
    &lt;%--jbo:DataSource
    id="ds"
    appid="am"
    viewobject="LV_Cu_Contact"
    rangesize='&lt;%=XPA.XPAConstants.XPA_RANGE_SIZE%&gt;'/--%&gt;
    &lt;jbo:DataHandler appid="am"
    relativeUrlPath = "/components/XPADataHandlerComponent.jsp" /&gt;
    &lt;%
    String params = HtmlServices.getRequestParameter(pageContext,"jboEvent");
    params= params + "xx";
    if (params.equalsIgnoreCase("nullxx")) {
    %&gt;
    &lt;%-- Roll back any un-finished transactions. We need to do this in any
    %-- first level jsp to negate any uncommited transactions
    --%&gt;
    &lt;jbo:RollBack appid="am" /&gt;
    &lt;h3&gt;Company Search Page&lt;/h3&gt;
    &lt;a href="queryhelp.html"&gt;Search Help&lt;/a&gt;
    &lt;jbo:DataQuery datasource="ds"
    relativeUrlPath="/components/XPADataQueryComponent.jsp" /&gt;
    &lt;%
    %&gt;
    &lt;jbo:OnEvent list="Search, FirstSet, NextSet, PreviousSet, LastSet" &gt;
    &lt;h3&gt;Query Results&lt;/h3&gt;
    &lt;table border="0"&gt;
    &lt;tr&gt;
    &lt;td ALIGN="left"&gt;
    &lt;jbo:DataScroller datasource="ds" /&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;jbo:DataTable datasource="ds"
    relativeUrlPath="Step1DataTableComponent.jsp"
    edittarget="Step1Q_Edit.jsp" /&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    &lt;/jbo:OnEvent&gt;
    &lt;/body&gt;
    &lt;jbo:ReleasePageResources /&gt;
    &lt;/html&gt;
    Any ideas on how to fix this problem?

    Has the view object been execute? Try using the RefreshDataSource tag.

  • Need query to link parent and child discrete job planned through ascp

    Could you help me create a query that will show both the parent and child discrete jobs created through ascp run? I do not need entire query. I need to know the names of tables and understand the links or joins between tables. Then, I shall be able to write the sql on my own.
    Thanks

    Hi;
    Please check below thread which could be helpful for your issue:
    http://forums.oracle.com/forums/thread.jspa?messageID=9155702
    Regard
    Helios

  • Query that link two tables together

    I am using this query to extract  Account Payable data:
    SELECT T0.DocNum, T0.DocStatus, T0.DocDate, T0.DocDueDate, T0.CardCode, T0.CardName, T0.NumAtCard, T0.DocTotal FROM Akron.dbo.OPCH T0
    How would I also add the unique number for each individual payment from these tables?
    OVPM and VPM2.
    What field links these 2 tables together?

    Hi,
    You may check this: Incoming Payments Report
    Replace all INV with PCH and RCV with VPM
    Thanks,
    Gordon

  • Query to link incoming payments with deposit

    hi everyone
    i am looking to develop a query that can link incoming payments with the respective deposit. does anyone have any such query? can you help?
    thanks

    Please use the following.  It shows both check deposits and CC deposits
    SELECT 'CHECK DEPOSIT' [Deposit Type], T0.DEPOSID [Deposit No.], T0.DEPOSDATE [Deposit Date], T0.LOCTOTAL [Desposit Total],
    T2.RCPTNUM [Incoming Payment No.]
    FROM ODPS T0 INNER JOIN DPS1 T1 ON T0.DEPOSNUM = T1.DEPOSITID
    INNER JOIN OCHH T2 ON T2.CHECKKEY = T1.CHECKKEY
    WHERE T0.DEPOSTYPE = 'K'
    UNION ALL
    SELECT 'CREDIT CARD DEPOSIT', T0.DEPOSID, T0.DEPOSDATE, T0.LOCTOTAL, T1.RCTABS
    FROM ODPS T0 INNER JOIN OCRH T1 ON T0.DEPOSNUM = T1.DEPNUM
    WHERE T0.DEPOSTYPE = 'V'
    Best wishes
    Suda

Maybe you are looking for