X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E320B3A43C2 for ; Wed, 17 Nov 2004 22:34:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45642-02 for ; Wed, 17 Nov 2004 22:33:49 +0000 (GMT) Received: from mail.arcompanies.net (unknown [66.249.130.221]) by svr1.postgresql.org (Postfix) with ESMTP id 8465E3A437D for ; Wed, 17 Nov 2004 22:33:51 +0000 (GMT) Received: from fame.arcompanies.net ([69.3.176.250] helo=ebrown) by mail.arcompanies.net with smtp (Exim 3.35 #1 (Debian)) id 1CUYN5-0007gX-00; Wed, 17 Nov 2004 14:33:51 -0800 Message-ID: <08da01c4ccf5$82256880$fb04a8c0@arcHead.arcompanies.net> From: "Ed Brown" To: "Ed Brown" , References: <07d901c4ccd8$254b2360$fb04a8c0@arcHead.arcompanies.net> Subject: Re: SQL Error- SQLBindColumn and TimeStamp Field Date: Wed, 17 Nov 2004 14:33:49 -0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_08D7_01C4CCB2.73E1F650" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=HTML_30_40, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200411/84 X-Sequence-Number: 4698 This is a multi-part message in MIME format. ------=_NextPart_000_08D7_01C4CCB2.73E1F650 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I found the answer, and I'm posting the response in case somebody else = someday has this problem. The problem is the field type change between = ODBC version 2.0 and 3.0, so I need to use SQL_C_TIMESTAMP and = SQL_TIMESTAMP instead of SQL_C_TYPE_TIMESTAMP and SQL_TYPE_TIMESTAMP, = which are for version 3.0. ODBC will not map between them. So the call = is=20 retcode :=3D SQLBindParameter(hSTMT, i + 1, SQL_PARAM_INPUT, SQL_C_TIMESTAMP, SQL_TIMESTAMP, SizeOf(SQL_TIMESTAMP_STRUCT), 0 , lParams[i], SizeOf(SQL_TIMESTAMP_STRUCT), piTemp) ; ----- Original Message -----=20 From: Ed Brown=20 To: pgsql-odbc@postgresql.org=20 Sent: Wednesday, November 17, 2004 11:03 AM Subject: [ODBC] SQL Error- SQLBindColumn and TimeStamp Field I have been trying to do an insert into a TimeStamp field in = Postgresql 7.34 (running on Suse 9.0, if it matters). The application = is in Delphi 7.0, but the code is similar enough that you C gurus should = be able to see what's happening. I get the text as a string, parse it = into the various elements, and populate the SQL_TimeStamp_Structure. = When I execute the SQLBindColumn function I get the following message: Unable to Bind Parameter- State: S1003, Error # 0, = [Microsoft][ODBC Driver Manager] Program type out of range The values in the structure are reasonable, and other elements work = properly. Can anyone either tell me what I'm doing wrong, or show me an = example of setting a Timestamp value that works? Thanks very much. Code Follows Ed Brown -------------------------------------------------------------------------= ----- New(pTimeStamp); DecodeDate(dtThis, i1,i2,i3); pTimeStamp^.year :=3D i1; pTimeStamp^.Month :=3D i2; pTimeStamp^.Day :=3D i3; DecodeTime(dtThis, i1,i2,i3,i4); pTimeStamp^.Hour :=3D i1; pTimeStamp^.minute :=3D i2; pTimeStamp^.second :=3D i3; pTimeStamp^.fraction :=3D i4; New(piTemp); lIntegers.Add(piTemp); // Fails on next call retcode :=3D SQLBindParameter(hSTMT, i + 1, SQL_PARAM_INPUT, SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, SizeOf(SQL_TIMESTAMP_STRUCT), 0 , pTimeStamp, SizeOf(SQL_TIMESTAMP_STRUCT), piTemp) ; -------------------------------------------------------------------------= ----- The values are: pTimeStamp^.year =3D 200 =20 pTimeStamp^.Month =3D 7 pTimeStamp^.Day =3D 15 pTimeStamp^.Hour :=3D 11 pTimeStamp^.minute :=3D 15 pTimeStamp^.second :=3D 0 pTimeStamp^.fraction :=3D 0 ------=_NextPart_000_08D7_01C4CCB2.73E1F650 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I found the answer, and I'm posting the = response in=20 case somebody else someday has this problem. The problem is the field = type=20 change between ODBC version 2.0 and 3.0, so I need to use=20 SQL_C_TIMESTAMP and SQL_TIMESTAMP instead of = SQL_C_TYPE_TIMESTAMP=20 and SQL_TYPE_TIMESTAMP, which are for version 3.0. ODBC will not = map=20 between them. So the call is
 
          &nbs= p; retcode=20 :=3D SQLBindParameter(hSTMT, i + 1,=20 SQL_PARAM_INPUT,
         = ;    SQL_C_TIMESTAMP,
    &nbs= p;        SQL_TIMESTAMP,
 = ;            = SizeOf(SQL_TIMESTAMP_STRUCT),=20 0 ,
          &= nbsp;  lParams[i],
       = ;      SizeOf(SQL_TIMESTAMP_STRUCT),=20 piTemp) ;
----- Original Message -----
From:=20 Ed=20 Brown
Sent: Wednesday, November 17, = 2004 11:03=20 AM
Subject: [ODBC] SQL Error- = SQLBindColumn=20 and TimeStamp Field

I have been trying to do an insert = into a=20 TimeStamp field in Postgresql 7.34 (running on Suse 9.0, if it = matters). =20 The application is in Delphi 7.0, but the code is similar enough that = you C=20 gurus should be able to see what's happening.  I get the text as = a=20 string, parse it into the various elements, and populate the=20 SQL_TimeStamp_Structure. When I execute the SQLBindColumn = function I get=20 the following message:
 
    Unable to Bind = Parameter-=20 State: S1003, Error # 0, [Microsoft][ODBC Driver Manager] Program type = out of=20 range
 
The values in the structure are = reasonable, and=20 other elements work properly. Can anyone either tell me what I'm = doing=20 wrong, or show me an example of setting a Timestamp value that=20 works?
 
Thanks very much. Code = Follows
 
Ed Brown

 
 New(pTimeStamp);
 DecodeDate(dtThis,=20 i1,i2,i3);
 pTimeStamp^.year :=3D = i1;
 pTimeStamp^.Month :=3D=20 i2;
 pTimeStamp^.Day :=3D i3;
 DecodeTime(dtThis,=20 i1,i2,i3,i4);
 pTimeStamp^.Hour :=3D = i1;
 pTimeStamp^.minute :=3D=20 i2;
 pTimeStamp^.second :=3D i3;
 pTimeStamp^.fraction = :=3D=20 i4;
 
 New(piTemp);
 lIntegers.Add(piTemp);
 
// Fails on next call
 retcode :=3D SQLBindParameter(hSTMT, i + 1,=20 = SQL_PARAM_INPUT,
  SQL_C_TYPE_TIMESTAMP,
  SQL_= TYPE_TIMESTAMP,
  SizeOf(SQL_TIMESTAMP_STRUCT),=20 = 0 ,
  pTimeStamp,
  SizeOf(SQL_TIMESTAMP_S= TRUCT),=20 piTemp) ;

The values are:
 
    pTimeStamp^.year = =3D 200   
    pTimeStamp^.Month =3D  7
    pTimeStamp^.Day = =3D 15
   =20 pTimeStamp^.Hour :=3D 11
    pTimeStamp^.minute = :=3D 15
    pTimeStamp^.second=20 :=3D 0
    pTimeStamp^.fraction :=3D = 0
 
------=_NextPart_000_08D7_01C4CCB2.73E1F650--