This discussion is archived
2 Replies Latest reply: Oct 10, 2012 10:59 AM by 525868 RSS

Creating batch job to run an "Update" statement nightly

525868 Newbie
Currently Being Moderated
Hello,

I"m trying to execute a simple script which runs nightly to update records in a table if where conditions are met.

For example,
update customer set field_a = '1' where field_a <> field_b

I created a text file a.bat to handle the log-on and the sql call as shown below and it works fine.
---> sqlplus username/password@dbname @c:\sql\batch\update_field_a.sql

And the udpate_field_a.sql file contains the example statement from above.
---> update customer set field_a = '1' where field_a <> field_b

I'm on Oracle 10g and the script hangs....if I use "select" statement instead of "update", the job completes fine.

Any advises?
  • 1. Re: Creating batch job to run an "Update" statement nightly
    sb92075 Guru
    Currently Being Moderated
    user522865 wrote:
    Hello,

    I"m trying to execute a simple script which runs nightly to update records in a table if where conditions are met.

    For example,
    update customer set field_a = '1' where field_a <> field_b

    I created a text file a.bat to handle the log-on and the sql call as shown below and it works fine.
    ---> sqlplus username/password@dbname @c:\sql\batch\update_field_a.sql

    And the udpate_field_a.sql file contains the example statement from above.
    ---> update customer set field_a = '1' where field_a <> field_b

    I'm on Oracle 10g and the script hangs....if I use "select" statement instead of "update", the job completes fine.

    Any advises?
    why do you expect us to debug code that we can not see?

    UPDATE statement must be terminated with a semicolon.

    UPDATE_FIELD_A.SQL file must contain EXIT statement
  • 2. Re: Creating batch job to run an "Update" statement nightly
    525868 Newbie
    Currently Being Moderated
    The file "update_field_a.sql" contains following two lines only.

    update customer set field_a = '1' where field_a <> field_b; -- field_a not equal to field_b
    Exit;

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points