inside odbc.ijs there is a verb for reading blob

datlong=: 3 : 0"1
sc=. b0 y
get=. sc,SQL_BINARY;(LONGBUF$' ');LONGBUF;,0

z=. sqlgetdata get
lim=. >{:z
dat=. ''
while. lim>:#dat do.
  if. sqlbad rc=. >{. z do. SQL_ERROR;'';0 return. end.
  if. SQL_NO_DATA=src rc do. break. end.

  dat=. dat , (LONGBUF<.>{:z) {. , >4{z
  z=. sqlgetdata get
end.
DD_OK ; dat ; #dat
)

the line lim=. >{:z  is problematic because lim will be changed by side effect
of subsequent sqlgetdat. A possible fix is use copy by value

lim=. a:&{ >{:z

or do not use lim because it is not required.

z=. sqlgetdata get
dat=. ''
while. do.
  if. sqlbad rc=. >{. z do. SQL_ERROR;'';0 return. end.
  if. SQL_NO_DATA=src rc do. break. end.

  dat=. dat , (0>.LONGBUF<.>{:z) {. >4{z  NB. >{:z will be _1 for NULL
  z=. sqlgetdata get
end.
DD_OK ; dat ; #dat
)

The loop can terminate because SQL_NO_DATA will be returned when attempting
sqlgetdata after all data have been read.

-- 
regards,
bill
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to