Slecting records from MSAccess tables using multiple conditions

Hi,
I am trying to build s select list of team names for a
sporting club website. The select list should include teams if the
currently logged in user is a coach, team manager, assistant coach,
player or a parent of a player.
When I have only one group of conditions in the where clause
it works fine. But that only accounts for one of the above roles.
As soon as I ad an OR and another set of criteria my CF7 server's
swsoc.exe goes into an permanent loop (well, at least 10 minutes, I
reboot after that :-)
For example, this works fine ...
<!--- select teams I coach, assistant coach, manage, am a
parent of a player, or am a player --->
<cfquery name="teams"
Datasource="#Application.Datasource#">
SELECT distinct teams.uid_team, team_name, uid_coach,
uid_team_manager, uid_coordinator, team_asst
from teams, player_agegroups, players
where
(player_agegroups.uid_team=teams.uid_team and
players.uid_user=player_agegroups.uid_user
and teams.uid_season=#session.season# and
players.uid_invoice_to=#session.userid#)
Order by team_name
</cfquery>
But as soon as I add another condition cf7 goes into a
loop...
<!--- select teams I coach, assistant coach, manage, am a
parent of a player, or am a player --->
<cfquery name="teams"
Datasource="#Application.Datasource#">
SELECT distinct teams.uid_team, team_name, uid_coach,
uid_team_manager, uid_coordinator, team_asst
from teams, player_agegroups, players
where
(player_agegroups.uid_team=teams.uid_team and
players.uid_user=player_agegroups.uid_user
and teams.uid_season=#session.season# and
players.uid_invoice_to=#session.userid#) or
(player_agegroups.uid_team=teams.uid_team and
players.uid_user=player_agegroups.uid_user
and teams.uid_season=#session.season# and
players.uid_user=#session.userid#) or
(player_agegroups.uid_team=teams.uid_team and
players.uid_user=player_agegroups.uid_user
and teams.uid_season=#session.season# and
teams_uid_coach=#session.userid#) or
(player_agegroups.uid_team=teams.uid_team and
players.uid_user=player_agegroups.uid_user
and teams.uid_season=#session.season# and
teams.team_asst=#session.userid#) or
(player_agegroups.uid_team=teams.uid_team and
players.uid_user=player_agegroups.uid_user
and teams.uid_season=#session.season# and
teams.uid_team_manager=#session.userid#)
Order by team_name
</cfquery>
Any combination hangs CF7, whether it be two, three or all
conditions, and any combination of conditions..
The teams table stores team name, coach, team manager,
assistant coach and coordinator. Players table stores the player
records, and the parent (uid_invoice_to), is part of the player
record. player agegroups has the teams, with a record for each
player in a team. The whole system is based around seasons, hence
the #session.season# variable.
What should happen is I get a very short list of teams. When
I select a team from the select list I then go and grab all the
player records from the player_agegroups table joined to the users
table to get their names, date of birth etc...
Can anyone see what I am doing wrong?
thanks
Tanya

Rustywater wrote:
>
> For example, this works fine ...
>
> <!--- select teams I coach, assistant coach, manage,
am a parent of a player,
> or am a player --->
> <cfquery name="teams"
Datasource="#Application.Datasource#">
> SELECT distinct teams.uid_team, team_name, uid_coach,
uid_team_manager,
> uid_coordinator, team_asst
> from teams, player_agegroups, players
> where
> (player_agegroups.uid_team=teams.uid_team and
> players.uid_user=player_agegroups.uid_user
> and teams.uid_season=#session.season# and
> players.uid_invoice_to=#session.userid#)
> Order by team_name
> </cfquery>
>
> But as soon as I add another condition cf7 goes into a
loop...
>
> <!--- select teams I coach, assistant coach, manage,
am a parent of a player,
> or am a player --->
> <cfquery name="teams"
Datasource="#Application.Datasource#">
> SELECT distinct teams.uid_team, team_name, uid_coach,
uid_team_manager,
> uid_coordinator, team_asst
> from teams, player_agegroups, players
> where
> (player_agegroups.uid_team=teams.uid_team and
> players.uid_user=player_agegroups.uid_user
> and teams.uid_season=#session.season# and
> players.uid_invoice_to=#session.userid#) or
> (player_agegroups.uid_team=teams.uid_team and
> players.uid_user=player_agegroups.uid_user
> and teams.uid_season=#session.season# and
players.uid_user=#session.userid#) or
> (player_agegroups.uid_team=teams.uid_team and
> players.uid_user=player_agegroups.uid_user
> and teams.uid_season=#session.season# and
teams_uid_coach=#session.userid#) or
> (player_agegroups.uid_team=teams.uid_team and
> players.uid_user=player_agegroups.uid_user
> and teams.uid_season=#session.season# and
teams.team_asst=#session.userid#) or
> (player_agegroups.uid_team=teams.uid_team and
> players.uid_user=player_agegroups.uid_user
> and teams.uid_season=#session.season# and
> teams.uid_team_manager=#session.userid#)
> Order by team_name
> </cfquery>
You are not just OR'ing your data filter, you are also OR'ing
the
relations between tables. You should define the relations
between your
tables in explicit JOIN statements in your FROM, and filter
the data in
your WHERE. You should also remove duplice filters in your
WHERE
statement. That would look something like:
SELECT DISTINCT
teams.uid_team,
team_name,
uid_coach,
uid_team_manager,
uid_coordinator,
team_asst
FROM
(teams INNER JOIN
player_agegroups ON
player_agegroups.uid_team=teams.uid_team)
INNER JOIN players ON
players.uid_user=player_agegroups.uid_user
WHERE
teams.uid_season=#session.season#
AND
players.uid_invoice_to=#session.userid#
OR
players.uid_user=#session.userid#
OR
teams_uid_coach=#session.userid#
OR
teams.team_asst=#session.userid#
OR
teams.uid_team_manager=#session.userid#
ORDER BY
team_name
Jochem
Jochem van Dieten
Adobe Community Expert for ColdFusion

Similar Messages

  • How to read records from Relationship table using ABAP API's

    Hi All,
    I need to retrieve the records from Relationship table. In Java API's I came to know there is an option to retrieve this. I could not find anything in ABAP API's. Is there any option in ABAP API's to do this.
    Please Suggest.
    Thank You,
    Gajendra.

    Hi Gajendra,
    You can mainly read records from MDM (in a DDIC structure) using ABAP API's using the following function modules/methods:
    1. RETRIEVE: This is used to generically retrieve records from tables. Attributes and Values can also be retrieved.
    2. RETRIEVE SIMPLE: Retrieve records from MDM in a simple way.( simple data types).
    3. RETRIEVE CHECKOUT: Retrieves all checked out ID's.
    4. RETRIEVE ATTRIBUTES: Retrieves attribute(s) from a Taxanomy table.
    You will find all these methods in the following interface
    Interface : IF_MDM_CORE_SERVICES
    Hope it helps.
    *Please reward points if found useful.
    Thanks and Regards
    Nitin Jain

  • How to fetch corresponding records from 2 tables using ADF Toplink & EJB

    Hi,
    I am unable to fetch records from 2 tables, which has a foregin key.Used the custom query in toplink, But the output is the cartition of the first table draged and the first row of the second table.The output required should be in the form of ADF Table. I am able to find the output in JSF data table.
    Two tables:
    Table name:Solutions
    sol_id varchar2(PK)
    sol_name varchar2
    Table name:Solution_details
    sol_id varchar2(FK)
    common_asum_id varchar2(PK)
    common_detail varchar2
    Output Required:
    sol_id,sol_name,common_asum_id,common_detail
    Custom query:
    SELECT * FROM solutions a
    ,solution_details b
    WHERE a.sol_id=b.sol_id

    Hi,
    I am unable to fetch records from 2 tables, which has a foregin key.Used the custom query in toplink, But the output is the cartition of the first table draged and the first row of the second table.The output required should be in the form of ADF Table. I am able to find the output in JSF data table.
    Two tables:
    Table name:Solutions
    sol_id varchar2(PK)
    sol_name varchar2
    Table name:Solution_details
    sol_id varchar2(FK)
    common_asum_id varchar2(PK)
    common_detail varchar2
    Output Required:
    sol_id,sol_name,common_asum_id,common_detail
    Custom query:
    SELECT * FROM solutions a
    ,solution_details b
    WHERE a.sol_id=b.sol_id

  • Select records from MS Access tables using multiple conditions

    Hi,
    I am trying to build s select list of team names for a
    sporting club website. The select list should include teams if the
    currently logged in user is a coach, team manager, assistant coach,
    player or a parent of a player.
    When I have only one group of conditions in the where clause
    it works fine. But that only accounts for one of the above roles.
    As soon as I ad an OR and another set of criteria my CF7 server's
    swsoc.exe goes into an permanent loop (well, at least 10 minutes, I
    reboot after that :-)
    For example, this works fine ...
    <!--- select teams I coach, assistant coach, manage, am a
    parent of a player, or am a player --->
    <cfquery name="teams"
    Datasource="#Application.Datasource#">
    SELECT distinct teams.uid_team, team_name, uid_coach,
    uid_team_manager, uid_coordinator, team_asst
    from teams, player_agegroups, players
    where
    (player_agegroups.uid_team=teams.uid_team and
    players.uid_user=player_agegroups.uid_user
    and teams.uid_season=#session.season# and
    players.uid_invoice_to=#session.userid#)
    Order by team_name
    </cfquery>
    But as soon as I add another condition cf7 goes into a
    loop...
    <!--- select teams I coach, assistant coach, manage, am a
    parent of a player, or am a player --->
    <cfquery name="teams"
    Datasource="#Application.Datasource#">
    SELECT distinct teams.uid_team, team_name, uid_coach,
    uid_team_manager, uid_coordinator, team_asst
    from teams, player_agegroups, players
    where
    (player_agegroups.uid_team=teams.uid_team and
    players.uid_user=player_agegroups.uid_user
    and teams.uid_season=#session.season# and
    players.uid_invoice_to=#session.userid#) or
    (player_agegroups.uid_team=teams.uid_team and
    players.uid_user=player_agegroups.uid_user
    and teams.uid_season=#session.season# and
    players.uid_user=#session.userid#) or
    (player_agegroups.uid_team=teams.uid_team and
    players.uid_user=player_agegroups.uid_user
    and teams.uid_season=#session.season# and
    teams_uid_coach=#session.userid#) or
    (player_agegroups.uid_team=teams.uid_team and
    players.uid_user=player_agegroups.uid_user
    and teams.uid_season=#session.season# and
    teams.team_asst=#session.userid#) or
    (player_agegroups.uid_team=teams.uid_team and
    players.uid_user=player_agegroups.uid_user
    and teams.uid_season=#session.season# and
    teams.uid_team_manager=#session.userid#)
    Order by team_name
    </cfquery>
    Any combination hangs CF7, whether it be two, three or all
    conditions, and any combination of conditions..
    The teams table stores team name, coach, team manager,
    assistant coach and coordinator. Players table stores the player
    records, and the parent (uid_invoice_to), is part of the player
    record. player agegroups has the teams, with a record for each
    player in a team. The whole system is based around seasons, hence
    the #session.season# variable.
    What should happen is I get a very short list of teams. When
    I select a team from the select list I then go and grab all the
    player records from the player_agegroups table joined to the users
    table to get their names, date of birth etc...
    Can anyone see what I am doing wrong?
    thanks
    Tanya

    You might try to change your query using a SQL JOIN command,
    so you can link the appropriate tables independently from the WHERE
    selection criteria. You could use Access to create the query and
    then go to the SQL command view to get the correct synyax.

  • Deleting data from another table with multiple conditions

    Hi frnds
    I need to delete some data from a table based on multiple condition I tried following sql but its deleteing some rows which is not meeting the criteria which is really dangerours. When i trying = operator it returns ORa- 01427 single -row subquery returns more than one row
    delete from GL_TXNS
    where TRN_DT in (Select trn_Dt from GL_MAT)
    and BR in (select ac_branch from GL_MAT)
    and CODE in (select CODE T from GL_MAT)
    and (lcy_amt in (select lcy_amt from GL_MAT) or
    fcy_amt in(select fcy_amt from GL_MAT)
    rgds
    ramya

    My answer is the same as Avinash's but I will explain a little bit more.
    ORa- 01427 single -row subquery returns more than one rowmeans that you have a subquery that Oracle is expecting one value from that is returning multiple values. In your case you need one value for the equijoin ("=") and you are getting more than one value back. The error happens even if all the values are the same - multiple values being returned will cause the error.
    The solution is to either allow multiple values to be returned (say, use the IN condition istead of "=") or only return one value if possible (say, forcing one value by using DISTINCT, GROUP BY, or a WHERE clause condition of ROWNUM=1) - but these workarounds must be checked carefully to make sure they work correctkly

  • Delete records from internal table using another internal table

    HI,
    I have two internal tables itab1 and itab2 which have same records initially.Later some records of itab2 are deleted .Then i want to delete those records from itab1 also ie,those records not found in itab2 .Is there any method other than looping.
    So that itab1 again becomes equal to itab2.
    Thanks in advance.
    Sowmya.

    Soumya,
    Itab1 , Itab2 .
    Before deleting the records from itab2  move those records to one more internal table itab3.
    Now you have deleted records  of itab2  in itab3.
    SORT ITAB3,ITAB1 by your main key field.
    LOOP AT itab3.
      READ TABLE ITAB1 WITH KEY key field = itab3-
      keyfield.
    IF sy-subrc EQ 0.
    DELETE itab1 where keyfield eq itab3-keyfield.
    ENDIF.
    ENDLOOP.

  • Issue in retrieving all the records from ADF Table with multiple row

    Hi,
    As per my requirement, I need to fill the table with multi selected LOV values and when user clicks on commit, I need to save them to database.
    I am using ADF 11g, Multi select table. Using the below ADD method, I am able to add the records but if user clicks on cancel, I need to remove those from view and clear the table as well.
    But the Issue I am facing is, in my cancel method, always I am getting half of the records. Lets assume table contains 100 records but in my cancel method, I am getting only 50 records.
    Please let me know what is the issue in my source code.
    ADD Method:
    public void insertRecInCMProcessParamVal(String commType, String processType, Number seqNumber){       
    try{
    Row row = this.getCmProcessParamValueView1().createRow();
    row.setAttribute("ParamValue7", commType);
    row.setAttribute("ProcessType", processType);
    row.setAttribute("CreationDate", new Date());
    row.setAttribute("CreatedBy", uid);
    row.setAttribute("ParamValueSeqNum", seqNumber);
    row.setAttribute("ProcessedFlag", "N");
    this.getCmProcessParamValueView1().insertRow(row);
    }catch(Exception e){           
    e.printStackTrace();
    Table Code:
    <af:table value="#{bindings.CmProcessParamValueView11.collectionModel}"
    var="row"
    rows="#{bindings.CmProcessParamValueView11.rangeSize}"
    emptyText="#{bindings.CmProcessParamValueView11.viewable ? 'No data to display.' : 'Access Denied.'}"
    fetchSize="#{bindings.CmProcessParamValueView11.rangeSize}"
    rowBandingInterval="1"
    selectedRowKeys="#{bindings.CmProcessParamValueView11.collectionModel.selectedRow}"
    selectionListener="#{bindings.CmProcessParamValueView11.collectionModel.makeCurrent}"
    rowSelection="multiple"
    binding="#{backingBeanScope.backing_app_RunCalcPage.t1}"
    id="t1" width="100%" inlineStyle="height:100px;" >
    <af:column sortProperty="ParamValue6"
    sortable="true"
    headerText="#{bindings.CmProcessParamValueView11.hints.ParamValue6.label}"
    id="c1" visible="false">
    <af:inputText value="#{row.bindings.ParamValue6.inputValue}"
    label="#{bindings.CmProcessParamValueView11.hints.ParamValue6.label}"
    required="#{bindings.CmProcessParamValueView11.hints.ParamValue6.mandatory}"
    columns="#{bindings.CmProcessParamValueView11.hints.ParamValue6.displayWidth}"
    maximumLength="#{bindings.CmProcessParamValueView11.hints.ParamValue6.precision}"
    shortDesc="#{bindings.CmProcessParamValueView11.hints.ParamValue6.tooltip}"
    id="it3">
    <f:validator binding="#{row.bindings.ParamValue6.validator}"/>
    </af:inputText>
    </af:column>
    <af:column sortProperty="ParamValue7"
    sortable="true"
    headerText="Comm Type"
    id="c2">
    <af:inputText value="#{row.bindings.ParamValue7.inputValue}"
    label="#{bindings.CmProcessParamValueView11.hints.ParamValue7.label}"
    required="#{bindings.CmProcessParamValueView11.hints.ParamValue7.mandatory}"
    columns="#{bindings.CmProcessParamValueView11.hints.ParamValue7.displayWidth}"
    maximumLength="#{bindings.CmProcessParamValueView11.hints.ParamValue7.precision}"
    shortDesc="#{bindings.CmProcessParamValueView11.hints.ParamValue7.tooltip}"
    id="it4">
    <f:validator binding="#{row.bindings.ParamValue7.validator}"/>
    </af:inputText>
    </af:column>
    <af:column sortProperty="ParamValue8"
    sortable="true"
    headerText="#{bindings.CmProcessParamValueView11.hints.ParamValue8.label}"
    id="c3" visible="false">
    <af:inputText value="#{row.bindings.ParamValue8.inputValue}"
    label="#{bindings.CmProcessParamValueView11.hints.ParamValue8.label}"
    required="#{bindings.CmProcessParamValueView11.hints.ParamValue8.mandatory}"
    columns="#{bindings.CmProcessParamValueView11.hints.ParamValue8.displayWidth}"
    maximumLength="#{bindings.CmProcessParamValueView11.hints.ParamValue8.precision}"
    shortDesc="#{bindings.CmProcessParamValueView11.hints.ParamValue8.tooltip}"
    id="it2">
    <f:validator binding="#{row.bindings.ParamValue8.validator}"/>
    </af:inputText>
    </af:column>
    </af:table>
    Backing Bean Code:
    DCBindingContainer dcBindings=(DCBindingContainer)getBindings();
    DCIteratorBinding dcIterator=dcBindings.findIteratorBinding("CmProcessParamValueView1Iterator");
    RowSetIterator rs = dcIterator.getRowSetIterator();
    System.out.println("In Cancel Row Count is : "+ rs.getRowCount());
    if (rs.getRowCount() > 0) {
    Row row = rs.first();
    row.refresh(Row.REFRESH_UNDO_CHANGES);
    row.remove();
    while (rs.hasNext()) {
    int count = rs.getRowCount();
    System.out.println("Count is : "+ count);
    Row row = rs.next();
    System.out.println("Row === "+ row);
    if(row != null){                   
    row.refresh(Row.REFRESH_UNDO_CHANGES);
    row.remove();
    Thanks.

    Issue resolved.
    remove selectionListener and selectedRowKeys....
    code to get all the selectedRows.
    RowSetIterator rs = dcIterator.getRowSetIterator();
    RowKeySet rks = this.t1.getSelectedRowKeys();
    Iterator rksIter = rks.iterator();
    while (rksIter.hasNext()) {
    List l = (List) rksIter.next();
    Key key = (Key)l.get(0);
    Row row = rs.getRow(key);
    Thanks.

  • Reading Locked records from HR table using LDB PNP

    Hi,
    I am trying to read the table pa0168 using LDB PNP.
    But the problem is that get pernr staement does not retrieve locked records i.e where PA0168-sprps eq "X'.
    Can anybody help me with this.
    I have to use LDB  so i don't want a solution of writing a select * for the pa0168 table.
    hence i have to use get pernr statement but it should also retrieve locked records.
    how can i achieve that.? please help
    Thanks
    GT
    Message was edited by: GT

    Hi GT,
    In the START-OF-SELECTION event, set the parameter value
    pnp-sw-ignorelockedrecords = 'N'.
    Good Luck,
    Suresh Datti
    ( Pl award points if the answer helps you )

  • Extracting records from 3 tables using joins in MySQL

    Hi All,
    Pls help me urgently...
    I have a n Order Processing Module and I have 4 tables for this.
    When a new order is placed these 2 tables are populated.
    Order_Customer : records details abt the direct customer/dealer who places the order.
    Order_Product : records the details abt the product (qty, unit price, taxes etc).
    At the Supplier's end the newly placed orders are accepted or rejected and notification is passed on to the despatch dept.
    No when Acceptance authority logs in all the new orders should be viewed..all the previously accepted orders should not be displayed. Here OrderId, OrderDate, Cust/Deal Name (from Order_Customer) and Product, Qty, OrdValue (from Order_Product) are to be displayed. My normal join qry does not work here
    "SELECT * FROM Order_Customer,Order_Product where Order_Customer.OSerialNo NOT IN (SELECT OrdCustSrNo FROM Order_Acceptance) AND Order_Product.OrdCustSrNo NOT IN (SELECT OrdCustSrNo FROM Order_Acceptance) AND Order_Customer.OSerialNo=Order_Product.OrdCustSrNo"
    This gives an error "Unable to load driver.java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near 'SELECT OrdCustSrNo FROM Order_Acceptance) AND Order_Product.OrdCustSrNo NOT IN (' at line 1 "
    Also tried
    "SELECT Order_Customer.* FROM Order_Customer LEFT JOIN Order_Acceptance ON Order_Customer.OSerialNo = Order_Acceptance.OrdCustSrNo where Order_Acceptance.OrdCustSrNo IS NULL";
    Here it gives error Column Name Product not found.
    Similar is the case when moving an Accepted Order to Despatch Dept.
    Need help urgently.

    "SELECT Order_Customer.* FROM Order_Customer LEFT JOIN Order_Acceptance ON Order_Customer.OSerialNo = Order_Acceptance.OrdCustSrNo where Order_Acceptance.OrdCustSrNo IS NULL";
    I think the above query has syntax error. for try with this
    "SELECT * FROM Order_Customer LEFT JOIN Order_Acceptance ON Order_Customer.OSerialNo = Order_Acceptance.OrdCustSrNo and Order_Acceptance.OrdCustSrNo IS NULL";

  • Unable to retrive data from two tables using multiple joins

    Hi,
    Table:   EMP mgr 
    eid              name
    eid mgrid
    1
    A 1
    null
    2
    B 2
    3
    3
    C 3
    3
    i need to get result as:
    eid ename mgrname
    thanks
    AVS

    Sai,
    It would be very helpful if you could mention your table structures a bit more clearly. Would allow for effective replies from fellow users as well. :) 
    However, assuming that your structure would be as follows presenting the query as below:
    DECLARE @Emp TABLE(Eid Int, ename Varchar(50))
    DECLARE @Emp_Mgr TABLE(Eid int, mgrid int null )
    INSERT INTO @Emp select 1,'Ram'
    INSERT INTO @Emp select 2,'Shyam'
    INSERT INTO @Emp_Mgr select 1,NULL
    INSERT INTO @Emp_Mgr select 2,1
    SELECT * FROM @Emp
    SELECT * FROM @Emp_Mgr
    Query to print results as EID, ENAME, MGRNAME
    SELECT em.eid,e1.ename as ENAME,e2.ename as MGRNAME
    FROM @Emp_Mgr em
    JOIN @Emp e1 ON em.eid=e1.eid
    JOIN @Emp e2 ON em.mgrid=e2.eid
    However, as you see this approach of maintaining two tables for preserving the employee-manager data is redundant and makes the queries unnecessarily complex. So, you could opt for the widely used single table format as mentioned by Praveen as well. Check
    if this helps you..
    Recommended Structure
    *Avoidance of redundant storage of data
    *Lesser Joins in queries
    DECLARE @Emp TABLE(Eid Int , Ename Varchar(50) , mgrid int null )
    INSERT INTO @Emp(Eid , ename , mgrid) values(1 , 'Ram' , null) , (2 , 'Shyam' , 1)
    SELECT * FROM @Emp
    Query to print results as EID, ENAME, MGRNAME
    SELECT e.Eid , e.Ename , m.Ename as MgrName
    FROM @Emp e
    JOIN @Emp m On a.mgrid = b.eid
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Find matching records from two tables, useing three key fields, then replace two fields in table1 from table2

    I have two tables - table1 and table2 - that have the exact same schema. There are three fields that can be used to compare the data of the two tables, field1, field2, and field3. When there are matching rows in the two tables (table1.field1/2/3 = table2.field1/2/3)
    I want to replace table1.field4 with table2.field4 and replace table1.field5 with table2.field5.
    I have worked with the query but have come up with goobly goop. I would appreciate any help. Thanks.

    If your field1, field2, and field3 combinations in these tables are unique, you
    can do a join on them.
    Select t1.field4, t2.field4 , t1.field5, t2.field5
    from table1 t1 inner join table2 t2 on t1.field1 =t2.field1 and t1.field2=t2.field2 AND t1.field3=t2.field3
    --You can update your table1 with following code:
    Merge table1 t1
    using table2 t2 on
    on t1.field1 =t2.field1 and t1.field2=t2.field2 AND t3.field3=t2.field3
    When matched then
    Update Set
    t1.field4= t2.field4
    ,t1.field5 = t2.field5 ;

  • How do I retrieve records from a table using JCO RFC Function Call

    Hi
    I am totally new to SAP Java Progamming. And I would like to know if I am writing code correctly. I read some tutorials in the Internet but I am still not sure if I am doing it the correct way.
    This is what my vendor has given me.
    My question is whether this is the correct optimum way to do get the customer detail based on an array of input values for the customer reference number.
    Input:
    I_CUSTNO - Any number customer IDs. This is a table similar to I_CUSTDETL
    Output:
    Structure name:  I_CUSTDETL
    Note: The CUSTID column has been added in the structure to identify the address of the relevant customer id
    Field details:
    Field Name  Data Type  Length
    CUSTID       Character   10
    COMPANYNAME   Character   40
    EMAIL        Character     40
    This is my code:
            JCoFunction function = connect.getFunction("Z_GET_CUSTOMER");
            JCoTable cust = function.getTableParameterList().getTable("I_CUSTNO");
            cust.appendRow();
            cust.setValue("CUSTID", "10000700");
            cust.appendRow();
            cust.setValue("CUSTID", "10000701");
            cust.appendRow();
            cust.setValue("CUSTID", "10000702");
    connect.execute(function);
            JCoTable table = function.getTableParameterList().getTable("I_CUSTDETL");
              System.out.println("Table size: " + table.getNumRows());
              for (int i = 0; i < table.getNumRows(); i++, table.nextRow()) {
                String custid= table.getValue("CUSTID").toString();
                String companyname = table.getValue("COMPANYNAME").toString();
                String email = table.getValue("EMAIL").toString();
                System.out.println("----
                System.out.println("Record Number::" + i + "::");
                System.out.println("----
                System.out.println("Value custidis::" + custid+ "::");
                System.out.println("Value companyname is::" + companyname + "::");
                System.out.println("Value email is::" + email + "::");

    Hi,
    Answer to your question :whether this is the correct optimum way to do get the customer detail based on an array of input values for the customer reference number? is
    YES.
    Regards,
    Ganga

  • Stored pl/sql procedure retrieving similar records from different tables using

    Hi all I'm trying to retrieve the employee num and employee name if they are both a driver and mechanic
    I'm script my own procedure and it compiles with no issue but when i try to execute it. they will show me this error.
    Error starting at line 29 in command:
    EXECUTE VERIFY(1,'John Smith')
    Error report:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "CARSON.VERIFY", line 8
    ORA-06512: at line 1
    01422. 00000 -  "exact fetch returns more than requested number of rows"
    *Cause:    The number specified in exact fetch is less than the rows returned.
    *Action:   Rewrite the query or change number of rows requested
    This is how my procedure look like:
    CREATE OR REPLACE PROCEDURE VERIFY(
    enum IN NUMBER,
    ename IN VARCHAR) IS
    empnum NUMBER;
    empname VARCHAR(50);
    Fail EXCEPTION;
    BEGIN
    select employee.e#, employee.name
    into empnum, empname
    from employee join driver
    on driver.e# = employee.e#
    join mechanic
    on driver.e# = enum;
    EXCEPTION
    WHEN Fail THEN
    dbms_output.put_line('OK');
    END VERIFY;
    and this is how i execute the procedure
    EXECUTE VERIFY(1,'John Smith');
    so may i know what have gone wrong? would be glad if someone is able to enlighten me.

    No need for a loop.
    Just make sure that your query always returns at most one row. Adding a predicate like 'where rownum=1' is a way to achieve that:
    select employee.e#
    ,      employee.name
    into   empnum
    ,      empname
    from   employee join driver on driver.e# = employee.e#
                    join mechanic on driver.e# = enum
    where rownum = 1;

  • FETCHING VALUES IN MULTI RECORD BLOCK FROM ANOTHER TABLE USING SELECT STATEMENT.

    Hi,
    I have one multi record block in which i want to fetch values
    (more then one record) from another table using select statement
    IN KEY NEXT ITEM.I am getting following error.
    ORA-01422: exact fetch returns more than requested number of rows
    Thanks in advance.

    In your case I see no reason to use non-database block and to try to populate it from a trigger with a query, instead of using the default forms functionality where you can associate the block and the fields with table, create where clause using bind variables and simply use execute_query() build-in to populate the block. The power of the forms is to use their build-in functionality to interact with the database.
    Also, you can base your block on a query, not on a table and you dynamically change this query using set_block_property() build-in. You can use any dynamic queries (based on different data sources) and you simply need to control the column's data type, the number of the columns and their aliases. Something like creating inline views as a block data source.
    However, you can replace the explicit cursor with implicit one like
    go_block('non_db_block_name');
    first_record();
    FOR v_tab IN (SELECT *
    FROM tab
    WHERE col_name = :variable)
    LOOP
    :non_db_block_name.field1 := v_tab.col1;
    :non_db_block_name.field2 := v_tab.col2;
    next_record();
    END LOOP;

  • Polling records from mulitiple table(61 Tables) using WCF-SQL adapter

    Hi,
    I would like get some suggestion from this forum. I've a scenario, in which I need to poll the records from multiple table(61) which are related and may have one to many relationship. what's the best way to poll the records from SQL table to BizTalk.
    Thanks in advance..
    Regards,
    Karthick

    Karthick,
    Write a SQL stored procedure with joins from your 61 tables (!!!) . Use WCF-SQL adapter to invoke the procedures.
    Following references shall help you:
    Executing Stored Procedures in SQL Server by Using BizTalk Server
    Performing Composite Operations on SQL Server by Using BizTalk Server
    Bing-Results: biztalk wcf sql
    adapter polling stored procedure
    I don’t know your exact requirement. Consider using SQL-SSIS for ETL process depending on your requirements. Anyway if your requirement really needs BizTalk, above suggest
    should solve your problem.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

Maybe you are looking for

  • Reader doesn't auto open when using save as in Word2007

    Can anybody help with this little problemette ! I originally had Adobe Reader 9.2 that would open automatically when I created a PDF from Word2007 using the Save as command. But now it won't open automatically. I (maybe stupidly) installed Adobe Read

  • First Time Making PKGBUILD: xhotkeys

    I wanted to try out a keybinding program called xhotkeys (I like to look aroudn for alternative programs constantly, and noticed that xbindkeys has quite a few dependencies), but when I went to install it from the AUR, it gave me some errors. (Namely

  • Can't compile the first sample in crossbridge

    when i'm trying to run make FLASCC=/cygdrive/c/crossbridge/sdk FLEX=/cygdrive/c/flex_sdk  in run.bat it gives the error "Unable to launch the Java Virtual Machine". i have already downloaded the 64-bit java and the flex sdk. i have also downloaded th

  • Copying files between Iphone and PC over 3G-connection?

    Hi, Is there any application for copying files between PC and Iphone using a 3G or Edge connection? I'm using Jaadu VNC client on my Iphone but it has no functions for file transfers (as far as I know). Thanks for any hints!

  • Create a schdule to upload an SAP UDQ to the BI on demand integration

    Hi Dear; in SAP B1, BI on demand integration, i can upload any UDQ to the BI On Demand Website is it possible to schedule a task to upload/update the UDQ ? how? 10x