Results 1 to 3 of 3

Thread: For Read Only

  1. #1
    Join Date
    Oct 2003
    Hyderabad, India

    Unhappy Unanswered: For Read Only

    Hello Group,
    I have couple of errors occuring when i try to add the "FOR READ ONLY" Clause in the SP's As well as in Functions.
    Here are the Cases where im getting Compilation Errors
    1. select count(1) into var1 from tab1 where <condition> for read only --> when i have this statement in the SP im getting compilation error.
    So Can we have For Read only clause in this scenerio Or not?
    2. insert into table1 (select * from table2 for read only ) --> Same case as the above.. getting compilation errors. Any Reasons?
    3. when i have a "FOR READ ONLY" clause in a SQL statement which is in Function the function is not getting built. Can't we have for read only clause in functions?

    I have tested this on Latest DB2 V8.1 Fix pack 3 as well as on older sytems.

    Can some one throw some light on the Read Only clauses and its restrictions and if possible could some one share some documentation on the same..

    I would be happy if i could help documentation both on SP's i& Functions Creationg in DB2 .

    Looking for Early help on this.

  2. #2
    Join Date
    Jan 2003
    Provided Answers: 5
    The FOR READ ONLY clause is only vaild on Select-Statement. In your examples, none are Select-Statements. 1) is a SELECT INTO and 2) is a full-select inside an INSERT. Maybe if you see the grammar for a Select-Statement (see page 601 of the V8 SQL REference Manual Volume 1) it might make more sense.

    I do not know why you cannot use it in a function, although I suspect that it is not on a Select-Statement.



  3. #3
    Join Date
    May 2003
    The FOR READ ONLY clause indicates that the result table is read-only and therefore the cursor cannot be referred to in Positioned UPDATE and DELETE statements.

    This applies to cursor operations where one may later perform an UPDATE (or DELETE) WHERE CURRENT OF CURSOR (positioned UPDATE and DELETE statements).

    I would not worry about it in your situations.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts