Curious about a oratcl 4.4 behavior

Help
2008-11-17
2013-04-16
  • Larry W. Virden
    Larry W. Virden
    2008-11-17

    I wrote some code a while back using oratcl 4.2 . The code from an oracle point of view did this:

    set logon [ oralogon / ]
    set ora_cur [ oraopen $logon ]

    oraparse $ora_cur "select * from systemlist "
    oraexec $ora_cur

    set count 0
    while {[orafetch $ora_cur -dataarray rowAsArray \         -indexbyname \         -command { processIEI } ] == 0} {  incr count; }

    oraclose $ora_cur
    oralogoff $logon

    Inside processIEI, I had code which looked at the data being retrieved, compared it to some data found elsewhere, and, if met some criteria, did a puts on a column value for each row.

    When I moved my code to oratcl 4.4, the code would stop before outputting any information.

    I added some debug statements and saw that the orafetch was returning one value, then quitting the loop.

    I knew I didn't want to send my hundred line program to this forum, so I started eliminating pieces to see what I could use as a small coherent example.

    When I ran my reduced program, it worked!

    I looked at the difference between my reduced program and my production program and there was one line that I specifically had changed. I had changed proc processIEI to return a 0 at the end, rather than just a return.

    So, I returned to my original program, added a return of 0. That ran a bit and still quit early - I looked at the code closely and found there was an early return in some cases - I added a 0 as the return argument and, again, the program started and ran through the process.

    So, my question is this - when I look at the orafetch line, I would interprete the testing of the return value to mean "if orafetch returns a 0 incr count". In other words, as long as more data is being fetched. Now, however, it appears that orafetch returns a non-zero return code if the -command returns a non-zero return code.

    Is that an intentional change to orafetch? I don't see this specifically mentioned in the man page. I can see an argument for this - it just caught me unaware.

     
    • Christoph Bauer
      Christoph Bauer
      2008-11-19

      This reminds me oin my Patch 1806291. Try it or the CVS HEAD version.

      Christoph Bauer