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 653023A445C for ; Wed, 17 Nov 2004 22:18:16 +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 39753-03 for ; Wed, 17 Nov 2004 22:18:12 +0000 (GMT) Received: from mail.arcompanies.net (unknown [66.249.130.221]) by svr1.postgresql.org (Postfix) with ESMTP id 95F7F3A4456 for ; Wed, 17 Nov 2004 22:18:13 +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 1CUY7w-0007WZ-00; Wed, 17 Nov 2004 14:18:12 -0800 Message-ID: <08d001c4ccf3$527ba290$fb04a8c0@arcHead.arcompanies.net> From: "Ed Brown" To: "Greg Campbell" Cc: References: <07d901c4ccd8$254b2360$fb04a8c0@arcHead.arcompanies.net> <419BB1ED.7050000@us.michelin.com> Subject: Re: SQL Error- SQLBindColumn and TimeStamp Field Date: Wed, 17 Nov 2004 14:18:10 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit 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.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/83 X-Sequence-Number: 4697 Specifically I am trying to execute a query like Insert into Table(field1, field2, field3) values(?,?,?) Where field3 is Postgres type 11, or Timestamp. The application I have written queries the database to determine field types in an attempt to properly insert the record. Yes, I could execute the query you describe below, except that means I would have to rewrite my application to not use query parameters, which has it own issues. And my apologies- I dropped a zero somewhere. The year is actually 2000, not 200. I did find a reference online at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcdatetime_data_type_changes.asp that talks about datetime-type variable changes between ODBC versions 1 and 2. I need to do some experimenting- I think I may need to change data type. Ed ----- Original Message ----- From: "Greg Campbell" To: "Ed Brown" Cc: Sent: Wednesday, November 17, 2004 12:17 PM Subject: Re: [ODBC] SQL Error- SQLBindColumn and TimeStamp Field > Please clarify "trying to insert a Timestamp field" > Are you doing Data Definition -- creating a timestamp field > or > Data Manipulation -- populating data into an existing timestamp field. > > If data manipulation: > I do not know Delphi, but couldn't you execute as query string against a > connection -- a string like > "INSERT INTO my_table (my_time) VALUES ('2004-11-17 12:10:35')"? > > and did you mean for the year value to be 200? > > > > Ed Brown wrote: > > > 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 := i1; > > pTimeStamp^.Month := i2; > > pTimeStamp^.Day := i3; > > DecodeTime(dtThis, i1,i2,i3,i4); > > pTimeStamp^.Hour := i1; > > pTimeStamp^.minute := i2; > > pTimeStamp^.second := i3; > > pTimeStamp^.fraction := i4; > > > > New(piTemp); > > lIntegers.Add(piTemp); > > > > // Fails on next call > > retcode := 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 = 200 > > pTimeStamp^.Month = 7 > > pTimeStamp^.Day = 15 > > pTimeStamp^.Hour := 11 > > pTimeStamp^.minute := 15 > > pTimeStamp^.second := 0 > > pTimeStamp^.fraction := 0 > > > > ---------------------------------------------------------------------------- ---- ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match