Menu

Unable to update

NLTC
2005-09-27
2013-04-25
  • NLTC

    NLTC - 2005-09-27

    Hi

    I am running the following sql statement to update a table.

    <?xml version="1.0"?>

    <!DOCTYPE sqlunit SYSTEM "file:D:\sqlunit-4.9\docs\sqlunit.dtd">

    <sqlunit>

      <connection>

        <driver>oracle.jdbc.driver.OracleDriver</driver>

        <url>jdbc:oracle:thin:@172.16.0.19:1521:vis</url>

        <user>tc122sa</user>

        <password>tc122sa</password>

      </connection>

     

      <test name="Product update">

          <sql>

            <stmt>update product set price=6.7 where partid=?</stmt>

                <param id="1" type="VARCHAR">'0834020'</param>

                </sql>

          <result\>

    </test>

    </sqlunit>

    But the table is not getting updated with the new values.
    Can anyone help me to fix this issue ?

    Thanks
    Meghanath

     
    • David Fishburn

      David Fishburn - 2005-09-28

      Did you try it like this:
      <param id="1" type="VARCHAR">0834020</param>

      No quotes should be required since we have already specified it is a VARCHAR datatype.

       
    • NLTC

      NLTC - 2005-09-28

      Hi

      Firstly we  had tried without quotes only.It didnt worked.Then we tried with the quotes , it didnt work.

      Are we missing something  ?

      Thanks
      Meghanath

       
    • James Henderson

      James Henderson - 2005-09-28

      Hi Meghanath,

      Have you tried executing the statement within the PL/SQL interpreter directly to ensure that it does not produce an error?

      Once you have confirmed that the statement does not produce an error within PL/SQL, try executing the statement as an un-parameter-ized statement within SQLunit and re-run the test.  That is, modify the SQLUnit code to be:

      <sql>
      <stmt>update product set price=6.7 where partid='0834020'</stmt>
      </sql>

      Finally, you should be checking the updatecount to ensure that a row has been modified.  Assuming that your statement will modify exactly one row, then you should use the following as the expected result within the test.

      <result>
      <updatecount>1</updatecount>
      </result>

      You will need to reset your price field within the product table database between each test.  (This will allow you to visually inspect the database and ensure the value has indeed changed.)

      Hope this helps.

       
    • Sujit Pal

      Sujit Pal - 2005-12-17

      Hi Meghanath,

      Any reason why you are using &lt; and &gt; all over the place? SQLUnit should be able to read valid XML files with angle brackets.

      -sujit

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.