SQLJ problem with DML

When try to Update record with sqlj I've got no result !!! Data remains unchanged ??
Does anybody have same problem ???
(I use default context).

Good point! You issue a commit in SQLJ with:
#sql { COMMIT };
Remember that:
- JDBC creates connections with autocommit on (except for the JServer session connection)
- the Oracle.connect() calls create connections with autocommit off
Some additional tips:
(1) You can use an ExecutionContext to see how many rows got updated.
import sqlj.runtime.ExecutionContext;
ExecutionContext ec=new ExecutionContext();
#sql [ec] { UPDATE table SET ... WHERE ... };
System.out.println("Updated "+ec.getUpdateCount()+" rows.");
(2) Remember that if the WHERE clause selects no rows, then 0 rows get updated and you will also NOT see a SQLException.
(3) If your WHERE clause compares any CHAR columns to Java strings, it very likely will not work: you have to blank-pad the Java strings if you want the comparison to succeed. Or you can declare the column as VARCHAR2. Or you could use a LIKE comparison and append a "%" to the Java string.
-- Ekkehard

Similar Messages

  • Problem with combination of ClobDomain and DB Trigger

    Hi all,
    I am using JDeveloper 10.1.2.0.0 (Build 1811), Oracle RDBMS 10.1.0.4.0
    I have a DB Table which contains a CLOB column. This column is mapped in the EntityObject with the java type ClobDomain. Insert, update and delete actions are handled correctly by BC4J. The problem is that the database trigger on the table always gives me an empty CLOB object instead of the correct data.
    PL/SQL trigger
    CREATE OR REPLACE TRIGGER SYNC_CLOB
    AFTER INSERT OR UPDATE OR DELETE ON MYTABLE
    FOR EACH ROW
    BEGIN
    IF (DELETING OR
    :NEW.clobcolumn IS NULL OR
    DBMS_LOB.GETLENGTH(:NEW.clobcolumn) = 0) THEN
    -- Delete record from sync table
    ELSE
    -- Insert/Update record in sync table
    END IF;
    END;
    Scenario
    When I do an insert or update (in BC4J) that contains data for the clobcolumn, the clobcolumn is populated correctly, but the trigger always deletes the record in the sync table because the length of the CLOB is always zero. If I remove the condition DBMS_LOB.GETLENGTH(:NEW.clobcolumn) = 0 a empty CLOB is inserted/updated in the sync table.
    When I do an insert or update via SQL*Plus that contains data for the clobcolumn the trigger inserts/updates the correct CLOB value in the sync table.
    This leads me to the conclusion that there is a problem with the ClobDomain.
    Has this got something to do with the way the ClobDomain handles the dml operations (streaming to a LOB locator)?
    Can somebody help me?
    Thanks,
    Steven.

    Solved the problem by myself....

  • A problem with sample application modification

    Hello,
    I trying to build my application based on the Oracle HTML DB sample application (SA). I do have ‘orders’ and ‘order_item’ tables and forms – similarly as the SA dos. However I do have a problem with a fact that SA’s ‘enter order header’ page only mandatory (not null) columns are obtaining values from a sequence (order_id) and popup key lov (p201_customer_id).
    In my application, I do have additional mandatory column – due_date. I can’t find a way to populate this column at the same time when process ‘process row of demo_orders’ is executed. This process’ type is ‘automatic row processing (dml)’ and as I can see it only deals with one primary key and one secondary key.
    On my own ‘enter order header’ page I do have ‘p201_due_date’ item displayed as ‘date picker (dd/mm/yyyy)’ so when I run my ‘enter order header’ page I can select ‘customer name’ similarly as on SA, and I do have additional ‘due date’ field where I can select a date from calendar-type popup window. However when I click on ‘continue >’ I am getting error ORA-01400 because I don’t know where to set that my due_date table column has to get populated from p201_due_date when I click on ‘continue >’ button.
    Is this doable using build in ‘automatic row processing (dml)’ process type or I have to write my own pl/sql anonymous block to handle this?
    Thank you for your time.
    DanielD

    Does p201_due_date have a source type 'Database Column' ? It should in order for the fetch and DML processes to know about it.
    Scott

  • ORA-02291 - ORA-02063 on merge with dml error logging through DB link

    Hello all,
    I have 2 DB's and I would like to merge records from A into B with dml error logging through a db link.
    Exemple:
    merge into B@dblink
    using (select ... from A where...)
    when matched then
    when not matched then
    log errors into err$_A reject limit unlimited;
    When I use this, and exception is thrown:
    ORA-02291: integrity constraint (B.constraint_name) violated - parent key not found
    ORA-02063: preceding line from dblink
    I've got no idea of what causes this.
    Could anyone please help me ?
    Thanks !
    Regards,
    TDE.

    Hello damorgan,
    Thanks for your answer.
    I've well understood that its was a foreign key violation, and I guess that's an error in the source: wee make only logical deletes, and I'm quite sure the problem is there.
    Anyway, I really would understand why dml error logging doesn't work in this case.
    I'll investigate and keep you informed.
    Regards.

  • Problem with database schema objects in the entity object wizard

    Hi All,
    When creating a new entity object, I am facing a problem with database schema objects in the entity object wizard, database schema objects (check boxes for tables,synonyms...) are disabled. Actually I am using a synonym but I am not able to select the synonym check box.
    Can any of you folks tell me how to enable the database schema objects (check boxes for tables,synonyms...).
    Thanks in Advance.
    Raja.M

    Make sure your using rite version of jdeveloper..
    Make sure your using apps schema and check whether your able perform DML operations in the schema vis sql developer.
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                           

  • HST60: Huge Performance Problem with VAPI Views

    We are using a VAPI view (with instead-of-triggers) for a table with +/- 60 columns.
    In this instead-of-trigger we call some functions to return constants and variables.
    Using DML (for example a Update) on this view takes the Server 80 sec. CPU time.
    Direct update on the table takes 0.2 secs. CPU time.
    Assistance please cause we are planning to use VAPI views to populate a new database model with old Forms.
    As I know in Oracle 7 there was a problem with code in triggers. I believe they were compiled each time they were called. And package onces !! MAybe has this something to do with it.
    Thanks in advise,
    M. Overdijk
    null

    Marc,
    Thanks for the reply....
    We are using 8.1.6 currently.
    This is a problem of one my fellow developers. The problem is the update using the rowid. Headstart has a booster to customize a Designer module to not use this rowid.
    Problem we have is we have a old Forms 4.5 application. We made a new server model along with cdm ruleframe. The old tables are dropped and the old forms now work with VAPI views......redericting the data the new tables.
    Now we have (we think) the same problem wherefor Headstart has this above called booster.
    Any solutions for us ??? Cause we don't want to change the old application forms (there are to much !!)
    Our solution is to drop the instead of triggers and use some cev business rule to redirect the data...
    Disadvantages:
    1. some work to do
    2. whern the old application is dropped we have to remove the cev rules.
    Any other solutions

  • Connector problem with access enforcer

    Hi Guys,
    I am facing a really strange problem with my connectors.
    We have a test installation of GRC which was down for about 3 months.
    During this time we migrated our central SLD to another system so I needed to change the connection after getting the system up again.
    Anyhow I still can't modify, test or even create a new connector for access enforcer.
    The only error I get is "Action failed".
    I tried to analyze the logs but found no help there too.
    2007-06-18 20:41:56,833 [SAPEngine_Application_Thread[impl:3]_4] ERROR java.lang.NullPointerException
    java.lang.NullPointerException
         at com.virsa.ae.dao.sqlj.SAPConnectorDAO.iterToDTO(SAPConnectorDAO.sqlj:75)
         at com.virsa.ae.dao.sqlj.SAPConnectorDAO.findByConnectorName(SAPConnectorDAO.sqlj:15)
         at com.virsa.ae.configuration.bo.ConnectorsBO.findSAPConnectorDetails(ConnectorsBO.java:76)
         at com.virsa.ae.configuration.actions.ManageConnectorsAction.testConnection(ManageConnectorsAction.java:163)
         at com.virsa.ae.configuration.actions.ManageConnectorsAction.execute(ManageConnectorsAction.java:66)
         at com.virsa.ae.commons.utils.framework.NavigationEngine.execute(NavigationEngine.java:229)
         at com.virsa.ae.commons.utils.framework.servlet.AEFrameworkServlet.service(AEFrameworkServlet.java:412)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java(Compiled Code))
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java(Compiled Code))
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java(Compiled Code))
         at java.security.AccessController.doPrivileged1(Native Method)
         at java.security.AccessController.doPrivileged(AccessController.java(Compiled Code))
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java(Compiled Code))
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java(Compiled Code))
    Did anybody here face a problem like that?
    Kind regards,
    Bastian
    Message was edited by:
            Bastian Schneider
    Message was edited by:
            Bastian Schneider

    I had a simular problem with CC and I had to contact SAP. They gave me a script to run against the database that remove the connector. The problem seemed somewhat common for CC 5.1. Not sure if this applies to AE.

  • Problem with a trigger

    I have a problem with a very simple trigger:
    CREATE OR REPLACE TRIGGER contratos_factuali
    AFTER UPDATE OF descrip,fautori,origpeso,origdls,
    montopeso,montodls,aant,aact,fifiobserva,pedsap
    ON ulises.contratos
    FOR EACH ROW
    BEGIN
    UPDATE contratos SET factuali=TO_DATE(SYSDATE,'DD/MM/YYYY HH24:MI')
    WHERE ncontra=:NEW.ncontra;
    COMMIT;
    END;This trigger update the column 'factuali' of this table everytime any other column of this table is updated. But returns me an error:
    SQL> update contratos set montodls=1 where ncontra='ODPS-086/00';
    update contratos set montodls=1 where ncontra='ODPS-086/00'
    ERROR at line 1:
    ORA-04091: table ULISES.CONTRATOS is mutating, trigger/function may not see it
    ORA-06512: at "ULISES.CONTRATOS_FACTUALI", line 2
    ORA-04088: error during execution of trigger 'ULISES.CONTRATOS_FACTUALI'What's happening?

    (1) You cannot use DML to update the table on which the trigger is based. Think about it: your trigger fires on UPDATE so each time fires, it updates the table and fires again. This is what is known as mutation.
    What you should do is create a trigger that executes BEFORE the update and simply do
    :NEW.factuali := SYSDATE;
    If ncontra is not a unique column and you genuinely want all rows of the same value to have the same factuali timestamp, well, it's very difficult, indeed I don't think it can be done. You could try submitting a DBMS_JOB to do the update, passing in the factuali value as a parameter; that DBMS_JOB would have to disable the trigger before doing the update (to prevent the recursion) and then re-enable it afterwards. Which seems like a lot of work: are you sure your design is correct?
    (2) You don't need the commit statement: the triggere exectutes within the commit phase of the original update.
    HTH, APC

  • We have problem with showing warnings "Inline with Field"s.

    We have problem with showing error messages "Inline with Field"s.
    1. We have a package ERROR, that collects all errors/warnings. It has a procedure PUT, that saves errors in the variables of the package.
    Package ERROR
    procedure put(ptable in varchar2, pcolumn in varchar2, pcode in varchar2, pmsg in varchar2);
    end;
    2. We have a database table. Its values are validated by a trigger (saving business rules).
    If an error occurs, then the trigger calls the procedure PUT ( to save an error message).
    For example ...
    CREATE TRIGGER ...
    --- Rule 21
    if substr(:new.ka_kood,1,1) != :new.s_kat then
    error.put('TABLE1','COLUMN1', -20167, ' MESSAGE 1 !');
    end if;
    END;
    3. I have a form of HTML DB that updates the table TABLE1
    I want to show this error message with the field COLUMN1 (Inline with Field) .
    I need same validations before and after updating values.
    Before update - to validate same input; after update - to show errors saved in the package ERROR.
    I also tried to use the global variables. For example ...
    WWV_FLOW.g_validation_ids_in_error(1):= 192645056564169139;
    WWV_FLOW.g_item_ids_in_error(1):= 192644674113169137 ;
    WWV_FLOW.g_validation_message(1):='MESSAGE1';
    And this did not help.
    To rise errors in programs - is there same API ?
    Or there is some other solutions ?
    How can I do this in HTML DB?

    Andres,
    I'm not sure exactly what you are trying to do. But perhaps this will help some. If your after-submit process runs DML that causes triggers to fire, which result in error messages to be accumulated in package variables, you could create a branch on the page that would be conditional on the existence of error messages in the package variables. The branch could be back to the same page or to a more customized error page. The page you branch to would use the error messages in the package variables to determine how to format the page with the error text. The key to doing this is to run it all in the same database session. The way to do that is to use a "direct" branch, i.e., one that does not do a URL redirect. You create this type of branch with the Create Branch wizard (Branch to Page) and do not check the "Branch to page using redirect" checkbox when you see it.
    Be sure to roll back any changes you do not want committed before the branch.
    Using HTML DB global package variables for anything like what you described is not supported.
    Scott

  • DB2 problems with Dynamic SQL

    Does anyone out there use dynamic SQL with DB2? If so, are the sql statements causing a PreparedStatement to be executed on DB2. I posted this question similarly before, but never resolved it, and it is killing me. I have to resolve this ASAP!
    Here is the problem: My DB2 Admin says that EVERY TIME I access the database, my Java app is causing the database to create a PreparedStatement. However, I'm using Statement objects exclusively, with dynamic SQL. He says that DB2 needs an "access path" for the client, and that it converts the Statement to a PreparedStatement, as this is the only way to get this "access path". He says the only solution is either stored procedures or SQLJ, which will do the binding in advance, and increase performance tremendously. However, I am STRONGLY opposed to using SQLJ, and if we do stored procedures, we'd have to write one for every possible SQL statment! I KNOW there is a better solution.
    Is anyone out there having these problems with JDBC and DB2? Surely someone out there uses DB2 and JDBC and either has these problems or can confirm that something is incorrectly configured on the database side.
    Any help would be great. Thanks, Will

    Now I'm wondering if maybe the PreparedStatements are ONLY being called on the database when I call getConnection(), and not when I call executeQuery() or executeUpdate() from the Statement object. I just can't see why the database would have to make an access path for every SQL statement executed, but I could see it creating an access path for every connection requested. Any thoughts on that theory?

  • Problem with a function(reply me soon )

    hello
    i have some problem with following statement, please answer me , what will be the answer.
    Within the current application, a COBOL program calculates the annual allowable budget for each studio based on historical analysis.This value, stored in a COBOL variable , will be passed to your function as an argument. Which function will you create?
    1. CREATE OR REPLACE FUNCTION set_budget
    (v_studio_id IN NUMBER, :cobol_variable_budget IN NUMBER)
    RETURN number
    IS
    BEGIN
    UPDATE studio
    SET yearly_budget = :cobol_variable_budget
    WHERE id = v_studio_id;
    COMMIT;
    RETURN SQL%ROWCOUNT;
    END;
    2. CREATE OR REPLACE FUNCTION set_budget
    (v_studio_id IN NUMBER, :cobol_variable_budget IN NUMBER)
    RETURN number
    IS
    v_new_budget NUMBER := :cobol_variable_budget;
    BEGIN
    UPDATE studio
    SET yearly_budget = v_new_budget
    WHERE id = v_studio_id;
    COMMIT;
    RETURN SQL%ROWCOUNT;
    END;
    3. CREATE OR REPLACE FUNCTION set_budget
    (v_studio_id IN NUMBER, v_new_budget IN NUMBER := :cobol_variable_budget)
    RETURN number
    IS
    BEGIN
    UPDATE studio
    SET yearly_budget = v_new_budget
    WHERE id = v_studio_id;
    COMMIT;
    RETURN SQL%ROWCOUNT;
    END;
    reply me soon thanx

    If you correctly copied the proposed functions from your homework, then you really need to get a new teacher.
    First, none of the functions are syntactically correct. You cannot use bind variable (i.e. :variable_name) in the way they are used in these functions.
    Second, even removing the colons, which does allow the functions to compile, and passing values to the functions results in:
    ERROR at line 1:
    ORA-14551: cannot perform a DML operation inside a query
    ORA-06512: at "OPS$ORACLE.SET_BUDGET", line 6
    Third, even if you could do the update in a function, the function will always return 0. The COMMIT sets SQL%ROWCOUNT to 0. If you want to use the value, you need to get it immediately after the statement, before doing anything else.
    The accepted way of doing DML on objects is through PROCEDURES.
    You need something like:
    CREATE OR REPLACE PROCEDURE set_budget
    (v_studio_id IN NUMBER, cobol_variable_budget IN NUMBER, rowcount OUT NUMBER)
    IS
    BEGIN
       UPDATE studio
       SET yearly_budget = cobol_variable_budget
       WHERE id = v_studio_id;
       rowcount := SQL%ROWCOUNT;
       COMMIT;
    END;
    To call this from sqlplus, you would need to
    1. Create the output variable rowcount by
       VARIABLE rowcount NUMBER;
    2. Then call the function with appropriate parameters
       exec set_budget(1,100,:rowcount);
       Note the use of a bind variable for the OUT parameter[b]To call this through a COBOL program would be similar, except that you would probably use the COBOL variables for all three parameters. The OUT parameter would still have to be passed as a bind variable.
    John

  • ODBC compatibility problem with server 7.1.5

    Hi all,
    I am suffering from Windows ODBC driver desasters and hope I am not alone with my problem:
    I am developing a client app with Visual Foxpro 5.0a (maybe not relevant to the problem) on Win NT 4.0 SP 6,
    which accesses a Oracle 7.1.5 Server (on Alpha VMS) through ODBC.
    I used for several years the Version 2.0.x of the Oracle ODBC driver with satisfying results.
    Now I have to extent the app to run on Win 95 (sorry, but thats true) and also Win 2000. I am working in a large company
    network and have to take as environment what is provided by the systems group, which is SQL-Net8 and Oracle drivers
    from the 8.x series (8.1.7x for Win 2000 and some 8.0.x for Win 95).
    My problem: While DML commands are just fine with the 8.x drivers on the 7.1 server, I cannot call any stored
    procedures on the driver. I am using "ODBC" syntax, i.e. send strings like
    "{Call Schema1.Package1.ProcedureA(?Variable1, ?@Variable2)}" to the ODBC driver.
    I get the error message "Table/View does not exist", which is garbage, since the same calls work just fine, when
    using the 2.x driver.
    However, with the 2.x drivers, also the procedures get called ok and IN parameters are passed correctly,
    I cannot receive IN OUT parameters! What I get back is what I passed into the procedure plus one arbitrary character.
    Needless to say, that the 8.x drivers work just perfect against an 8i Server. However, I cannot migrate my productive
    database anytime soon.
    Does anybody have an idea which drivers are able to support calling stored procedures on a 7.1.5 server or can point
    me to resources here, which handle the problem?
    Thanks a lot,
    Peter
    PS: Yes I have seen the previous thread stating that, 7.1x servers are no certified for new drivers. But I simply hope, some
    body recognizes my problem and has a solution. :-)

    Thanks for the tip, might well be that this solves my problem (standards always should, or).
    But how do I bind the variables in a separate step the standard way? I never saw that in any docs -neither Foxpro nor VB which of course now moved to ADO.
    Thanks for an example or a pointer to the literature,
    Peter
    The standard ODBC syntax for executing a stored procedure is
    "{Call Schema1.Package1.ProcedureA(?, ?)}"
    The syntax you describe
    "{Call Schema1.Package1.ProcedureA(?Variable1, ?@Variable2)}"
    isn't familiar to me. I assume it's something Microsoft cooked up for pass-through queries (may be something special for FoxPro) that combines a few steps. You may want to try using the standard syntax and doing the variable binding as a separate step.
    I suppose that there might be a problem with the 7.1.5 database and how it handles IN OUT parameters, but that seems unlikely...
    Justin

  • Problem with Mlogs

    Good Day
    I've suitation here, we have materilized views(MV's) with other interface(UII) and Mlogs at my end(Application).
    The bussiness rule is that, when ever the base table are performed/subjected with DML operations at my end the data will flow to respective Mlogs,and Mlogs should purge for every 2 minutes.(i.e fastrefresh)
    Now the problem is that, this purging is not happening and the data is getting accumulating in Mlogs,however the data flows to UII from my application(or my end).i.e fastrefresh is happening.
    To overcome the purging issuse we have done the following..with no luck
    we have dropped Mlogs and re-created them, but still purging is not happening
    We have forcefully purged the Mlogs using oracle supplied packages, but still purging is not happening
    Please,could some one point out for me why purging is not happening in Mlogs at my end?
    Database version 10.2.0.3

    I faced this prob too.
    But i manually delete 15 days old records from mview log.
    Nimish Garg
    http://nimishgarg.blogspot.com

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

  • Problem with Threads and a static variable

    I have a problem with the code below. I am yet to make sure that I understand the problem. Correct me if I am wrong please.
    Code functionality:
    A timer calls SetState every second. It sets the state and sets boolean variable "changed" to true. Then notifies a main process thread to check if the state changed to send a message.
    The problem as far I understand is:
    Assume the timer Thread calls SetState twice before the main process Thread runs. As a result, "changed" is set to true twice. However, since the main process is blocked twice during the two calls to SetState, when it runs it would have the two SetState timer threads blocked on its synchronized body. It will pass the first one, send the message and set "changed" to false since it was true. Now, it will pass the second thread, but here is the problem, "changed" is already set to false. As a result, it won't send the message even though it is supposed to.
    Would you please let me know if my understanding is correct? If so, what would you propose to resolve the problem? Should I call wait some other or should I notify in a different way?
    Thanks,
    B.D.
    Code:
    private static volatile boolean bChanged = false;
    private static Thread objMainProcess;
       protected static void Init(){
            objMainProcess = new Thread() {
                public void run() {
                    while( objMainProcess == Thread.currentThread() ) {
                       GetState();
            objMainProcess.setDaemon( true );
            objMainProcess.start();
        public static void initStatusTimer(){
            if(objTimer == null)
                 objTimer = new javax.swing.Timer( 1000, new java.awt.event.ActionListener(){
                    public void actionPerformed( java.awt.event.ActionEvent evt){
                              SetState();
        private static void SetState(){
            if( objMainProcess == null ) return;
            synchronized( objMainProcess ) {
                bChanged = true;
                try{
                    objMainProcess.notify();
                }catch( IllegalMonitorStateException e ) {}
        private static boolean GetState() {
            if( objMainProcess == null ) return false;
            synchronized( objMainProcess ) {
                if( bChanged) {
                    SendMessage();
                    bChanged = false;
                    return true;
                try {
                    objMainProcess.wait();
                }catch( InterruptedException e ) {}
                return false;
        }

    Thanks DrClap for your reply. Everything you said is right. It is not easy to make them alternate since SetState() could be called from different places where the state could be anything else but a status message. Like a GREETING message for example. It is a handshaking message but not a status message.
    Again as you said, There is a reason I can't call sendMessage() inside setState().
    The only way I was able to do it is by having a counter of the number of notifies that have been called. Every time notify() is called a counter is incremented. Now instead of just checking if "changed" flag is true, I also check if notify counter is greater than zero. If both true, I send the message. If "changed" flag is false, I check again if the notify counter is greater than zero, I send the message. This way it works, but it is kind of a patch than a good design fix. I am yet to find a good solution.
    Thanks,
    B.D.

Maybe you are looking for