Update statement problem !!

Hi,
I need some specific features for my school project and BDB is almost providing me with this functionality. In my project, I want to provide the user with the functionality to provide the update statements from the user screen. I want to then take the user input in a java variable for manipulation of the xml data and display the end result. The only option I have for the user is to provide the xquery updates with the following syntax: ( I need this syntax for update statements as I use a parser to convert the user input to involve fuzziness):
"insert nodes <b4>inserted child</b4> after doc('dbxml:/test.dbxml/book)/Bookstore";
Now I am trying to run these with the below Code but I am not actually getting the required output. Can somebody help me to debug or fix this code for my requirement. I use the following xml data :
<Bookstore>
<Book>
<book_ID>1</book_ID>
<title>Harry Potter and the Order of the Phoenix</title>
<subtitle/>
<author>
<author_fname>J.K.</author_fname>
<author_lname>Rowling</author_lname>
</author>
<price>9.99<;;/price>
<year_published>2004</year_published>
<publisher>Scholastic, Inc.</publisher>
<genre>Fiction</genre>
<quantity_in_stock>28997</quantity_in_stock>
<popularity>20564</popularity>
</Book>
</Bookstore>
I have track points in my code to find the mistake and I get the following ouput.
Track 3
Track 3.1
Track 3.2-----
The code I use fails to compile the xquery statement with .prepare API.
import java.io.*;
import com.sleepycat.db.*;
import com.sleepycat.dbxml.*;
public class phone{
public static void main(String[] args)
String document1 = "C:/Documents and Settings/cjmadall/Desktop/BDB/book.xml";
String docName = "book";
XmlManager myManager = null;
XmlContainer myContainer = null;
try {
myManager = new XmlManager();
myContainer = myManager.openContainer("test.dbxml");
String myQuery = "insert nodes <b4>inserted child</b4> after doc('dbxml:/test.dbxml/book)/Bookstore";
// This Works and displays the entire document-> String myQuery = "collection('test.dbxml')";
// This Doesnt Work, ends with the above output -> String myQuery = "insert nodes <newNode>Some new text</newNode> after collection("dbxml:/test.dbxml")/Bookstore";
// collection('test.dbxml')/Bookstore";
System.out.println("Track 3 ");
XmlQueryContext managerContext = myManager.createQueryContext();
System.out.println("Track 3.1 ");
// Get a context for the document queries
// XmlQueryContext documentContext = myManager.createQueryContext();
System.out.println("Track 3.2 ");
// Prepare the XmlManager query
*XmlQueryExpression managerQuery = myManager.prepare(myQuery, managerContext);*
System.out.println("Track 3.3 ");
// Perform the query.
XmlResults results = managerQuery.execute(managerContext, 0);
// Display the result set
System.out.println("Track 3.4 ");
XmlValue value;
while ((value = results.next()) != null){
System.out.println(value.asString());
System.out.println("Track 3.5 ");
results.delete();
managerQuery.delete();
// documentContext.delete();
managerContext.delete();
} catch (XmlException e) {
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (myContainer != null) {
myContainer.close();
if (myManager != null) {
myManager.close();
} catch (XmlException ce) {
// Exception handling goes here
}//end finally
Thanks.

I was using a old version of BDB and the latest version fixed this issue.

Similar Messages

  • Update statement problem for jdbc adapter

    Hi all
    In the jdbc sender adapter, I configured as follows:
    Query statement
    select * from pickdiff where tid is null
    Update statement
    delete from pickdiff where tid is null
    I got following error message:
    Database-level error reported by JDBC driver while executing statement 'delete from pickdiff where tid is null'. The JDBC driver returned the following error message: 'java.sql.SQLException: [SQLServer 2000 Driver for JDBC][SQLServer]Die Unterabfrage gab mehr als einen Wert zurück. Das ist ungültig, wenn die Unterabfrage auf =, !=, <, <= , >, >= folgt oder als Ausdruck verwendet wird.'. For details, contact your database server vendor.
    If I change the Update statement to
    update pickdiff set tid = 'sapxi' where tid is null
    Then everything is ok.
    Doese any one have some idea about this problem?
    Regards
    Hui

    Hi,
    The below statements are from SAP help...
    http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/frameset.htm
    The UPDATE statement must alter exactly those data records that have been selected by the SELECT statement. You can ensure this is the case by using an identical WHERE clause. (See Processing Parameters, SQL Statement for Query, and SQL Statement for Update below).
    &#9679;      Processing can only be performed correctly when the isolation level for transaction is set to repeatable_read or serializable.
    SQL statement for query: SELECT * FROM table WHERE processed = 0;
    SQL statement for update: UPDATE table SET processed = 1 WHERE processed = 0;
    processed is the indicator in the database.
    please see if setting the isolation level would help....Also are you getting this error always or is it intermitent ?
    Thanks,
    Renjith

  • Simple update statement problem

    hello experts sorry to bother everyone with such a mundane question but this is giving me a headache
    i have 2 table ike and ike2
    ike has c1, c2 and ike2 has c_1 and c_2
    i like to set c2 on ike = to sysdate when c1=C_1
    UPDATE (SELECT c1,c2,c_1, c_2 FROM ike , ike2  WHERE c1 = c_1 )
      SET ike.C2 = sysdate ;
    this seems really simple todo yet im having a hell of a time getting this to work can anyone point out the obvious.
    Please

    Hi,
    Let me make sure I understand.
    Some rows in ike have matching rows in ike2; that is ike.c1 = ike2.c_1.
    For those rows that have matches, you want to set ike.c2 to SYSDATE.
    For the rows the don't have a match, you don't want to change anything.
    Is that it?
    If you wanted to change all the rows, you would just say:
    UPDATE  ike
    SET     c2 = SYSDATE;If you only want to update some of the rows in ike, you add a WHERE clause at the end.
    Either an EXISTS or an IN sub-query would make a good condition. Here's how to use IN:
    UPDATE  ike
    SET     c2 = SYSDATE;
    WHERE   c1  IN ( SELECT  c_1
                     FROM    ike2
                   );

  • Problem in Update Statement

    I got some problem in update statement.Can anybody discuss with me regarding my problem? Below is the occured problem.
    //all the declaration like Connection, ResultSet are declared, setting the ODBC path and so on steps have been set up before this method. When compile it, no error, when I start to run my program, the program�s interface is shown, but the following error was appearred and data cannot be updated, can anybody tell me where is my mistake?
    //ERROR:SQL Error in update statement:java.sql.SQLException [Microsoft][ODBC][ODBC Microsoft Access Driver] Syntax Error in UPDATE statement.
    //emp_overview is the table name
    // last_name, first_name, office_phone�.is the attributes of the table
    //this method had declare in the interface class already
    public String updateData (String idd, String ln, String fn, String op,
                   String oe, String hp, String ps, String ss)
                   throws java.rmi.RemoteException
         {//begin of this method
              String result ="";
              try
              Statement statement = connection.createStatement();
              String sql = "UPDATE emp_overview SET" +
              "last_name=' "+ln+
              " ', first_name=' "+fn+
              " ', office_phone=' "+op+
              " ', office_ext=' "+oe+
              " ', home_phone=' "+hp+
              " ', primary_skill=' "+ps+
              " ', secondary_skill=' "+ss+
              " ' WHERE id="+idd;
              statement.executeUpdate(sql);
              statement.close();
              catch (java.sql.SQLException e)
         System.out.println("SQL Error in update statement: "+e);
              //throw a RemoteException with the exception
              //embedded for the client to receive
         throw new java.rmi.RemoteException("Error in Updating exist row into DB", e);
              return result;
         }//end of this method

    Hi Kevin,
    According to the code you have posted, it looks like you are missing a space between "SET" and "last_name". I suggest you add the following line of code:
    System.out.println(sql);
    before the invocation of "executeUpdate()".
    I also suggest you add the following line of code:
    e.printStackTrace();in your "catch" block.
    Hope this helps.
    Good Luck,
    Avi.

  • Problem in Update statement using Execute Immediate

    Hi All,
    I am facing problem in update statement.
    I am creating dynamic sql and use "execute immediate" statement to execute a update statement.
    But it is not updating any thing there in the table.
    I have created a query like :
    update_query='Update '|| Table_Name ||' t set t.process_status =''Y'' where t.tid=:A';
    Execute immediate update_query using V_Id;
    commit;
    But it is not updating the table.
    I have a question , is execute immediate only does insert and delete?
    Thanks
    Ashok

    SQL> select * from t;
                     TID P
                     101 N
    SQL> declare
      2     V_Id          number := 101;
      3     Table_Name    varchar2(30) := 'T';
      4     update_query  varchar2(1000);
      5  begin
      6     update_query := 'Update '|| Table_Name ||' t set t.process_status =''Y'' where t.tid=:A';
      7     Execute immediate update_query using V_Id;
      8     commit;
      9  end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> select * from t;
                     TID P
                     101 Y                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Problem in UPDATE statement In Multiple Record Block

    Hi Friends,
    I have problem in update Statement for updating the record in multiple record data Block.
    I have two data Block the master block is single Record block and the 2nd data block is Multiple Record data Block.
    I am inserting the fields like category,and post_no for partiular job in single data block
    Now in second Multiple Record Data Block,i am inserting the multiple record for above fileds like no. of employees work in the position
    There is no problem in INSERT Statement as it is inerting all record But whenever i want to update particular Record (in Multiple Block) of employee for that category and Post_no
    then its updating all the record.
    my code is Bellow,
    IF v_count 0 THEN
    LOOP
    IF :SYSTEM.last_record 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES(g_post_no, g_roster_no, g_category, :POST_HISTORY_MULTIPLE.idcode, :POST_HISTORY_MULTIPLE.joining_post_dt,
    :POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    next_record;
    ELSIF :SYSTEM.last_record = 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES (g_post_no,g_roster_no,g_category,:POST_HISTORY_MULTIPLE.idcode,
    :POST_HISTORY_MULTIPLE.joining_post_dt,:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    EXIT;
    END IF;
    END LOOP;
    SET_ALERT_PROPERTY('user_alert',ALERT_MESSAGE_TEXT, 'Record Updated successfuly' );
    v_button_no := SHOW_ALERT('user_alert');
    FORMS_DDL('COMMIT');
    CLEAR_FORM(no_validate);
    Please Guide me
    Thanks in advence

    As you do a loop over all the records in the block, of course every record is updated.
    Also, what you do is not the way is intended to be used. In general, you base a block on a table,then there is no need at all for writing INSERT's or UPDATE's. Forms also know's then, which records to be updated and which not.

  • Problem In Update Statement In Multiple Record Data Block

    Hi Friends,
    I have problem in update Statement for updating the record in multiple record data Block.
    I have two data Block the master block is single Record block and the 2nd data block is Multiple Record data Block.
    I am inserting the fields like category,and post_no for partiular job in single data block
    Now in second Multiple Record Data Block,i am inserting the multiple record for above fileds like no. of employees work in the position
    There is no problem in INSERT Statement as it is inerting all record But whenever i want to update particular Record (in Multiple Block) of employee for that category and Post_no
    then its updating all the record.
    my code is Bellow,
    IF v_count <> 0 THEN
    LOOP
    IF :SYSTEM.last_record <> 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
    VALUES(g_post_no, g_roster_no, g_category, :POST_HISTORY_MULTIPLE.idcode, :POST_HISTORY_MULTIPLE.joining_post_dt,
    :POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    next_record;
    ELSIF :SYSTEM.last_record = 'TRUE' THEN
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    IF SQL%NOTFOUND THEN
    INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
         VALUES (g_post_no,g_roster_no,g_category,:POST_HISTORY_MULTIPLE.idcode,
              :POST_HISTORY_MULTIPLE.joining_post_dt,:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
    END IF;
    EXIT;
    END IF;
    END LOOP;
    SET_ALERT_PROPERTY('user_alert',ALERT_MESSAGE_TEXT, 'Record Updated successfuly' );
    v_button_no := SHOW_ALERT('user_alert');
    FORMS_DDL('COMMIT');
    CLEAR_FORM(no_validate);
    Please Guide me
    Thanks in advence

    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;
    UPDATE post_history
    SET idcode = :POST_HISTORY_MULTIPLE.idcode,
    joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
    leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
    entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
    WHERE post_no = :POST_HISTORY_SINGLE.post_no
    AND category = :POST_HISTORY_SINGLE.category
    AND roster_no = :POST_HISTORY_SINGLE.roster_no;
    AND idcode = :POST_HISTORY_MULTIPLE.idcode;These update statements are without where clause, so it will update all records.
    If it is specific to oracle forms then u may get better help at Forms section.

  • Weird problem when executing an update statement

    Please help me out with this issue. This a very weird problem i'm facing while executing the following update statement.
    update tblo.S_TABLE c
    SET (ACCNT_NAME, ACCNT_LOC)
    =
    (select NAME, LOC from S_TABLE1 p
    where p.ROW_ID = c.ACCNT_ID)
    where ROW_ID = 'XXXXX'
    The statement executes perfectly fine in "SQL Plus" but when i try from my application or any SQL Tool that uses ODBC, it fails with the following error
    <eb1>ORA-00923: FROM keyword not found where expected
    State:S1000,Native:923,Origin:[Oracle][ODBC][Ora]</eb1>
    ODBC Driver Used: 9.2.0.2.0

    Yes this could most probably be resolved by upgrading the driver. I'hv tried MS Oracle ODBC driver but that is even more problematic!
    The applications works fine in another environment which uses a Merant ODBC driver. Thanks for your time and advice.

  • Emergency: problem with update statement!

    hello guys, i have a very serious problem with an update statement in pl/sql.
    i had an application written in sybase, where i had the following update statement:
    update mis_dik_adeia
    set trexon_etos_days = days_per_year
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_dik_adeia.adeia_id between :aapo and :aews
    and mis_dik_adeia.employee_id = :erg
    and mis_dik_adeia.etos = :etos
    and mis_plafon_adeivn.years_yphr = ( select max( a.years_yphr ) from mis_plafon_adeivn a where a.adeia_id = mis_plafon_adeivn.adeia_id and a.years_yphr <= :eth ) using sqlca;
    This is working properly in sybase. When i copied this code in pl/sql it displayed me error and it's impossible to work. Then i thought to make a nested select statement like this:
    update mis_dik_adeia
    set trexon_etos_days = (select days_per_year
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and mis_plafon_adeivn.years_yphr = (
    select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth )
    but as you can understand, it is working, but it doesn't produce the same results as the update statement in Sybase!
    It is very important for me to solve this problem , which is a very big trouble for me for a long time.
    Please if anyone can help me i would appreciate it a lot!
    Regards ,
    Bill...

    Bill,
    folowing the logic of your original query by Sybase
    (it's embedded SQL in Power Builder, isn't it ?):
    update mis_dik_adeia
    set trexon_etos_days = (select days_per_year
    from mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_plafon_adeivn.years_yphr = (
    select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth )
    where
    mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and
    exists (select 1
    from mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    and mis_plafon_adeivn.years_yphr = (
    select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth )
    In 9i you can also try the following:
    megre into mis_dik_adeia
    using (
    select
    days_per_year,
    mis_dik_adeia.rowid rid
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and mis_plafon_adeivn.years_yphr =
    (select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth)
    ) src
    on (mis_dik_adeia.rowid = src.rid)
    when matched then
    update set mis_dik_adeia.trexon_etos_days = src.days_per_year
    when not matched then
    insert (mis_dik_adeia.adeia_id) values(0);
    In 10G it can be easily:
    megre into mis_dik_adeia
    using (
    select
    days_per_year,
    mis_dik_adeia.rowid rid
    from mis_dik_adeia, mis_plafon_adeivn
    where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
    mis_dik_adeia.adeia_id between aapo and aews
    and mis_dik_adeia.employee_id = erg
    and mis_dik_adeia.etos = etos1
    and mis_plafon_adeivn.years_yphr =
    (select max( a.years_yphr )
    from mis_plafon_adeivn a
    where a.adeia_id = mis_plafon_adeivn.adeia_id
    and a.years_yphr <= eth)
    ) src
    on (mis_dik_adeia.rowid = src.rid)
    when matched then
    update set mis_dik_adeia.trexon_etos_days = src.days_per_year;
    I have to notice I didn't check it carefully, so I can miss...
    Rgds.
    Corrected a mistake in the table name
    Message was edited by:
    dnikiforov

  • Update with case statement problem.

    Hi,
    I have this statement
    update tab_tr set col_rate =
      case
      when col_ern_type in ('031','035','036') then (1.5 * col_rate)
      when col_ern_type in ('041','045','046') then (2 * col_rate)
    end;this statement updated some 2 million rows in the table tab_tr. But the total count of rows for col_ern_type in ('031','035','036', '041','045','046') yeild only around 222642 rows.
    select count(*) from tab_tr where col_ern_type in ('031','035','036', '041','045','046');  --> 222642 rowswhat is the problem with the above update statement.
    Thank you,

    Hi,
    DBA_1976 wrote:
    ... I thought the case statement conditions are counted as the where condition. But ......A CASE expression just takes the place of some other expression, such as a literal, a function, or a column.
    For example, which rows do you think this should update?
    UPDATE  tab_tr
    SET     col_rate  = 100;It would update all rows, of course.
    How about this statement?
    UPDATE  tab_tr
    SET     col_rate  = column_x;Will it only change the rows where column_x are a certain value, or not NULL, or in any way depend on column_x? No, of course not. It will update all rows.
    How about this statement?
    UPDATE  tab_tr
    SET     col_rate  = function_y (col_ern_type);Will it only change the rows where the fucntion returns a certain value? Will it depend on the value in col_ern_type? No, of course not. It calls the function for each row, and whatever the function returns (even if the function returns NULL), that's what goes into col_rate on each row.
    A CASE expression is just something that you can substitute in place of any other expression, such as the literal 100, or the column column_x, or the function function_y in the statements above. Naturally, the value that gets put into col_rate will depend on what the CASE expression returns, but the behavior of the UPDATE statement as a whole will not.

  • Problem with a sqlite update statement using variables

    Flash Builder/Flex 4
    I'm trying to create a routine that will allow me to change the name of an author in a sqlite table.
    I have this update statement which works with hardcoded data:
    //trace("updateName function newAuthorName: " + newAuthorName (returns Dusty));
    //trace("updateName function oldAuthorName: " + oldAuthorName (returns Kristin));
    updateStmt = new SQLStatement();
    updateStmt.sqlConnection = conn;
    var sql:String = "UPDATE tableName SET authorNameColumn = 'Dusty' WHERE authorNameColumn = 'Kristin' ";
    updateStmt.text = sql;
    updateStmt.execute();
    If I change the statement to
    "UPDATE tableName SET authorNameColumn  =" +  newAuthorName +  "WHERE authorNameColumn =" + oldAuthorName;
    I get SELECT error: SQLError: 'Error #3115: SQL Error.', details:'near 'authorNameColumn': syntax error'
    I've tried changing many things about this statement trying to isolate the problem, but it seems to not like the variables.

    Lee;
    Thanks for your help.
    I'm relatively new to this Flex stuff.
    I've been trying to fix this problem for hours and you know how it is when you keep looking at the same thing for too long.
    The article you linked to helped. I finally just copied the text from it and changed the variable name to my own.
    FINALLY!! I can go do something else now.
    Grins
    Kristin

  • Problem with update statement

    Hi, i have the following data
    document_seq_num, Country, LE, SOB
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    i want an update statement for every change in the document sequnce with the other combination..
    the seqence number should change.
    i tried to write a rank over partion and and sequence but when i am trying to update, this is always updating
    90000000 in first run, as it is in loop for all records it is updating the same. i want an
    increment to the sequence for every change in document_seq_num
    Can any one help me to correct this procedure
    create or replace PROCEDURE test is
    cursor cur_voc_ref
    IS SELECT a.document_seq_num,
    a.country, a.LE, a.SOB, 2009, Rank() over (partition by
    a.country, a.LE, a.SOB
    order by a.document_seq_num, a.country, a.LE, a.SOB)
    from (select distinct document_seq_num,
    country, LE, SOB,period_name
    from temp_tab
    where country= 'NL'
    and LE= '000320'
    and SOB=13
    order by SOB,LE,document_seq_num) a
    where
    a.country= 'NL'
    and a.LE= '000320'
    and a.SOB=13
    and substr(a.period_name,5,6) =substr(2009,3,4);
    v_base number;
    BEGIN
    FOR c_rec IN cur_voc_ref
    LOOP
    BEGIN
    select nvl(max(ggtsi.reference), substr(2009,3,2)*1000000) into v_base
    from temp_tab ggtsi;
    update temp_tab
    set reference= v_base
    where document_seq_num= c_rec.document_seq_num
    and country=c_rec.country
    and le=c_rec.le
    and sob=c_rec.sob;
    commit;
    END;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line( 'Exception in opening balance insert ' || SQLCODE || ' ' || SQLERRM );
    END;

    user11289444 wrote:
    Hi, i have the following data
    document_seq_num, Country, LE, SOB
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100037     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100038     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100039     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100040     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100041     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100042     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    33100043     NL     000320     13     
    i want an update statement for every change in the document sequnce with the other combination..
    the seqence number should change.
    i tried to write a rank over partion and and sequence but when i am trying to update, this is always updating
    90000000 in first run, as it is in loop for all records it is updating the same. i want an
    increment to the sequence for every change in document_seq_num
    Can any one help me to correct this procedure
    create or replace PROCEDURE test is
    cursor cur_voc_ref
    IS SELECT a.document_seq_num,
    a.country, a.LE, a.SOB, 2009, Rank() over (partition by
    a.country, a.LE, a.SOB
    order by a.document_seq_num, a.country, a.LE, a.SOB)
    from (select distinct document_seq_num,
    country, LE, SOB,period_name
    from temp_tab
    where country= 'NL'
    and LE= '000320'
    and SOB=13
    order by SOB,LE,document_seq_num) a
    where
    a.country= 'NL'
    and a.LE= '000320'
    and a.SOB=13
    and substr(a.period_name,5,6) =substr(2009,3,4);
    v_base number;
    BEGIN
    FOR c_rec IN cur_voc_ref
    LOOP
    BEGIN
    select nvl(max(ggtsi.reference), substr(2009,3,2)*1000000) into v_base
    from temp_tab ggtsi;
    update temp_tab
    set reference= v_base
    where document_seq_num= c_rec.document_seq_num
    and country=c_rec.country
    and le=c_rec.le
    and sob=c_rec.sob;
    commit;
    END;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line( 'Exception in opening balance insert ' || SQLCODE || ' ' || SQLERRM );
    END;Hi,
    I suggest you to add a column to preserve current RANK value for all rows, <preserve_rank> for example, and
    when you add the new rows you will update your <preserve_rank> but you must pay attention to have the same value for
    document_seq_num, with other words you may insert yours rows in a batch like this:
    -- first update preserve_rank with RANK function
    declare
    v_doc_seq_num numeric;
    begin
    v_doc_seq_num:=33100040;
    -- note !!!
    -- put all into a valid sql command
    -- and apply execute immediate
    insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
    insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
    insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
    -- update preserve_rank
    update temp_tab x  set x.preserve_rank = (Select max(preserve_rank) from temp_tab y
                                              where y.document_seq_num=v_doc_seq_num) old_rank + 1)
    where (prserve_rank is null) and x.document_seq_num=v_doc_seq_num;
    end;  I know it's a lost a memory but the trigger is the last solution who can give us a nightmare.
    Regards,
    Ion
    Edited by: user111444777 on Sep 25, 2009 11:12 AM
    Edited by: user111444777 on Sep 25, 2009 11:35 AM

  • Problem in doing an update statement

    Hello all
    i should write an update statement,
    these tables : country: name,code,population,nextyearr_population ...
    nextyear_population is empty,at first i should get population_growth from population table then calculate the next year population according to corrent population and population_growth
    population: country(actually is code not name of country) ,population_growth,....
    i wrote so and i got this error
    Error starting at line 1 in command:
    update country c
    set c.nextyear_population=(c.population+ ((c.population*(select pop.population_growth from population pop join country co on co.code=pop.code))/100)
    where country.code=population.country
    Error at Command Line:4 Column:20
    Error report:
    SQL Error: ORA-00904: "POPULATION"."COUNTRY": invalid identifier
    00904. 00000 -  "%s: invalid identifier"
    *Cause:   
    *Action:
    --  File created - Wednesday-May-15-2013  
    --  DDL for Table COUNTRY
      CREATE TABLE "intern"."COUNTRY" ("NAME" VARCHAR2(40), "CODE" CHAR(2), "CAPITAL" VARCHAR2(40), "PROVINCE" VARCHAR2(40), "POPULATION" NUMBER, "AREA" NUMBER, "NEXTYEAR_POPULATION" NUMBER)
       COMMENT ON COLUMN "intern"."COUNTRY"."NAME" IS 'the country name'
       COMMENT ON COLUMN "intern"."COUNTRY"."CODE" IS 'the internet country code (two letters)'
       COMMENT ON COLUMN "intern"."COUNTRY"."CAPITAL" IS 'the name of the capital'
       COMMENT ON COLUMN "intern"."COUNTRY"."PROVINCE" IS 'the province where the capital belongs to'
       COMMENT ON COLUMN "intern"."COUNTRY"."POPULATION" IS 'the population number'
       COMMENT ON COLUMN "intern"."COUNTRY"."AREA" IS 'the total area'
       COMMENT ON TABLE "intern"."COUNTRY"  IS 'the countries of the world with some data'
    REM INSERTING into intern.COUNTRY
    SET DEFINE OFF;
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('Andorra','ad','Andorra la Vella','Andorra la Vella',69865,468,null);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('United Arab Emirates','ae','Abu Dhabi','Abu Dhabi',2523915,82880,null);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('Afghanistan','af','Kabul','Kabul',28513677,647500,null);
    --  File created - Wednesday-May-15-2013  
    --  DDL for Table POPULATION
      CREATE TABLE "intern"."POPULATION" ("COUNTRY" CHAR(2), "POPULATION_GROWTH" NUMBER, "INFANT_MORTALITY" NUMBER)
       COMMENT ON COLUMN "intern"."POPULATION"."COUNTRY" IS 'the country code'
       COMMENT ON COLUMN "intern"."POPULATION"."POPULATION_GROWTH" IS 'population growth rate (percentage, per annum)'
       COMMENT ON COLUMN "intern"."POPULATION"."INFANT_MORTALITY" IS 'infant mortality (per thousand)'
       COMMENT ON TABLE "intern"."POPULATION"  IS 'information about the population of the countries'
    REM INSERTING into intern.POPULATION
    SET DEFINE OFF;
    Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('ad',0.95,4.05);
    Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('ae',1.54,14.51);
    Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('af',4.77,163.07);thank you in advance
    im using oracle11g and ubuntu 12
    best,david

    Hi, David,
    Thanks for posting the CREATE TABLE and INSERT statements.
    Don't forget to post the results you want from thatsample data (that is, the contents of country after everything is finished).
    1003209 wrote:
    ... i wrote so and i got this error
    Error starting at line 1 in command:
    update country c
    set c.nextyear_population=(c.population+ ((c.population*(select pop.population_growth from population pop join country co on co.code=pop.code))/100)
    where country.code=population.country
    Error at Command Line:4 Column:20
    Error report:
    SQL Error: ORA-00904: "POPULATION"."COUNTRY": invalid identifier
    00904. 00000 -  "%s: invalid identifier"
    In the UPDATE statement itself (outside of sub-queries) you can only reference the table being UPDATEd, but in the WHERE clause:
    where country.code=population.countryyou're trying to reference another table, population. That's what caused the error.
    You either need another sub-query, or MERGE, which will probably be simpler and more efficient than UPDATE.

  • Problem with CFQUERY update statement

    I'm having trouble getting an SQL Update statement to work
    correctly and I'm scratching my head as to why.
    The output i get is the following:
    Syntax error in UPDATE statement
    SQLSTATE 42000
    SQL UPDATE companies SET CompanyName = 'Insight Data Ltd',
    Address1 = '5 Boulevard', Address2 = '', Address3 = '', City =
    'Weston-super-Mare', County = 'North Somerset', Postcode =
    'BS231NN', OfficeBranch = 'BR', contacttitle1 = 'Mr', contactname1
    = 'Andrew', contactsurname1 = 'Scott', contactposition1 = 'Owner',
    mail1 = 'yes', TelNumber = '01934 123456', TPS = 'no', FaxNumber =
    '',FPS = 'no',MobileNumber = '',MPS = 'no',email =
    '[email protected]', EPS = 'no', WebAddress = '
    http://www.insightdata.co.uk',
    contacttitle2 = 'Mr', contactname2 = 'David', contactsurname2 =
    'Lewis', contactposition2 = 'Office Manager', mail2 = 'no',
    contacttitle3 = 'Mr', contactname3 = '', contactsurname3 = '',
    contactposition3 = 'Owner', mail3 = 'no', contacttitle4 = 'Mr',
    contactname4 = '', contactsurname4 = '', contactposition4 =
    'Owner', mail4 = 'no', wPVCUfab = 'yes', wALUinst = 'yes', WHERE
    companyid = 33415
    VENDORERRORCODE -3503
    DATASOURCE idv6
    I've checked that all the data fields are in the correct
    format, and I can't see why I am getting a syntax error. Any help
    on this would be appriciated

    Agreed, but it looks like you already have the sql. Take the
    query from the error message above and run it in your database.
    Though I did notice have an extra comma between the last column and
    there WHERE clause.
    wALUinst = 'yes' , WHERE companyid = 33415
    For the optional columns, put the commas first to prevent
    errors due to trailing or too many commas
    UPDATE Table
    SET Column1 = 'value'
    <cfif SomeValueExists>, Column2 = 'other value'
    </cfif>
    WHERE ID = 123
    Two other things to consider: use cfqueryparam and consider
    normalizing your table. Column names like Contact1, Contact2,
    Contact3 ... are usually a sign its time to normalize.

  • Problem regarding Update-Statement on se11 table

    Hello I tried to update a dataset in a se11 table using UPDATE Statement.
    It doesn't work and I get a sy-subrc = 4.
    That is my code:
    TABLES ZTDM_SAPOUTPUT.
    * Arbeitsbereich definieren
    DATA:
    wa_ZTDM_SAPOUTPUT LIKE ZTDM_SAPOUTPUT.
    wa_ZTDM_SAPOUTPUT-PK = '1'.
    wa_ZTDM_SAPOUTPUT-FNCODE = '3'.
    wa_ZTDM_SAPOUTPUT-MATNR = '3'.
    wa_ZTDM_SAPOUTPUT-MAKTX = '3'.
    wa_ZTDM_SAPOUTPUT-ZEINR = '3'.
    wa_ZTDM_SAPOUTPUT-MATKL = '3'.
    wa_ZTDM_SAPOUTPUT-STATE = '1'.
    UPDATE ZTDM_SAPOUTPUT FROM wa_ZTDM_SAPOUTPUT.
    Write: 'UPDATE returned' , sy-subrc.
    SKIP.
    The given Dataset having PK=1 doesn't get updated.
    Maybe my understanding is wrong:
    Is it correct that the updated dataset ist defined by the primary key in this workingarea?
    My Primary Key is PK.
    Can you see the error?

    UPDATE  dbtab      FROM wa. or
    UPDATE (dbtabname) FROM wa.
    Changes one single line in a database table, using a primary key to identify the line and taking the values to be changed from the specified work area, wa. The data is read out of wa from left to right, matching the line structure of the database table dbtab. The structure of wa remains unchanged. This means that wa must be at least as wide (see DATA) as the line structure of dbtab, and have the same alignment. Otherwise, a runtime error occurs.
    If either the database table, dbtab, or the work area, wa, contain Strings, wa must be compatible with the line structure of dbtab.
    Example
    Changing the telephone number of the customer with customer number '12400177' in the current client:
    DATA   wa TYPE scustom.
    SELECT SINGLE * FROM scustom INTO wa
      WHERE id = '12400177'.
    wa-telephone = '06201/44889'.
    UPDATE scustom FROM wa.
    When the command has been executed, the system field SY-DBCNT contains the number of updated lines (0 or 1).
    Examples
    Update discount for the customer with the customer number '00017777' to 3 percent (in the current client):
    DATA: wa TYPE scustom.
    SELECT SINGLE * FROM scustom INTO wa
      WHERE id = '00017777'.
    wa-discount = '003'.
    UPDATE scustom FROM wa.
    The Return Code is set as follows:
    SY-SUBRC = 0:
    The specified line has been updated.
    SY-SUBRC = 4:
    The system could not update any line in the table, since there is no line with the specified primary key.
    rwrd if helpful
    bhupal

Maybe you are looking for

  • [AWESOME WM] How to define the size of textbox widget

    Hi, I have problem with network widget. When some transfer has place widget change it's value and move all widgets that are place before it. Is there any why to set it's width to some fix value so it have some margin for changes? To create widget I u

  • How to access new data in User Message Event Callback?

    I am using the Simple LabVIEW OI as the model for my TestStand user interface. The sequence sends a User Message to the OI to request the string array of tests to run. But I am having great difficulty making this string array data available to the ev

  • Stays in edit even when I have saved my picture to a new name. Says in process

    Why does it say edit in process when I am done?

  • Snapshot zone and dataset

    Hi, I (try !!) to manage a X86-64 solaris computer. and I want to create à snapshot in a secondary zone.. That zone exist is ready and booted and I can login on it. So I use zfs snapshot koonytan/root/datatank to create the snapshot. And I got an err

  • "MCI command handling window" not respond

    im currently running a fresh new Windows XP Pro x64 and X-FI eXtremeMusic. installed cd drivers, then updated to last versions. every like 2-3 restarts i get this error window: "MCI command handling window" not responding at logoff, waiting for me to