pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
64-bit type in SQLBindParameter
3+ messages / 2 participants
[nested] [flat]

* 64-bit type in SQLBindParameter
@ 2002-10-22 15:31 Scot Loach <sloach@SANDVINE.com>
  2002-10-24 23:42 ` Re: 64-bit type in SQLBindParameter Hiroshi Inoue <Inoue@tpf.co.jp>
  0 siblings, 1 reply; 3+ messages in thread

From: Scot Loach @ 2002-10-22 15:31 UTC (permalink / raw)
  To: pgsql-odbc

Is it possible to use 64-bit types for bound queries?

Here's my setup:
FreeBSD 4.7
UnixODBC 2.2.0
PostgreSQL 7.2.1
PostgreSQL/UnixODBC driver 7.2.1

I'm using the BIGINT type for my column.
The program below prints out the error message:

[unixODBC]Error while executing the query;
ERROR:  parser: parse error at or near ")"

It works if I change the SQL_BIGINT to SQL_INTEGER, but it only uses 32 bits
of the number in that case.

#include <stdio.h>
#include <sql.h>
#include <sqlext.h>

main()
{
    SQLHENV     env;
    SQLHDBC     dbc;
    SQLINTEGER  val = 0;
    unsigned long long ll = 6000000000;

    SQLAllocEnv(&env);
    SQLAllocConnect(env, &dbc);
    SQLConnect(dbc, (SQLCHAR*)"my_db", SQL_NTS, (SQLCHAR*)0, 0, (SQLCHAR*)0,
0);
    SQLCHAR sql[] = "INSERT INTO my_table (my_column) VALUES (?)";

    HSTMT hstmt;
    SQLAllocStmt(dbc, &hstmt);
    SQLPrepare(hstmt, sql, SQL_NTS);
    SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_DEFAULT, SQL_BIGINT,
0, 0, &ll, 0, &val);
    int rv = SQLExecute(hstmt);
    if (rv == SQL_ERROR)
    {
        SQLCHAR err[6];
        SQLCHAR msg[SQL_MAX_MESSAGE_LENGTH + 1];
        SQLINTEGER e;
        SQLSMALLINT sz;
        SQLError(0, 0, hstmt, err, &e, msg, SQL_MAX_MESSAGE_LENGTH, &sz);
        printf("%s\n", msg);
    }
}


Any suggestions are appreciated!

scot.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: 64-bit type in SQLBindParameter
  2002-10-22 15:31 64-bit type in SQLBindParameter Scot Loach <sloach@SANDVINE.com>
@ 2002-10-24 23:42 ` Hiroshi Inoue <Inoue@tpf.co.jp>
  0 siblings, 0 replies; 3+ messages in thread

From: Hiroshi Inoue @ 2002-10-24 23:42 UTC (permalink / raw)
  To: Scot Loach <sloach@SANDVINE.com>; +Cc: pgsql-odbc

Scot Loach wrote:
> 
> Is it possible to use 64-bit types for bound queries?
> 
> Here's my setup:
> FreeBSD 4.7
> UnixODBC 2.2.0
> PostgreSQL 7.2.1
> PostgreSQL/UnixODBC driver 7.2.1
> 
> I'm using the BIGINT type for my column.
> The program below prints out the error message:
> 
> [unixODBC]Error while executing the query;
> ERROR:  parser: parse error at or near ")"
> 
> It works if I change the SQL_BIGINT to SQL_INTEGER, but
> it only uses 32 bits of the number in that case.
> 
> #include <stdio.h>
> #include <sql.h>
> #include <sqlext.h>
> 
> main()
> {
>     SQLHENV     env;
>     SQLHDBC     dbc;
>     SQLINTEGER  val = 0;
>     unsigned long long ll = 6000000000;
> 
>     SQLAllocEnv(&env);
>     SQLAllocConnect(env, &dbc);
>     SQLConnect(dbc, (SQLCHAR*)"my_db", SQL_NTS, (SQLCHAR*)0, 0, (SQLCHAR*)0,
> 0);
>     SQLCHAR sql[] = "INSERT INTO my_table (my_column) VALUES (?)";
> 
>     HSTMT hstmt;
>     SQLAllocStmt(dbc, &hstmt);
>     SQLPrepare(hstmt, sql, SQL_NTS);
>     SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_DEFAULT, SQL_BIGINT,
> 0, 0, &ll, 0, &val);

SQL_C_DEFAULT for SQL_BIGINT is SQL_C_CHAR.
You can't specify SQL_C_SBIGINT(UBIGINT) for the C Data Type
under the driver.

regards,
Hiroshi Inoue
	http://w2422.nsk.ne.jp/~inoue/



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: 64-bit type in SQLBindParameter
@ 2002-10-25 01:38 Scot Loach <sloach@SANDVINE.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Scot Loach @ 2002-10-25 01:38 UTC (permalink / raw)
  To: Hiroshi Inoue <Inoue@tpf.co.jp>; +Cc: pgsql-odbc

Thanks for your reply.

Does this mean that I need to convert the integer into a character buffer
(using sprintf() for example) and use the character buffer in the
SQLBindParameter statement?

That doesn't seem to work when I try it, I get the same result.

scot.


-----Original Message-----
From: Hiroshi Inoue [mailto:Inoue@tpf.co.jp]
Sent: Thursday, October 24, 2002 7:42 PM
To: Scot Loach
Cc: 'pgsql-odbc@postgresql.org'
Subject: Re: [ODBC] 64-bit type in SQLBindParameter


Scot Loach wrote:
> 
> Is it possible to use 64-bit types for bound queries?
> 
> Here's my setup:
> FreeBSD 4.7
> UnixODBC 2.2.0
> PostgreSQL 7.2.1
> PostgreSQL/UnixODBC driver 7.2.1
> 
> I'm using the BIGINT type for my column.
> The program below prints out the error message:
> 
> [unixODBC]Error while executing the query;
> ERROR:  parser: parse error at or near ")"
> 
> It works if I change the SQL_BIGINT to SQL_INTEGER, but
> it only uses 32 bits of the number in that case.
> 
> #include <stdio.h>
> #include <sql.h>
> #include <sqlext.h>
> 
> main()
> {
>     SQLHENV     env;
>     SQLHDBC     dbc;
>     SQLINTEGER  val = 0;
>     unsigned long long ll = 6000000000;
> 
>     SQLAllocEnv(&env);
>     SQLAllocConnect(env, &dbc);
>     SQLConnect(dbc, (SQLCHAR*)"my_db", SQL_NTS, (SQLCHAR*)0, 0, (SQLCHAR*)
0,
> 0);
>     SQLCHAR sql[] = "INSERT INTO my_table (my_column) VALUES (?)";
> 
>     HSTMT hstmt;
>     SQLAllocStmt(dbc, &hstmt);
>     SQLPrepare(hstmt, sql, SQL_NTS);
>     SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_DEFAULT, SQL_BIGINT,
> 0, 0, &ll, 0, &val);

SQL_C_DEFAULT for SQL_BIGINT is SQL_C_CHAR.
You can't specify SQL_C_SBIGINT(UBIGINT) for the C Data Type
under the driver.

regards,
Hiroshi Inoue
	http://w2422.nsk.ne.jp/~inoue/



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2002-10-25 01:38 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-10-22 15:31 64-bit type in SQLBindParameter Scot Loach <sloach@SANDVINE.com>
2002-10-24 23:42 ` Hiroshi Inoue <Inoue@tpf.co.jp>
2002-10-25 01:38 Re: 64-bit type in SQLBindParameter Scot Loach <sloach@SANDVINE.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox