Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

problem with SQLBindCol and fetching multiple rows

4 posts in General Discussion Last posting was on 2008-06-27 02:19:58.0Z
ptovo Posted on 2008-06-25 23:02:25.0Z
Sender: 64ab.48629c57.1804289383@sybase.com
From: ptovo
Newsgroups: ianywhere.public.general
Subject: problem with SQLBindCol and fetching multiple rows
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4862ce81.6cec.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 25 Jun 2008 16:02:25 -0700
X-Trace: forums-1-dub 1214434945 10.22.241.41 (25 Jun 2008 16:02:25 -0700)
X-Original-Trace: 25 Jun 2008 16:02:25 -0700, 10.22.241.41
Lines: 28
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6934
Article PK: 5159

How do I define the C type and pass it to SQLBindCol
for the Strlen_or_Ind argument when retriving more than 1
row
at a time?

When fetching one row, I just pass the address of a
different
SQLLEN value and it works fine.
But, for more than 1 row, I have tried passing an array of
SQLLEN values per column as well as a single array for all
columns (with a different offset into the array depending on
the column).

I can't get it to work - I keep getting an invalid bus
alignment error when doing the fetch.

Does anyone have an example of how to do this?

Thanks,
Pat

SQLRETURN SQLBindCol(
SQLHSTMT StatementHandle,
SQLUSMALLINT ColumnNumber,
SQLSMALLINT TargetType,
SQLPOINTER TargetValuePtr,
SQLLEN BufferLength,
SQLLEN * StrLen_or_Ind);


Mark Culp Posted on 2008-06-26 02:53:56.0Z
Message-ID: <486304AF.484436D4@iAnywhere.com>
From: Mark Culp <reply_to_newsgroups_only_please_nospam_mark.culp@iAnywhere.com>
X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: problem with SQLBindCol and fetching multiple rows
References: <4862ce81.6cec.1681692777@sybase.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 25 Jun 2008 19:53:56 -0700
X-Trace: forums-1-dub 1214448836 10.22.241.152 (25 Jun 2008 19:53:56 -0700)
X-Original-Trace: 25 Jun 2008 19:53:56 -0700, vip152.sybase.com
Lines: 65
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6935
Article PK: 5161

Please always state the version and _build number_ that you are
using... and in this case, also please state the platform that you
are using and whether you are building a 32bit or 64bit client app.

From what you have said, it sounds like you are using a Unix platform,
and since you are getting bus faults, my guess is that you are using
one of the big endian Unixes.... so I'll take a wild guess (just for
the fun of it - perhaps because its late) that you are using Solaris?
(but my answer that follows does not really matter too much on which
Unix big endian platform that you are using).

The fact that you are getting a bus fault means that the pointer value
that you are passing in is not properly aligned for the data type that
is being used, or one of the subsequent calculated value locations
is not properly aligned (see below).
If you are building a 32bit app, then your SQLLEN value must be 4-byte
aligned and if a 64bit app then the SQLLEN must be 8-byte aligned
because SQLLEN is 4 and 8-byte values respectively (and the big endian
Unix hw platforms require these rules w/ some exceptions).

Also, if you are using the SQL_ATTR_ROW_BIND_TYPE option, the value
used (i.e. row width) must also be a "nice" multiple of 4 (or 8) bytes,
otherwise the calculations to where the next row sits will result in
an unaligned value, and hence a bus fault.

HTH
--
Mark Culp
SQLAnywhere Research and Development
iAnywhere Solutions Engineering
-------------------------------------------------------------------------
-- SQL Anywhere Blog Center - http://www.sybase.com/sqlanyblogs
-- SQL Anywhere Developer Community:
-- http://www.sybase.com/developer/library/sql-anywhere-techcorner
-------------------------------------------------------------------------

ptovo wrote:
>
> How do I define the C type and pass it to SQLBindCol
> for the Strlen_or_Ind argument when retriving more than 1
> row
> at a time?
>
> When fetching one row, I just pass the address of a
> different
> SQLLEN value and it works fine.
> But, for more than 1 row, I have tried passing an array of
> SQLLEN values per column as well as a single array for all
> columns (with a different offset into the array depending on
> the column).
>
> I can't get it to work - I keep getting an invalid bus
> alignment error when doing the fetch.
>
> Does anyone have an example of how to do this?
>
> Thanks,
> Pat
>
> SQLRETURN SQLBindCol(
> SQLHSTMT StatementHandle,
> SQLUSMALLINT ColumnNumber,
> SQLSMALLINT TargetType,
> SQLPOINTER TargetValuePtr,
> SQLLEN BufferLength,
> SQLLEN * StrLen_or_Ind);


ptovo Posted on 2008-06-26 16:49:28.0Z
Sender: 64ab.48629c57.1804289383@sybase.com
From: ptovo
Newsgroups: ianywhere.public.general
Subject: Re: problem with SQLBindCol and fetching multiple rows
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4863c898.d97.1681692777@sybase.com>
References: <486304AF.484436D4@iAnywhere.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 26 Jun 2008 09:49:28 -0700
X-Trace: forums-1-dub 1214498968 10.22.241.41 (26 Jun 2008 09:49:28 -0700)
X-Original-Trace: 26 Jun 2008 09:49:28 -0700, 10.22.241.41
Lines: 96
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6937
Article PK: 5163

You guessed right - solaris is the platform.
The SQL Anywhere version is 10.0.1.3533 and I'm building
a 64-bit application.
I'm using the include files (odbc.h, unixodbc.h,
etc)supplied
by Sybase, and have defined UNIX, UNIX64, and
LONG_IS_64BITS.
Based on odbc.h, SQLLEN will be a long.
So, I don't understand why this isn't working.

ALso, I was looking for an example of how to pass in and use
the Strlen_or_Ind parameter when dealing with multiple
columns
and multiple rows. The SQLBindCol() procedure defines this
as a SQLLEN *. Should I just be passing a pointer to a
1-dimensional array of SQLLEN, and, if so, how are the
values
layed out upon return?

Let me know if I should open a support case on this...

Thanks,
Pat

> Please always state the version and _build number_ that
> you are using... and in this case, also please state the
> platform that you are using and whether you are building a
> 32bit or 64bit client app.
>
> From what you have said, it sounds like you are using a
> Unix platform, and since you are getting bus faults, my
> guess is that you are using one of the big endian
> Unixes.... so I'll take a wild guess (just for the fun of
> it - perhaps because its late) that you are using Solaris?
> (but my answer that follows does not really matter too
> much on which Unix big endian platform that you are
> using).
>
> The fact that you are getting a bus fault means that the
> pointer value that you are passing in is not properly
> aligned for the data type that is being used, or one of
> the subsequent calculated value locations is not properly
> aligned (see below). If you are building a 32bit app, then
> your SQLLEN value must be 4-byte aligned and if a 64bit
> app then the SQLLEN must be 8-byte aligned because SQLLEN
> is 4 and 8-byte values respectively (and the big endian
> Unix hw platforms require these rules w/ some exceptions).
>
> Also, if you are using the SQL_ATTR_ROW_BIND_TYPE option,
> the value used (i.e. row width) must also be a "nice"
> multiple of 4 (or 8) bytes, otherwise the calculations to
> where the next row sits will result in an unaligned value,
> and hence a bus fault.
>
> HTH
> --
> Mark Culp
> SQLAnywhere Research and Development
> iAnywhere Solutions Engineering
> ----------------------------------------------------------
> --------------- -- SQL Anywhere Blog Center -
> http://www.sybase.com/sqlanyblogs -- SQL Anywhere
> Developer Community: --
>
http://www.sybase.com/developer/library/sql-anywhere-techcorner
> ----------------------------------------------------------
> --------------- ptovo wrote:
> >
> > How do I define the C type and pass it to SQLBindCol
> > for the Strlen_or_Ind argument when retriving more than
> > 1 row
> > at a time?
> >
> > When fetching one row, I just pass the address of a
> > different
> > SQLLEN value and it works fine.
> > But, for more than 1 row, I have tried passing an array
> > of SQLLEN values per column as well as a single array
> > for all columns (with a different offset into the array
> > depending on the column).
> >
> > I can't get it to work - I keep getting an invalid bus
> > alignment error when doing the fetch.
> >
> > Does anyone have an example of how to do this?
> >
> > Thanks,
> > Pat
> >
> > SQLRETURN SQLBindCol(
> > SQLHSTMT StatementHandle,
> > SQLUSMALLINT ColumnNumber,
> > SQLSMALLINT TargetType,
> > SQLPOINTER TargetValuePtr,
> > SQLLEN BufferLength,
> > SQLLEN * StrLen_or_Ind);


Mark Culp Posted on 2008-06-27 02:19:58.0Z
Message-ID: <48644E64.EF040075@iAnywhere.com>
From: Mark Culp <reply_to_newsgroups_only_please_nospam_mark.culp@iAnywhere.com>
X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: problem with SQLBindCol and fetching multiple rows
References: <486304AF.484436D4@iAnywhere.com> <4863c898.d97.1681692777@sybase.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 26 Jun 2008 19:19:58 -0700
X-Trace: forums-1-dub 1214533198 10.22.241.152 (26 Jun 2008 19:19:58 -0700)
X-Original-Trace: 26 Jun 2008 19:19:58 -0700, vip152.sybase.com
Lines: 103
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6939
Article PK: 5164

SA ships with a sample called odbcfet.c which illustrates how
this can be done.

- Mark

ptovo wrote:
>
> You guessed right - solaris is the platform.
> The SQL Anywhere version is 10.0.1.3533 and I'm building
> a 64-bit application.
> I'm using the include files (odbc.h, unixodbc.h,
> etc)supplied
> by Sybase, and have defined UNIX, UNIX64, and
> LONG_IS_64BITS.
> Based on odbc.h, SQLLEN will be a long.
> So, I don't understand why this isn't working.
>
> ALso, I was looking for an example of how to pass in and use
> the Strlen_or_Ind parameter when dealing with multiple
> columns
> and multiple rows. The SQLBindCol() procedure defines this
> as a SQLLEN *. Should I just be passing a pointer to a
> 1-dimensional array of SQLLEN, and, if so, how are the
> values
> layed out upon return?
>
> Let me know if I should open a support case on this...
>
> Thanks,
> Pat
>
> ? Please always state the version and _build number_ that
> ? you are using... and in this case, also please state the
> ? platform that you are using and whether you are building a
> ? 32bit or 64bit client app.
> ?
> ? From what you have said, it sounds like you are using a
> ? Unix platform, and since you are getting bus faults, my
> ? guess is that you are using one of the big endian
> ? Unixes.... so I'll take a wild guess (just for the fun of
> ? it - perhaps because its late) that you are using Solaris?
> ? (but my answer that follows does not really matter too
> ? much on which Unix big endian platform that you are
> ? using).
> ?
> ? The fact that you are getting a bus fault means that the
> ? pointer value that you are passing in is not properly
> ? aligned for the data type that is being used, or one of
> ? the subsequent calculated value locations is not properly
> ? aligned (see below). If you are building a 32bit app, then
> ? your SQLLEN value must be 4-byte aligned and if a 64bit
> ? app then the SQLLEN must be 8-byte aligned because SQLLEN
> ? is 4 and 8-byte values respectively (and the big endian
> ? Unix hw platforms require these rules w/ some exceptions).
> ?
> ? Also, if you are using the SQL_ATTR_ROW_BIND_TYPE option,
> ? the value used (i.e. row width) must also be a "nice"
> ? multiple of 4 (or 8) bytes, otherwise the calculations to
> ? where the next row sits will result in an unaligned value,
> ? and hence a bus fault.
> ?
> ? HTH
> ? --
> ? Mark Culp
> ? SQLAnywhere Research and Development
> ? iAnywhere Solutions Engineering
> ? ----------------------------------------------------------
> ? --------------- -- SQL Anywhere Blog Center -
> ? http://www.sybase.com/sqlanyblogs -- SQL Anywhere
> ? Developer Community: --
> ?
> http://www.sybase.com/developer/library/sql-anywhere-techcorner
> ? ----------------------------------------------------------
> ? --------------- ptovo wrote:
> ? ?
> ? ? How do I define the C type and pass it to SQLBindCol
> ? ? for the Strlen_or_Ind argument when retriving more than
> ? ? 1 row
> ? ? at a time?
> ? ?
> ? ? When fetching one row, I just pass the address of a
> ? ? different
> ? ? SQLLEN value and it works fine.
> ? ? But, for more than 1 row, I have tried passing an array
> ? ? of SQLLEN values per column as well as a single array
> ? ? for all columns (with a different offset into the array
> ? ? depending on the column).
> ? ?
> ? ? I can't get it to work - I keep getting an invalid bus
> ? ? alignment error when doing the fetch.
> ? ?
> ? ? Does anyone have an example of how to do this?
> ? ?
> ? ? Thanks,
> ? ? Pat
> ? ?
> ? ? SQLRETURN SQLBindCol(
> ? ? SQLHSTMT StatementHandle,
> ? ? SQLUSMALLINT ColumnNumber,
> ? ? SQLSMALLINT TargetType,
> ? ? SQLPOINTER TargetValuePtr,
> ? ? SQLLEN BufferLength,
> ? ? SQLLEN * StrLen_or_Ind);