old peace of code:
...
while. lim>:#t do.
if. sqlbad rc=. >{. z do. SQL_ERROR;'';0 return. end.
if. SQL_NO_DATA=src rc do. break. end.
NB. last item of z contains bytes remaining before last get
dat =. dat , (LONGBUF<.>{:z) {. , >4{z
dat =. t
z=. sqlgetdata get
end.
...
the problem that under linux+postgresql the >{. sqlgetdata get never
returns SQL_NO_DATA for long varchar columns. In this case the condition
lim>:#t works incorrect.
modified code:
...
while. 1 do.
if. sqlbad rc=. >{. z do. SQL_ERROR;'';0 return. end.
if. SQL_NO_DATA=src rc do. break. end.
NB. last item of z contains bytes remaining before last get
t =. dat , (LONGBUF<.>{:z) {. , >4{z
if. lim<#t do. break. end.
dat =. t
z=. sqlgetdata get
end.
...
Does it only err in linux but not in window? Could you post the
unmodified version for comparison?
Yuri Burger wrote:
sorry, prev post was html formatted. following is right source:
datlong=: 3 : 0"1
NB.*datlong v-- fetches long types. Unfortunately looping is
NB. unavoidable. Setting the (LONGBUF) to the largest value the
NB. ODBC driver can reliably use will reduce the amount of
NB. looping. Setting (LONGBUF) to high can result in domain
NB. errors being signaled by (cd) and wrong lengths being
NB. returned so be careful! 5000 is about as high as this value
NB. can be set for most drivers.
NB.
NB. Note: Sql2000 can tolerate buffer sizes of 30000 chars (July 2002)
NB.
NB. Note: In the case of SQL Server 7/2000 short var types can be
NB. up to 8000 bytes and be fetched with (ddfch) much faster.
NB.
NB. monad: datlong ilShCol
sc=. b0 y
NB. Oleg's fix Oct 2003
NB. get=. sc,SQL_CHAR;(LONGBUF$' ');(>:LONGBUF);,0
get=. sc,SQL_BINARY;(LONGBUF$' ');LONGBUF;,0
z=. sqlgetdata get
lim=. a:{ >{:z NB. last item of first get is data length
dat=. ''
NB. fixed by Yuri Burger
while. 1 do. NB. FIX
if. sqlbad rc=. >{. z do. SQL_ERROR;'';0 return. end.
if. SQL_NO_DATA=src rc do. break. end.
NB. last item of z contains bytes remaining before last get
t =. dat , (LONGBUF<.>{:z) {. , >4{z NB. FIX
if. lim<#t do. break. end. NB. FIX
dat =. t
z=. sqlgetdata get
end.
DD_OK ; dat ; #dat NB. return code, data, length
)
--
Yuri Burger
Senior Software Architect
Labs Zoral, Kiev
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm