Skip to Content

Sender JDBC: help to construct Update statement

Hi,

I need help in writing a update statement to DB2 database in sender JDBC adapter.

The sender adapter picks up only few records say 10 at a time which match the Select query condition. So I would need to update only those selected "n" records and not all the records that match the Select query condition.

Select looks like :

Select * from <table> where <condition> fetch first <n> rows only.

But it is not allowing the following update

update <table> set <field> = <value> where <field> IN (Select * from <table> where <condition> fetch first <n> rows only)

The above statement errors because DB2 does not allows u201CFetchu201D statement within the update sub query.

Any pointers to a write update statement for n records is highly appreciatedu2026

~SaNvu2026

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jul 09, 2009 at 04:02 PM

    Santhosh,

    Try your update statement like this:

    update (Select * from <table> where <condition> fetch first <n> rows only) set <field> = <value>

    See some more information here:

    http://bytes.com/groups/ibm-db2/522816-help-update-query

    Regards,

    ---Satish

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Santhosh Kumar Vellingiri

      Hi Santosh,

      In JDBC Sender Adapter provide the following select & update statements

      Select Statement:

      select * from <table> where <condition> AND ROWNUM<N (N==No.of Rows)

      Update Statement:

      update <table> set <field> = <value> where <field> IN (Select * from <table> where <condition> AND ROWNUM<N)

      (N==No.of Rows)

      And for the error you are facing is because of the server communication link failure between the two systems.

      Check the connections and try to stop & start communication channels once.

      Regards

      Venkat Rao .G