Case within case in join

I am trying to set up a join where what fields are matched depend on the value of another field but cannot seem to get the syntax right. I have only posted part of the query as it is quite long and the rest has no relevance to the join.
The error is
Msg 102, Level 15, State 1, Line 59
Incorrect syntax near '='.
on the line
then  CertNo =
Can anybody help me sort this out please?
regards
Ron
from
InvoiceItems
join Invoices on inv_no = invit_invno and inv_canind <> 'Y' and inv_cust <> '$sayrf'
join Customers on cust_no = inv_cust
join Stock on stock_no = invit_partno
join Batches on batch_batch = invit_batch and batch_part = invit_partno
inner join Certtable on
case when certpord = ''
then CertNo =
CASE WHEN LEFT(invit_cert,5) = 'HAPAG' then 'HAPAGL'
WHEN LEFT(invit_cert,5) = 'UAMMA' then 'UAMMAERSK'
WHEN LEFT(invit_cert,5) = 'UAMRB' then 'UAMRB211'
WHEN LEFT(invit_cert,5) = 'NSKCON' then 'NSKCON'
ELSE invit_cert
end
else certpord = batch_order
end
join Suppliers on supplierRef = supp_no

Because you are thinking of CASE as a control-of-flow construct - it is not.  It is an expression that returns a scalar value.  You can use it within a join clause but it must be done correctly.  Case returns a scalar value which must be used
to form a Boolean expression.  You currently have
case when certpord = ''
    then  CertNo =
    CASE WHEN LEFT(invit_cert,5) = 'HAPAG' then 'HAPAGL'
    WHEN LEFT(invit_cert,5) = 'UAMMA' then 'UAMMAERSK'
    WHEN LEFT(invit_cert,5) = 'UAMRB' then 'UAMRB211'
    WHEN LEFT(invit_cert,5) = 'NSKCON' then 'NSKCON'
    ELSE invit_cert
    end
    else certpord = batch_order
    end
Reducing this to remove the specific logic within the nested expression, you have
case when certpord = ''
    then  CertNo =  [c1]
    else certpord = batch_order
    end
So it should be obvious that you are attempting to treat the case expression as a control-of-flow statement.  Usually it is easier to write the logic twice and then combine the queries into a single one (if that is possible).  I'm guessing that
you need something like:
inner join Certtable on
(certprod = '' and (case left(invit_cert,5) when 'HAPAG' then 'HAPAGL' ... else invit_cert end) = CertNo)
or (certpord <> '' and certpord = batch_order)
Carefully consider the logic if certprod can be null.  And a last comment. You should get into the many best practices habits - one of which is to give an alias to each table and to use always the alias when referencing columns in each table. 
This makes it easier to find logic problems based on the presence of similar column names in different tables and it improves the ability of your reader to understand the query and the association of columns to tables and tables to tables.  If you
find that the logic used to translate left(invit_cert, 5) appears frequently, you should consider adding a computed column to the associated table (and perhaps materializing it and /or the relationship). 
And another note - don't write/implement code that serves no useful purpose.  The last condition of your embedded case expression does nothing useful. 
WHEN LEFT(invit_cert,5) = 'NSKCON' then 'NSKCON'
The above condition can be safely left out of the logic since it will be evaluated in the same fashion as the else condition of the case expression.

Similar Messages

  • Using Case and Joins in update statement

    Hi all,
    I need to update one column in my table...but need to use case and joins...I wrote the query and it is not working
    I am getting an error msg saying...the SQL command not ended properly...
    I am not that good at SQL...Please help...
    update t1 a
    set a.name2=
    (case
    when b.msg2 in ('bingo') then '1'
    when b.msg2 in ('andrew') then '2'
    when b.msg2 in ('sam') then '3'
    else '4'
    end )
    from t1 a left outer join t2 b
    on a.name1 = b.msg1 ;
    Waiting for help on this...!
    Thanks in Advance... :)

    Another approach is to update an inline view defining the join:
    update
    ( select a.name2, b.msg2
      from   t1 a
      join   t2 b on b.msg1 = a.name1 ) q
    set q.name2 =
        case
          when q.msg2 = 'bingo' then '1'
          when q.msg2 = 'andrew' then '2'
          when q.msg2 = 'sam' then '3'
          else '4'
        end;which could also be rewritten as
    update
    ( select a.name2
           , case q.msg2
                when 'bingo'  then '1'
                when 'andrew' then '2'
                when 'sam'    then '3'
                else '4'
             end as new_name
      from   t1 a
      join   t2 b on b.msg1 = a.name1 ) q
    set name2 = new_name;The restriction is that the lookup (in this case, t2.msg1) has to be declared unique, via either a primary or unique key or unique index.
    (You don't strictly need to give the view an alias, but I used 'q' in case you tried 'a' or 'b' and wondered why they weren't recognised outside the view.)

  • CASE and JOIN Query Help

    I have two Tables
    Table A
    ID                             VALUE           
    1                         Delhi                
    2                      Mumbai                
    3                      Bangalore
    Table B
    TYPE                        TYPE_A_ID                         TYPE_B_ID             
    A                      1                                 NA                   
    A                      1                                 NA                
    B                      NA                                2           
    A                      3                                 NA                  
    B                      NA                                    1                   
    A                      1                                 NA            I want to get the value from Table A, depending on the Type in Table B
    i.e., when the Type is A, the value in Type_A_ID should be looked up in Table A
    and when the Type is B, the value in Type_B_ID should be looked up in Table A.
    The result how i need is as follows:
    TYPE                        TYPE_A_ID                         TYPE_B_ID                 Value      
    A                         1                                 NA                     Delhi
    A                      1                                 NA                     Delhi
    B                      NA                                2                      Mumbai
    A                      3                                 NA                     Bangalore       
    B                      NA                            1                      Delhi       
    A                      1                                 NA                     Delhi

    Here you go...
    <pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>
    SQL&gt; DROP TABLE A;
    Table dropped.
    SQL&gt; CREATE TABLE A ( ID INTEGER, VALUE VARCHAR2(20));
    Table created.
    SQL&gt; INSERT INTO A VALUES(1,'Delhi');
    1 row created.
    SQL&gt; INSERT INTO A VALUES(2,'Mumbai');
    1 row created.
    SQL&gt; INSERT INTO A VALUES(3,'Bangalore');
    1 row created.
    SQL&gt; DROP TABLE B;
    Table dropped.
    SQL&gt; CREATE TABLE B(TYPE CHAR(1), TYPE_A_ID CHAR(2), TYPE_B_ID CHAR(2));
    Table created.
    SQL&gt; INSERT INTO B VALUES ('A','1','NA');
    1 row created.
    SQL&gt; INSERT INTO B VALUES ('A','1','NA');
    1 row created.
    SQL&gt; INSERT INTO B VALUES ('B','NA','2');
    1 row created.
    SQL&gt; INSERT INTO B VALUES ('A','3','NA');
    1 row created.
    SQL&gt; INSERT INTO B VALUES ('B','NA','1');
    1 row created.
    SQL&gt; INSERT INTO B VALUES ('A','1','NA');
    1 row created.
    SQL&gt; COMMIT;
    Commit complete.
    SQL&gt;
    SQL&gt; SELECT TYPE, TYPE_A_ID, TYPE_B_ID, VALUE
    2 FROM A, (SELECT TYPE, TYPE_A_ID, TYPE_B_ID, DECODE(TYPE_A_ID,'NA',TYPE_B_ID,TYPE_A_ID) ID FROM B) B
    3 WHERE A.ID = B.ID
    4 /
    T TY TY VALUE
    A 1 NA Delhi
    A 1 NA Delhi
    B NA 1 Delhi
    A 1 NA Delhi
    B NA 2 Mumbai
    A 3 NA Bangalore
    6 rows selected.
    </code></pre>
    Karthick
    http://www.karthickarp.blogspot.com/

  • PREDICTION JOIN OPENQUERY against data source view does not work

    Hi,
     I am trying to follow the example in this link:
    http://technet.microsoft.com/en-us/library/ms132031.aspx
    to do a prediction join with a table defined in a data source view of our cube/mining structures.  No matter how I specify the table in the OPENQUERY statement I get: "OLE DB error: OLE DB or ODBC error: Invalid object name 'DataSourceView.dbo.TableName'.;
    42S02."  I've tried specifying the table name in 1, 2, and 3 parts, with and without the '[]' brackets but get the same error every time.  I thought something might be wrong with the table in the DSV so tried putting other tables in the query,
    but that produces the same error.  Any ideas on the problem?
    SELECT FLATTENED
            t.[Column1],
            t.[Column2],
            t.[Column3],
            PredictTimeSeries([ModelName].[Column3],5)
    From
      [ModelName]
    PREDICTION JOIN
      OPENQUERY([DataSourceView],
        'SELECT
            [Column1],
            [Column2],
            [Column3]
        FROM
          [DataSourceView].[dbo].[TableName]
        ') AS t
    ON
            [ModelName].[Column3] = t.[Column3]
    OLE DB error: OLE DB or ODBC error: Invalid object name 'R Staging.dbo.TestSet'.; 42S02."

    I want to be able to query a data source view table/named query.  This TechNet article seems to imply it is as simple as running the following in a DMX window:
         OPENQUERY ([MyDatasourceView],'select Column1 from DataSourceTable')
    I've also tried:
         select * from OPENQUERY ([MyDatasourceView],'select Column1 from DataSourceTable')
    Both result in:
        "Query (1, 1) Parser: The syntax for 'OPENQUERY' is incorrect."
    Can we query a DSV table from a DMX query directly with OPENQUERY, or does the OPENQUERY only work within a PREDICTION JOIN?  Seems like such a simple case for it not to work.
    Following the example in this article:
    http://technet.microsoft.com/en-us/library/ms132173.aspx

  • Designer - complex join not displayed correctly

    Post Author: Jon80
    CA Forum: General Feedback
    I've created a complex join as part of a tutorial for aggregate aware tables.  So I've created a complex join as follows within the e-fashion universe:
    Calendar_year_lookup.Yr=Agg_yr_qt_mt_mn_wk_rg_cy_sn_sr_qt_ma.Yr and Calendar_year_lookup.Week_In_Year=Agg_yr_qt_mt_mn_wk_rg_cy_sn_sr_qt_ma.Wk
    When selecting Detect, the cardinality detected is many-to-many.  Is it bad practice in this case?  Does it have to be resolved?
    It is noted that when I edit the join (e.g. double click the join), the cardinality that was previously detected is not shown within the Edit Join dialog.  Why?
    Then I try to create a context for this join, however at this stage it is noted that within the formula bar and within the New Context dialog the join is not displayed as it is expected, hence misleading to the designer:
    Calendar_year_lookup.Yr=Calendar_year_lookup.Week_In_Year=Agg_yr_qt_mt_mn_wk_rg_cy_sn_sr_qt_ma.Wk
    It would be helpful if the formula bar and the New Context dialog could accomodate the two lines created.
    As a matter of fact when I do copy and paste the join is pasted, as expected, i.e. how I have updated it previously:
    Calendar_year_lookup.Yr=Agg_yr_qt_mt_mn_wk_rg_cy_sn_sr_qt_ma.Yr and Calendar_year_lookup.Week_In_Year=Agg_yr_qt_mt_mn_wk_rg_cy_sn_sr_qt_ma.Wk
    Reference: Business Objects XI - The Complete Reference 2nd Ed pg.250

    Hello,
    most recent patches for IGS and kernel installed. Now it works.

  • How to change operator of join conditions in where clause?

    Hello
    I have a situation... I want to change the operator between each join conditions in the where clause when these join conditions are not from the same join..
    For example, I have the following schema:
    Dim1 ------ DimA -------Fact1
    Dim1-------DimB -----Fact1
    So DimA and DimB are aliasas of one dim table, but the join is different.
    Now if I run this model, what I will get in the where clause of the query is:
    Where Dim1 = DimA and Dim1 = DimB and DimA= Fact1 and DimB = fact1.
    Is there a way I can change these "and" operator to "OR", so that the where clause would look like this: Where Dim1 = DimA and Dim1 = DimB and DimA= Fact1 OR DimB = fact1?
    This is different from simply changing the join operator within the same join, because these are different joins and I'd like to control how they relate to each other..
    Please help
    Thanks

    Sometimes, business rules are complex, so there isn't always a way to simplify things.  Is your issue that it's complex and error prone, or is it performance due to the OR clauses?
    One possibility that will at least make it easier to test and debug is something like this:  (pseudocode)
    From Table1 Inner join Table2 on x=y etc.etc.
    CROSS APPLY
    (Select case when a=b and (c=d or e=f) then 1 else 0 end) as Situation1
    , case when h=i or j = k then 1 else 0 end) as situation2
    , case when l = m then 1 else 0 end) as situation 3
    ) as CA_Logic_Simplifier
    Where situation1 = 1 and situation2 = 1 and situation3 = 1
    Although you could say, "Hey, this is basically doing the same thing as before", this approach would be far easier to test and debug, because you can at a glance look at the values for situation1, 2, 3, etc. to see where errors are being introduced. 
    The cross apply makes the columns situation1/2/3 "instantiated", so they are usable in the where clause. Divide and conquer.  

  • OSB Split Join Repeat Until Question On XPath Condition

    I'm trying to use OSB File Transport to stream a very large XML document file into a service which will split the file into very many small XML documents. So, given a file like:
    <BookStore>
    <Book></Book>
    <Book></Book>
    ... (many more books)
    </BookStore>
    In the split join I want to use a 'repeat until' to process each Book until there are no more Books in the BookStore. Here's my question: What is the correct XPath expression to use as the Repeat Until terminating condition? (I'm an XPath novice.)
    Thanks for your help!!!

    Hi,
    Based on what I understood, you should be using a for each loop with the conditions as follows:
    Within the Split Join flow
    for each ( counter variable from 1 to Count (xpath of book) ) --> For my example it was count($request.parameter/sjpoc:Orders/sjpoc:Order) replace this with your xpath.
    - do your logic
    Snapshot just in case @ http://dl.dropbox.com/u/19901533/sj_foreach_snapshot.JPG
    Based on this the split and join would happen for n (based on count) number of Book tags.
    Let me know if my understanding is incorrect.
    Thanks,
    Patrick

  • Create Manageable Channel in JSDT and invite the clients to join It

    I am developing a collaborative application using JSDT where I want to incorporate private messaging between two clients. When the Client chooses the private messaging option I am creating a New channel and inviting the other Client to join the Channel using channel.invite(client) method. It throws the permissionDenied exception. I am wondering if it is a client autentication problem. Since there isn't enough good reference on JSDT I am having hard time understanding this problem. I would greatly appreciate any help to solve this problem.

    Sorry I didn't get back to you earlier
    Have taken a look at this problem & have built a skeleton app that works
    I think your problem is probably due to NOT building in a ChannelManager(???) & thus when your client tries to join the Channel within the Session - No Authentication occurs
    Anyhow have a look at the code below (it needs some tidying up)
    Run JSDTManager, then JSDTChatApp, then JSDTChatClient
    ******************* Code for JSDTManager.java *********************
    * JSDTManager.java
    * Created on 09 December 2003, 17:11
    package com.JSDT;
    import com.sun.media.jsdt.*;
    import com.sun.media.jsdt.event.*;
    * @author stefan.maric
    public class JSDTManager extends Thread implements RegistryManager, SessionManager, ChannelManager
         private static JSDTManager manager;
         public static final int nCLIENT_PORT_BASE = 5000;
         public static final int nCLIENT_PORT_LIMIT = 5999;
         public static final String sSU = "SU";
         public static final String sSUALLOWED = "SU_ALLOWED";
         public static final String sJOIN_SESSION_ALLOWED = "OK";
         public static final String sCREATE_CHANNEL_ALLOWED = "CREATE_CHANNEL_OK";
         public static final String sJOIN_CHANNEL_ALLOWED = "CHN_OK";
         public static final String sCREATE_CLIENT_ALLOWED = "CLIENT_OK";
         /** Creates a new instance of JSDTManager */
         private JSDTManager()
         public static JSDTManager getInstance()
              if(manager == null)
                   manager = new JSDTManager();
                   manager.start();
              return manager;
         public void run()
              try{
                   if(!RegistryFactory.registryExists("socket"))
                        RegistryFactory.startRegistry("socket", new JSDTManager());
                        System.out.println("JSDTManager:JSDT Registry Started");
                   while(true)
              }catch(JSDTException eX){
                   eX.printStackTrace();
         public static void channelInvite(String sH, Channel chn, String sCN)
              System.out.println("JSDTManager:channelInvite");
              try{
                   Client[] clients = new Client[1];
                   int nPort = JSDTManager.nCLIENT_PORT_BASE;
                   boolean bFound = false;
                   while(!bFound && nPort <= JSDTManager.nCLIENT_PORT_LIMIT)
                        URLString url = URLString.createClientURL(sH, nPort, "socket", sCN);
                        try{
                             System.out.println(url.toString());
                             clients[0] = ClientFactory.lookupClient(url);
                             bFound = true;
                        }catch(NotBoundException eX){
                             nPort++;
                   if(bFound)
                        System.out.println("JSDTManager:Inviting '" + clients[0].getName() + "' to join Channel '" + chn.getName() + "'");
                        chn.invite(clients);
                   else
                        System.out.println("Could NOT find Client '" + sCN + "' in Registry");
              }catch(JSDTException eX){
                   eX.printStackTrace();
         public boolean registryRequest(AuthenticationInfo info, Client client)
              boolean bRetVal = false;
              String sN = client.getName();
              int nAction = info.getAction();
              char chType = info.getType();
              System.out.println("JSDTManager:registryRequest from Client '" + sN + "'");
              if(nAction == AuthenticationInfo.CREATE_SESSION)
                   String challenge = "Challenge Session Create";
                   String reply = null;
                   info.setChallenge(challenge);
                   reply = (String) client.authenticate(info);
                   if(reply != null)
                        if(reply.equals(sSUALLOWED) || reply.equals(sJOIN_SESSION_ALLOWED))
                             System.out.println("JSDTManager:registryRequest Authentication Reply '" + reply + "' Rxd from Client '" + sN + "' Authenticated");
                             bRetVal = true;
                        else
                             System.out.println("JSDTManager:registryRequest Authentication Reply '" + reply + "' Rxd from Client '" + sN + "' NOT Authenticated");
                   else
                        System.out.println("JSDTManager:registryRequest NULL Reply");
              else if(nAction == AuthenticationInfo.CREATE_CLIENT)
                   String challenge = "Challenge Client Create";
                   String reply = null;
                   info.setChallenge(challenge);
                   reply = (String) client.authenticate(info);
                   if(reply != null)
                        if(reply.equals(sSUALLOWED) || reply.equals(sCREATE_CLIENT_ALLOWED))
                             System.out.println("JSDTManager:registryRequest Authentication Reply '" + reply + "' Rxd from Client '" + sN + "' Authenticated");
                             bRetVal = true;
                        else
                             System.out.println("JSDTManager:registryRequest Authentication Reply '" + reply + "' Rxd from Client '" + sN + "' - NOT Authenticated");
                   else
                        System.out.println("JSDTManager:registryRequest NULL Reply");
              return(bRetVal);
         public boolean sessionRequest(Session session, AuthenticationInfo info, Client client)
              boolean bRetVal = false;
              String sN = client.getName();
              int nAction = info.getAction();
              char chType = info.getType();
              System.out.println("JSDTManager:sessionRequest from Client '" + sN + "' for '" + info.toString() + "'");
              if(chType == AuthenticationInfo.SESSION)
                   String reply = null;
                   String challenge = null;
                   switch(nAction)
                        case AuthenticationInfo.JOIN:
                             challenge = "Challenge Session Join";
                             info.setChallenge(challenge);
                             reply = (String) client.authenticate(info);
                             if(reply != null)
                                  if(reply.equals(sSUALLOWED) || reply.equals(sJOIN_SESSION_ALLOWED))
                                       System.out.println("JSDTManager:sessionRequest Authentication Reply '" + reply + "' Rxd from Client '" + sN + "' Authenticated");
                                       bRetVal = true;
                                  else
                                       System.out.println("JSDTManager:sessionRequest Authentication Reply '" + reply + "' Rxd from Client '" + sN + "' NOT Authenticated");
                             else
                                  System.out.println("JSDTManager:sessionRequest NULL Reply");
                             break;
                        case AuthenticationInfo.CREATE_BYTEARRAY:
                        case AuthenticationInfo.CREATE_TOKEN:
                             break;
                        case AuthenticationInfo.CREATE_CHANNEL:
                             challenge = "Challenge Channel Create";
                             info.setChallenge(challenge);
                             reply = (String) client.authenticate(info);
                             if(reply != null)
                                  if(reply.equals(sSUALLOWED) || reply.equals(sCREATE_CHANNEL_ALLOWED))
                                       System.out.println("JSDTManager:sessionRequest Authentication Reply '" + reply + "' Rxd from Client '" + sN + "' Authenticated");
                                       bRetVal = true;
                                  else
                                       System.out.println("JSDTManager:sessionRequest Authentication Reply '" + reply + "' Rxd from Client '" + sN + "' NOT Authenticated");
                             else
                                  System.out.println("JSDTManager:sessionRequest NULL Reply");
                             break;
              return(bRetVal);
         public boolean channelRequest(Channel channel, AuthenticationInfo info, Client client)
              boolean bRetVal = false;
              String sN = client.getName();
              int nAction = info.getAction();
              char chType = info.getType();
              System.out.println("JSDTManager:channelRequest from Client '" + sN + "' for '" + info.toString() + "'");
              if(chType == AuthenticationInfo.CHANNEL && nAction == AuthenticationInfo.JOIN)
                   String challenge = "Challenge Channel Join";
                   String reply = null;
                   info.setChallenge(challenge);
                   reply = (String) client.authenticate(info);
                   if(reply != null)
                        if(reply.equals(sSUALLOWED) || reply.equals(sJOIN_CHANNEL_ALLOWED))
                             System.out.println("JSDTManager:channelRequest Authentication Reply '" + reply + "' Rxd from Client '" + sN + "' Authenticated");
                             bRetVal = true;
                        else
                             System.out.println("JSDTManager:channelRequest Authentication Reply '" + reply + "' Rxd from Client '" + sN + "' NOT Authenticated");
                   else
                        System.out.println("JSDTManager:channelRequest NULL Reply");
              return(bRetVal);
         * @param args the command line arguments
         public static void main(String[] args) throws Exception
              JSDTManager.getInstance();
    ******************* Code for JSDTManager.java *********************
    ******************* Code for JSDTChatApp.java *********************
    * JsdtChatApp.java
    * Created on 08 December 2003, 12:36
    package com.JSDT;
    import com.sun.media.jsdt.*;
    import com.sun.media.jsdt.event.*;
    * @author stefan.maric
    public class JsdtChatApp implements Client, ClientListener, SessionListener
         public static final String sCHATTER = "Chat Session";
         private String sHost;
         private int nPort;
         private JSDTManager manager;
         private Session session;
         private Channel channel;
         /** Creates a new instance of JsdtChatApp */
         public JsdtChatApp() throws Exception
              manager = JSDTManager.getInstance();
              nPort = 4461;
    //          sHost = "BOH-EAAC-IT3.eaac.boh";
              sHost = "localhost";
              int nTry = 1;
              boolean bCreated = false;
              URLString sessionURL = URLString.createSessionURL(sHost, nPort, "socket", sCHATTER);
              while(bCreated == false)
                   if(SessionFactory.sessionExists(sessionURL))
                        bCreated = true;
                   else
                        try{
                             System.out.println("JsdtChatApp:Session Create Attempt '" + nTry + "'");
                             session = SessionFactory.createSession(this, sessionURL, false, manager);
                        }catch(TimedOutException eX){
                             System.out.println("JsdtChatApp:Session Create Attempt '" + nTry + "' Timed Out");
                             try{
                                  Thread.sleep(5000);
                             }catch(InterruptedException iEX){
                                  iEX.printStackTrace();
                                  System.exit(1);
                   nTry++;
              System.out.println("JsdtChatApp:Session created");
              try{
                   session.join(this);
                   System.out.println("JsdtChatApp:Joined Session");
                   session.addSessionListener(this);
                   channel = session.createChannel(this, "ChatChannel", true, true, true, manager);
                   System.out.println("JsdtChatApp:ChatChannel Created");
    //               RegistryFactory.addRegistryListener(sHost, "socket", this);
              }catch(JSDTException eX){
                   eX.printStackTrace();
              while(true)
    //***********************     Session Listener Inerface     ***********************
         public void byteArrayCreated(SessionEvent event)
         public void byteArrayDestroyed(SessionEvent event)
         public void channelCreated(SessionEvent event)
         public void channelDestroyed(SessionEvent event)
         public void sessionDestroyed(SessionEvent event)
         public void sessionJoined(SessionEvent event)
              String sCN = event.getClientName();
              Session sess = event.getSession();
              String sSN = sess.getName();
              System.out.println("JsdtChatApp: '" + sCN + "' has Joined session '" + sSN + "'");
              manager.channelInvite(sHost, channel, sCN);
         public void sessionLeft(SessionEvent event)
         public void sessionInvited(SessionEvent event)
         public void sessionExpelled(SessionEvent event)
         public void tokenCreated(SessionEvent event)
         public void tokenDestroyed(SessionEvent event)
    //***********************     Session Listener Inerface     ***********************
    //***********************     Client Inerface     ***********************
         public Object authenticate(AuthenticationInfo info)
              System.out.println("JsdtChatApp:authenticate \n" + info.toString());
              return JSDTManager.sSUALLOWED;
         public String getName()
              return JSDTManager.sSU;
    //***********************     Client Inerface     ***********************
    //***********************     Client Listener Section     ***********************
         public void byteArrayExpelled(ClientEvent event)
         public void byteArrayInvited(ClientEvent event)
         public void channelExpelled(ClientEvent event)
         public void channelInvited(ClientEvent event)
         public void sessionExpelled(ClientEvent event)
         public void sessionInvited(ClientEvent event)
         public void tokenExpelled(ClientEvent event)
         public void tokenInvited(ClientEvent event)
         public void tokenGiven(ClientEvent event)
    //***********************     Client Listener Section     ***********************
         * @param args the command line arguments
         public static void main(String[] args) throws Exception
              new JsdtChatApp();
    ******************* Code for JSDTChatApp.java *********************
    ******************* Code for JSDTChatClient.java *********************
    * JSDTClient.java
    * Created on 08 December 2003, 13:10
    package com.JSDT;
    import com.sun.media.jsdt.*;
    import com.sun.media.jsdt.event.*;
    * @author stefan.maric
    public class JSDTChatClient implements Client, ClientListener, SessionListener, ChannelListener
         private static JSDTManager manager;
         private Session session;
         private String name;
         /** Creates a new instance of JSDTClient */
         public JSDTChatClient()
              manager = JSDTManager.getInstance();
         public JSDTChatClient(String sN) throws Exception
              this();
              setName(sN);
    //          String sHost = "BOH-EAAC-IT3.eaac.boh";
              String sHost = "localhost";
              int nPort = JSDTManager.nCLIENT_PORT_BASE;
              int nTry = 1;
              boolean bCreated = false;
              while(bCreated == false && nPort <= JSDTManager.nCLIENT_PORT_LIMIT)
                   URLString clientURL = URLString.createClientURL(sHost, nPort, "socket", sN);
                   if(ClientFactory.clientExists(clientURL))
                        bCreated = true;
                   else
                        try{
                             System.out.println("JSDTChatClient:Client Create Attempt '" + nTry + "'");
                             ClientFactory.createClient(this, clientURL, this);
                        }catch(AlreadyBoundException eX){
                             eX.printStackTrace();
                             System.exit(1);
                        }catch(PortInUseException eX){
                             nPort++;
                             Thread.sleep(5000);
                        }catch(TimedOutException eX){
                             System.out.println("JSDTChatClient:Client Create Attempt '" + nTry + "' Timed Out");
                             Thread.sleep(5000);
                   nTry++;
              if(bCreated)
                   System.out.println("JSDTChatClient:Client Created");
              else
                   System.out.println("JSDTChatClient:Client NOT Created");
                   System.exit(1);
              nPort = 4461;
              nTry = 1;
              bCreated = false;
              URLString sessionURL = null;
              while(bCreated == false)
                   sessionURL = URLString.createSessionURL(sHost, nPort, "socket", JsdtChatApp.sCHATTER);
                   if(SessionFactory.sessionExists(sessionURL))
                        bCreated = true;
                   else
                        try{
                             System.out.println("JSDTChatClient:Session Create Attempt '" + nTry + "'");
                             session = SessionFactory.createSession(this, sessionURL, false);
                        }catch(PortInUseException eX){
                             nPort++;
                             Thread.sleep(5000);
                        }catch(TimedOutException eX){
                             System.out.println("JSDTChatClient:Session Create Attempt '" + nTry + "' Timed Out");
                             Thread.sleep(5000);
                   nTry++;
              System.out.println("JSDTChatClient:Found Session '" + JsdtChatApp.sCHATTER + "'");
              try{
                   session = SessionFactory.createSession(this, sessionURL, false);
                   session.join(this);
                   session.addSessionListener(this);
                   System.out.println("JSDTChatClient:Joined Session");
              }catch(JSDTException eX){
                   eX.printStackTrace();
              while(true)
    //***********************     Client Listener Section     ***********************
         public void byteArrayExpelled(ClientEvent event)
         public void byteArrayInvited(ClientEvent event)
         public void channelExpelled(ClientEvent event)
         public void channelInvited(ClientEvent event)
              Session session = event.getSession();
              String sChn = event.getResourceName();
              System.out.println("JSDTChatClient: has been Invited to join Channel '" + sChn + "'");
              try{
                   Channel chn = session.createChannel(this, sChn, true, true, false);
                   chn.join(this, Channel.READWRITE);
                   System.out.println("JSDTChatClient:Joined Channel '" + chn.getName() + "'");
                   chn.addChannelListener(this);
              }catch(JSDTException eX){
                   eX.printStackTrace();
         public void sessionExpelled(ClientEvent event)
         public void sessionInvited(ClientEvent event)
         public void tokenExpelled(ClientEvent event)
         public void tokenInvited(ClientEvent event)
         public void tokenGiven(ClientEvent event)
    //***********************     Client Listener Section     ***********************
    //***********************     Channel Listener Inerface     ***********************
         public void channelJoined(ChannelEvent event)
         public void channelLeft(ChannelEvent event)
         public void channelInvited(ChannelEvent event)
              System.out.println("JSDTChatClient:Channel Listener - channelInvited from '" + event.getClientName() + "'");
              Channel chn = event.getChannel();
              try{
                   chn.join(this, Channel.READWRITE);
                   System.out.println("JSDTChatClient:Joined Channel '" + chn.getName() + "'");
              }catch(JSDTException eX){
                   eX.printStackTrace();
         public void channelExpelled(ChannelEvent event)
         public void channelConsumerAdded(ChannelEvent event)
         public void channelConsumerRemoved(ChannelEvent event)
    //***********************     Channel Listener Inerface     ***********************
    //***********************     Client Inerface     ***********************
         public Object authenticate(AuthenticationInfo info)
              String sRetVal = null;
              System.out.println("JSDTChatClient:authenticate \n" + info.toString());
              int nAction = info.getAction();
              char chType = info.getType();
              if(chType == AuthenticationInfo.SESSION)
                   if(nAction == AuthenticationInfo.CREATE_CHANNEL)
                        sRetVal = JSDTManager.sCREATE_CHANNEL_ALLOWED;
                   else if(nAction == AuthenticationInfo.JOIN)
                        sRetVal = JSDTManager.sJOIN_SESSION_ALLOWED;
              else if(chType == AuthenticationInfo.CHANNEL)
                   sRetVal = JSDTManager.sJOIN_CHANNEL_ALLOWED;
              else if (chType == AuthenticationInfo.REGISTRY)
                   sRetVal = JSDTManager.sCREATE_CLIENT_ALLOWED;
              return sRetVal;
         public String getName()
              return name;
    //***********************     Client Inerface     ***********************
    //***********************     Session Listener Inerface     ***********************
         public void byteArrayCreated(SessionEvent event)
         public void byteArrayDestroyed(SessionEvent event)
         public void channelCreated(SessionEvent event)
         public void channelDestroyed(SessionEvent event)
         public void sessionDestroyed(SessionEvent event)
         public void sessionJoined(SessionEvent event)
              String sN = event.getClientName();
              System.out.println("JSDTChatClient:sessionJoined from '" + sN + "'");
         public void sessionLeft(SessionEvent event)
         public void sessionInvited(SessionEvent event)
         public void sessionExpelled(SessionEvent event)
         public void tokenCreated(SessionEvent event)
         public void tokenDestroyed(SessionEvent event)
    //***********************     Session Listener Inerface     ***********************
         public void setName(String sN)
              name = sN;
         * @param args the command line arguments
         public static void main(String[] sArgs) throws Exception
              new JSDTChatClient(sArgs[0]);
    ******************* Code for JSDTChatClient.java *********************
    Hope this helps

  • Split joins in OSB

    Hi,
    Actually i do have a requirement where i need to call 2 business services simultaneously(in parallel) in OSB(Like using Flow activity in SOA) using split joins. Is it possible to call 2 business services parallely in OSB?
    Can any one please help me out with any blogs or steps that i can follow to achieve this.
    Your help is appreciated.
    Thanks,
    Naveen

    That is not entirely true. Split Join itself is based on single operation, i.e. the input to split join will be a single message, but within the split join you can invoke multiple services in parallel. You can either dynamically decide the number of parallel flows at runtime (similar to FlowN) or you can have static number of parallel calls (like Flow activity of BPEL) within split join.
    In case you want to call two business services in parallel, create a WSDL(if needed, in most cases you can reuse the WSDL of the Proxy Service itself for SplitJoin as well unless you are doing enrichment within Proxy before calling business services) for split join which has request message which contains data for both business services. Within the split join you can configure calls to both business services in parallel and you can also add transformations for each business services in respective branches.
    You can than aggregate the response from both services if needed and return that as a response of split join.
    Here is an example of Static Split Join:
    http://www.xenta.nl/blog/2011/07/03/oracle-service-bus-implementing-aggregator-pattern-by-use-of-split-join/

  • Deciphering column names in a join query using jdbc

    hi all....
    I am making a database adapter for a generic report generater. This adapter would be forming queries involing various tables. There are two ways of doing it . I fire an sql on parent table to get the keys and then go to child table for each one of them or i form a join query to get desired result.
    i want to go with the later approach where my query would be forming a join. The problem comes when table involved in this join has columns with the same name. for eg if a column "NOTE" is there in table A as well as table B on which i have a join. Resultset returns me with two "NOTE" columns and i cannot recognize which one belongs to which table.
    all API calls including getString("Note") seems to be referring to the first occurence of "Note" column.
    Also getTableName() and getSchemaName() APIs on resultsetMetadata doesnt return in anything in case of joins.
    Any pointers would be most appreciated.
    cheers
    vivek

    thanks for suggesting this solution ... though i had thought of the same onece .... unfortunately i cannot implement something like this coz out of the result set i have to instantiate an object hierarchy depending on the schema ....
    this also puts me in a doubt whether i can use join in my case.
    for eg ... .
    lets say we have a customer talbe and and address table which has one to many relationship .... one contact can have multiple addresses.
    Assuming a contanct "Joe Bloggs" having 3 addresses ...a query like following
    select contact.firstname contactfirstname , address.streetname addressstreetname from contact , address where contact.contactid = address.contactid
    this would return me 3 rows and i can also recognize various columns with their aliases ..
    but i would lose an important fact that i have to create one java object for contact class and 3 instances for addresses which i have to return finally.
    this means that i would like to return an object hierarchy with one contact object and 3 address object underneath it linked with contactid.
    Any other suggestions after reading the complete requirement are most welcome ...sorry for not puting the entire thing at first.
    i guess the only soln left is to visit contact and address table separately. :(

  • Is it better to use join?

    hi
    i want to select header details from LIKP and item details from LIPS. i have VBELN number with me. now there are two scenarios
    in first one
    i can use select single to get the header details
    then chekc sy-subrc to make sure that  document exists in the system then query LIPS to get the item details.
    second case
    use join between LIKP and LIPS join on VBELN.
    what would be the best in terms of performance in case if u want to select only one item from LIPS?

    Hi Sudhakar ,
    Proceed with the INNER JOIN between tables LIKP and LIPS based on VBELN to fetch Header and Item details.
    This will resolve your issue.

  • Inner join and outer  join in infosets

    hi everyone,
    i have a doubt in infosets...
    when and why we use inner and outer joins(right outer join and left outer join) for infoset
    please give a real time scenario........
    Thanks in advance.
    Bye.

    Hello,
    Inner join:
    For example, the requirement is to show all sales documents where you have delivery exists. In this case, you join both sales ods and delivery ods in a infoset as inner join. This will match the record against the reference documents and pull only matched records.  
    Outer Join:
    Suppose you want to pull all billing/invoice details along with their FI documents related data in a report. Assume that always there might be a situation that invoice exists but not posted to FI, however, you want to have all billing documents details either it has FI document or not. In this case, you link both Billing data and FI document data in a outer join.  This will pull all invoices data either FI document exists or not.   Other words, you want to show one side of data always but adding additional details from differenent source if data exists.
    Hope, it clarifies your doubt. Let me know if any questions.
    Thanks
    Viswa

  • Automatically complete pending interactive activities within a process

    What is the best approach for automatically completing pending interactive activities within a process?
    Scenario: If you have two or more threads within a split-join and one thread completes all the defined activities whilst the other thread is still waiting for an interactive step to be completed, is there a programmatic way of completing outstanding tasks i.e remove them from the workspace task list and move then onto the next task
    At the moment we have just configured the join activity to only wait for one process to complete but I was wondering if there was a way using the java api.
    Thanks in advance

    What I think you're asking is how to complete activities in the split so the instance can go onto the next activity after the join. If so then use just use
    Action = RELEASE;
    in the join. You'll need to surround this statement with appropriate conditional statements since the code in the join runs each time an instance copy (from one of the branches) reaches the join. You'll need to test to see if the instance is ready to proceed then do the action=release.
    If this is not what you want then you may need to involve something more complex, like placing a Notification Interrupt in your process. By interrupting the interactive in a split/join, you can perform these activities from within the interrupt process flow:
    OK / NONE      Indicates that PBL-Method execution was successful. This is the default value.
    FAIL                Indicates that the PBL-Method has failed its execution. The PBL-Method must be executed again, if it is so required.
    CANCEL           PBL-Method execution is aborted.
    REPEAT           Indicates that the PBL-Method execution is successful, but not recorded as completed.
    RELEASE           Ends the PBL-Method execution and releases the instance from this activity.
    ABORT           Ends PBL-Method execution and aborts the entire process instance.
    BACK           Ends PBL-Method execution and sends the instance back to the activity where the exception (or interruption) occurred.
    SKIP                Ends PBL-Method execution and sends the instance back to the activity where the exception (or interruption) occurred and skips it.
    Note the last one allows you to skip the interactive upon return and go to the next activity. Sorry I can't help any further. You may want to describe you're problem some more and perhaps we can help you better.
    Mark

  • Grab in split-join

    I have a grab activity which is set to from all to all. The process has a split-join. The user cannot grab an activity which is in a branch of split-join to outside the split-join or grab an acitivity which is outside the split-join into one branch of split-join. If I want to grab an activity of a branch to outside split-join, I can abort all activities in all branches and the process goes to join. Or I can grab all acitivities in all branches to the final activity before join and execute them to join. Is there any other method to grab from activity which is inside split-join to outside the gateway?

    Hi,
    Thanks for your reply. I create a new grab activity and set it to grab from all to all.
    In a new instance, if the process is inside the split-join, the new grab activity is the same as the first one. It is shows that the instance in a branch can be grabbed within the split-join.
    If the instance is outside the split-join, the grab activity cannot grab the instance to the branch.
    For example, the split-join has 2 branches. Each has 3 activities, named as
    branch 1: a1, a2, a3;
    branch 2: b1, b2, b3.
    Before the split, there are 2 activities named as c1, c2. After the join, 2 activities named c3, c4.
    C1 cannot be grabbed to b2. b2 cannot be grabbed to c4.

  • SQVI - join with table T030

    Hello!
    I am trying to create a query for material accounts with the Quick Viewer (transaction SQVI).
    I´ve already added tables MARA, MBEW and T001K, but when i try to add table T030 an error message comes up:
    "Table T030 cannot be used in a join" (Message #AQ 501)
    Does Anyone know why the Quick Viewer doesn't let me add this table to the join of tables?
    Thank you everybody in advance!
    cecil

    Dear Maria,
    Not every table can be join using SQVI, eg:T030,A017,etc.
    You can read the notes for this :
    1. You cannot read the selected table with SELECT statements (because,
    for example, it is a structure without a database table). Therefore,  
    this table cannot be read within a table join either.                                                                               
    2. The chosen table is a pool or cluster table. These tables may not be
    used in a table join.             
    Regards,

Maybe you are looking for

  • Automatic Payment Program problem in F110

    Hi Experts, When i am running APP program in F110, after parameter selection i am not able to do further steps. After parameters have been entered I cant do the further steps. When ever i select edit proposal button the messages are coming like: Prop

  • Apple Web Site Default Icon, Gone..

    Hi There, I seem to have tossed my Apple Web Site Default Icon.. I remember seeing the puff of smoke which means I moved it a little to far, and now I'd like to get it back. You know the one, it looks like an A, or an @ on a spring or something.. Any

  • Help page does not build refernce Models summary.

    Currently, we use the MVC default help page feature and enable the XMLPrvider: config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/ManagementApi.xml"))); When we access the help page, we didn't

  • PDK for EP 7.0

    Hi all, We installed EP 7.0 successfully. But we couldn't find the PDK for EP 7.0 anywhere. The links which were mentioned in other threads are not working. I couldn't find any info regarding PDK download. Any inputs on the path to download PDK for E

  • Problem emptying trash

    Has anyone had problems removing applications since the upgrade?