I found bug with odbc under linux. When you trying select long varchar from postgresql through dd the resulting string is doubled.
Following is my fix for this problem.

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

Reply via email to