Passing resultser of one db adapter query to anoother db adapter query

I would like achieve the following:
1) first query returns PO_Number, Batch_Number,..... etc. in the first query. But in this query the PO_NUMBER and batch number can come mutiple times because of other columns.
2) But I have to send a single notification for each Batch_Number/PO-number combination that comes from the above query.
to do that there can be a second db adapter with the query which will be like
select distinct PO_NUMBER, batch number from table1
where Batch_number and PO Number which are selected in the first query.
How to do that?
Is there any other way to fulfil the same requirement.

Hi there,
this is probably more one for the database SQL forums. It is a tricky one as you can't execute a select like:
select distinct PO_NUMBER, distinct BATCH_NUMBER, C3, C4, ....
Safest would be to do this query first:
select distinct PO_NUMBER, BATCH_NUMBER from tab
Then for each PO/BATCH read, execute the following select:
select * from tab where PO = ? and BATCH = ? and rownum <= 1;
However that will lead to a lot of queries to get the extra column info.
You can do it all in one query if you can find one other column in the table that is unique for a given PO/BATCH combination and sortable, i.e. assume it is named pk.
Then you can execute:
select * from TAB T0 where not exists (select * from TAB T1 where T0.PO = T1.PO and T0.BATCH = T1.BATCH and T1.pk< T0.pk)
It took a while but failing that you still can do it with one query. If a, b are the columns that need to be distinct (PO and BATCH), and c is say the other column, you could execute this:
with Q1 as (select distinct A, B, C, rownum as COUNTER from TAB) select T0.A, T0.B, T0.C from Q1 T0 where not exists(select * from Q1 T1 where T1.A= T0.A and T1.B = T0.B and T1.counter < T0.counter)
You can do all of this using the "execute pure SQL" option of the DbAdapter wizard. Just cut and paste in the SQL and it should generate the right XSD.
There is currently one issue with the pure SQL wizard, in that it doesn't recognize WITH. The query has to start with SELECT or it will think it is an update. So just wrap it with SELECT * FROM (...), i.e.
select * from (with Q1 as (select distinct A, B, C, rownum as COUNTER from TAB) select T0.A, T0.B, T0.C from Q1 T0 where not exists(select * from Q1 T1 where T1.A= T0.A and T1.B = T0.B and T1.counter < T0.counter))
That is if you want to do a one time select. If this is more for polling, I would look at the ExpertPolling sample on soasamples.samplecode.oracle.com for ideas. You can set the primary key to be PO/BATCH, and give custom poll and after read SQLs. The poll can be very similar to the one given here.
Thanks
Steve

Similar Messages

  • How to pass more than one parameter using common...

    Hi,
    I am using ODP.NET with my 2005 VB
    I want to create function from where I can pass more than one parameter to execute SP, or query just like i created for SQL SERVER as below
    Public shared Function CreateParameter(ByVal paramname As String, ByVal paramvalue As Object) As DbParameter
    Dim param As DbParameter
    param = New SqlParameter
    param.ParameterName = paramname
    param.Value = paramvalue
    Return param
    End Function
    Public Shared Function ExecuteQuery(ByVal sql As String, ByVal commtype As CommandType, ByVal ParamArray parameter As DbParameter())
    Dim cmd As DbCommand = New SqlCommand()
    cmd.Connection = OpenConnection()
    cmd.CommandType = commtype
    cmd.CommandText = sql
    cmd.Parameters.AddRange(parameter)
    Dim RetVal As Integer = cmd.ExecuteNonQuery()
    Return RetVal
    End Function
    specially part is in bold to be converted
    I tried like but oracleCommand.parameters doesnt support AddRange
    please help me out
    Regards

    Hello,
    I used the following way:
    pCommand.CommandText = "Update " + sDataTable + " set "
    + sColumnName + " = :1 ";
    pCommand.Parameters.Add("ValueToDb",
    this.DefaultDbType,
    this.m_Value,
    System.Data.ParameterDirection.Input);
    Of course, you can add :2,... to your command text, too.
    The way back is:
    sEndOfTheClause += " RETURNING " + sDataTable + "." + sColName + " INTO :iNewValue";
    pCommand.CommandText = ... + sEndOfTheClause;
    pCommand.Parameters.Add("iNewValue", this.DefaultDbType,
    ParameterDirection.Output);
    bool bReturn = (pCommand.ExecuteNonQuery() != 0);
    if ((bReturn == true) && (pCommand.Parameters.Count > 0))
    this.Value = DataService.Convert<DATA_TYPE>(pCommand.Parameters[0].Value);
    ....

  • How to pass more than one parameter

    Hello,
    This is my code.
    How to pass more than one parameter:
    SELECT:responsibility_name responsibility_name,
    LPAD(' ', 6*(LEVEL-1))
      || menu_entry.entry_sequence sequence ,
      LPAD(' ', 6*(LEVEL-1))
      || menu.user_menu_name SubMenu_Description ,
      LPAD(' ', 6*(LEVEL-1))
      || func.user_function_name Function_Description ,
      LPAD(' ', 6*(LEVEL-1))
      || menu_entry.prompt prompt
      ,menu.menu_id ,
      func.function_id
      --menu_entry.grant_flag Grant_Flag ,
      --DECODE( menu_entry.sub_menu_id , NULL, 'FUNCTION' , DECODE( menu_entry.function_id , NULL, 'SUBMENU' , 'BOTH') ) Type
    FROM fnd_menu_entries_vl menu_entry ,
      fnd_menus_tl menu ,
      fnd_form_functions_tl func
    WHERE menu_entry.sub_menu_id    = menu.menu_id(+)
    AND menu_entry.function_id      = func.function_id(+)
    AND MENU.LANGUAGE(+) = 'US'
    AND FUNC.LANGUAGE(+) = 'US'
    --AND func.user_function_name LIKE '%Primary Care Providers%'
    AND grant_flag                  = 'Y'
      START WITH menu_entry.menu_id =
      (SELECT menu2.menu_id
      FROM fnd_menus_tl menu2,apps.fnd_responsibility_vl resp
      WHERE menu2.menu_id=resp.menu_id
      and resp.responsibility_name= :responsibility_name
      --and menu2.user_menu_name = ('ATCO HR INQ USER'
      AND LANGUAGE = 'US'
      CONNECT BY MENU_ENTRY.MENU_ID = PRIOR MENU_ENTRY.SUB_MENU_ID
       and menu_entry.function_id not in (select func.function_id
                                       from --fnd_form_functions_vl fnc,
                                       apps.fnd_resp_functions exc,
                                       apps.fnd_responsibility_vl res
                                      where func.function_id = exc.action_id
                                      and res.responsibility_name =:responsibility_name
                                      and res.responsibility_id=exc.responsibility_id)
      and menu_entry.sub_menu_id  not in (select menu.menu_id
                                       from --fnd_menus_vl imn,
                                       apps.fnd_resp_functions exc,
                                       apps.fnd_responsibility_vl res
                                       where menu.menu_id = exc.action_id
                                       and res.responsibility_name =:responsibility_name
                                      and res.responsibility_id=exc.responsibility_id)
    ORDER SIBLINGS BY menu_entry.entry_sequence;
    Thank you for your help
    Shuishenming

    Hi, Ming,
    One way is to put the "parameters" in a table, and join to that table in your query.  If you make it a Global Temporary Table, then multiple sessions can run the query at the same time, and each can be seeing different responsibilities.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.  Since this problem involves parameters, you should give a couple of different sets of parameters, and the results you want from the same sample data for each set.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Query operation in file adapter

    Dear All,
    we have faced several issues in using polling for production env.
    We have to ensure sequential nature of data, which means FIFO order of inserts
    is there any alternative to using polling - Receive in file adapter ?
    Can we use {query database adapter  - invoke activity } in file adapter ?
    Please let me know if any body as any leads.
    Appreciate your response.
    Regards
    Arc

    we cant use Invoke activity for Read functionality for File Adapter but there is another way to achive this we can use two recieve activities in one BPEL please find the Sample here $BPEL_HOME\samples\tutorials\109.CorrelationSets
    Krishna

  • Change query dynamically in DB Adapter

    Hi,
    Please answer these questions.
    1. How to change query dynamically in DB Adapter?
    2. I have 2 db adapters, if i got error in 1 db adapter then how to rollback?
    Regards,
    kpr

    Hi,
    <div class="jive-quote">How to change query dynamically in DB Adapter?</div>
    Unfortunately there is no way to pass the query dynamically in DB Adapter. The reasoning behind that is that the DB adapter configuration wizard creates multiple assist files for each operation including the xsd which can not be created for any query dynamically.
    <div class="jive-quote">I have 2 db adapters, if i got error in 1 db adapter then how to rollback?</div>
    Either use XA datasources or throw a rollback fault in the catch block.
    Regards,
    Neeraj Sehgal

  • Complex SQL Query in BPEL DB Adapter

    Hi,
    Is it possbile to write a complex query in BPEL DB Adapter using "Custom SQL Query"?
    I would like to write an IF ELSE condition in the DB Adapter similar what is given below..
    IF((SELECT COUNT(*) FROM F5898001 WHERE CT58SRCNME = 'CA_TEST' AND CTJOBNAME = '12345' AND CTEDBT = 'EDBT' AND CTEDSP = 'B') < 1)
    BEGIN
    insert into f5898001 (CTJOBNAME,CTEDSP,CTEDBT,CT58SRCNME) VALUES (#jobname, #edsp, #edbt, #srcnme)
    END.

    In a single pass no.
    You could use a DB link to perform select and return result to BPEL process variable. Put a switch decision depending on result in variable that calls a DB Adapter to perform the insert.
    Wouldn't be in a single transaction and not very elegant, but might be a way round.

  • Custom query conditions in db adapter

    Hello,
    How to execute custom query in bpel db adapter?
    For example :
    1. select * from employee where status = 'N' and address is not null
    2. select * from empoyee where substatus = 'Y' and phone is null
    after where keyword - query part is dynamic, parameter combinations and count is unlimited ( depends on business logic ). It is not possible to implement each condition parameter as parameter in db adapter configuration.
    Db adatper query has to be something like  : select * from employee where #condition# , but #condtion# need to be interpretated as condition not string with quotes..
    best Regards,
    Uldis

    Say your complete query looks like this -
    select SUBJECT_NAME from RELATION
                where PID_GID_SSID IN (select PARTY_KEY from  xref WHERE row_id='123')
    1). In assign activity, write out the query part which comes after where clause and assign to variable query
    (select PARTY_KEY from  xref WHERE row_id='123') , replace the value of row_id from input value in assign.
    2. Now open DB adapter and pass the rest of query as input -
    select SUBJECT_NAME from RELATION
                where PID_GID_SSID IN #query

  • Output of One Query  is input to other Query??

    Hi All,
    How to make output of one query as input to other Query and what are the points to be takeb care of to do it?
    regards,
    murali.
    Message was edited by: Murali

    Hallo
    You got a second query where you also have 0date. Based on the selection on the second query, you get some value for 0date. this values are then passed in background to the first query which will show you the output based on the input date of the first query. You can also have othe variable in the query.
    http://help.sap.com/saphelp_nw04/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    I hope everything is fine.
    Mike

  • Problem passing parameter from one interactive report to another

    Hi.
    I'm going slightly mad over this simple problem.
    Apex 4.0.2 installed. Created one interactive report with 4 columns, one is linked to a custom target which is another interactive report where the column is used in the WHERE clause through a hidden field value.
    This works fine in other applications on same Apex install, but not in this one.... Writing the hidden field to the screen shows that it gets the correct value from the first report, but the SQL-query returns no rows when querying on the :<parameter_name> value (there are rows in database - query runs fine when hard coding a value).
    Tried link column both directly from the column value link definition, and from the report definition - both pass value ok to hidden field, but SQL-query doesn't pick it up.
    Tried deleteing and recreating second report page, same problem.
    Anyone else had this problem? Are there any properties on the pages/fields that I've forgot to set, that may cause the session value not to be set when the query is running? I've got it working in other apps, and can't find anything done differently there....
    Regards,
    -Haakon-

    Yes, it shows the correct value. Also creating a second text field and assigning it the Source value of the hidden field shows the correct value in the textbox on page load.
    It's only the report's sql query that doesn't seem to get the value. Hard coding a document number (without hyphens etc) works fine, I get the expected records - so the rest of the query is correct.
    Tried '=' and LIKE - but still nothing...
    It's just the sql variable substitution of :P21_DOCNO that under no circumstance will work.... also tried a simple pl/sql block with the variable - nothing.... using the V('P21_DOCNO') - nothing....
    It seems like the sql query is parsed and run before the hidden field gets it's value or something....
    This is very strange - as it works in another application on same Apex installation.

  • Passing Variables from one View to another

    First of all Hi this is my first post on the sap forums.
    Aplogies if I have come to the wrong place or if this question is very easy, but I am new to abap and web dynpro and have found myself struggling a little bit.  So I stumbled across this site and thought I would ask for help.
    My problem is this, I have 2 variables on my MAIN view, one called MONTH and the other called YEAR.  What I want to do is on a button click on the MAIN view pass the values of these variables to another view called SUMMARY_RPT and then use these variables in an SQL query I have on this view.
    Anybody out there that can help ?
    Many Thanks,
    George

    Hi George,
    Welcome to webdynpro abap community. To pass data from one view to another, you can should create two attributes (type string) in the attribute tab of of the component controller. Now these will act as global variable for you. Now you can access these attribute in your view in this way:
    wd_comp_controller->gv_val "gv_val is the name of the attribute
    Populate the value in it and use it anywhere you want.
    There is one more way to do the same.
    Create a node under context in component controller and create 2 attributes(type string) after that. Map this node to both the views. Now get the value of month , year and set these attribute with the same values with the help of code wizard in view 1. Now in the view2 simply read those attribute and you'll get the value of month and year which was entered in the first view. Read the attribute with the help of code wizard. Now you can use them accordingly.
    I would suggest you to use 1st method as it is better performance wise.
    I hope it helps.
    Regards
    Arjun

  • Passing parameters from one callablestatement to another

    I need to run multiple stored procedures. The first one generates a ident key and returns it as an output parameter. The remaining procs need to take the ident key from proc 1 and use it as an input parameter. When I do this I get a SQLException for an RI violation saying the row (inserted by the first call) containing the primary key (ident field) does not exist. I have had our DBA look at this and he says it should work fine. I can run the 2 stored procs, passing the output parameter from the first to the second in query analyzer and it works just fine. Here is my Java code:
    try{
    connection.setAutoCommit(false);
    callStmt = connection.prepareCall("{call insert_proc_1 (?, ?)}");
    callStmt.setString(1, "xxxx");
    callStmt.registerOutParameter(2, java.sql.Types.INTEGER);
    callStmt.execute();
    long primaryKey = callStmt.getLong(2);
    callStmt.close();
    callStmt2 = connection.prepareCall("{call insert_proc_2 (?, yyyy, xxxx, ?)}");
    callStmt2.setLong(1, primaryKey);
    callStmt2.registerOutParameter(2, java.sql.Types.INTEGER);
    callStmt2.execute();
    long secondKey = callStmt2.getLong(2);
    callStmt2.close();
    connection.commit();
    connection.close();
    return secondKey;
    } catch(SQLException e){
    connection.rollback();
    connection.close();
    return -1;
    What am I doing wrong?
    Thanks,
    Jim

    Oh never mind. I switched to another JDBC driver and the code works just fine.

  • How can I pass more than one parameters in PDK-URL services?

    Hi all,
    How can I pass more than one parameters in PDK-URL service? All samples on Portal Center shows just one parameter passing.
    <inputParameter class="oracle.portal.provider.v1.URLPortletParameter">
    <name>csz</name>
    <isMandatory>false</isMandatory>
    <displayName>What location do you want a map for (City, State or Zip)?</displayName>
    </inputParameter>
    How can I write the privider.xml file for passing multiple parameters?

    I answer to my question. I've got the answer.
    I repeatly write down the <inputParameter> tags, and it works.

  • How can I pass parameters from one process flow to another process flow?

    How can I pass parameters from one process flow to another process flow (sub process) in warehouse builder? let me know the steps I have to do in warehouse builder.
    Thanks in advance,
    Kishan

    Hi Kishan,
    Please post this question to the Warehouse Builder forum:
    Warehouse Builder
    Thanks, Mark

  • HT201250 how can i pass information from one mac to another mac by using the time capsule

    how can i pass information from one mac to another mac by using the time capsule

    If you want to transfer files, settings, etc., you must open Migration Assistant (Applications > Utilities) in the Mac that you want to transfer the files and follow the instructions

  • How can i pass the value one from to another form?

    hi all
    how can i pass the value one from to another form  with out use it when ever i want to needed this value that ican useit?
    like i have two fields U_test1 and U_test2  table name @AUSR
    that i have  four form  A! , A2,A3,A4    please tell me in details....?

    Hi,
    U can assign the values to some variables and access then in ur required forms.
    Vasu Natari.

Maybe you are looking for