I am having an issue when inserting a TDateTime into a PostgreSQL timestamp without time zone column.
Using a stored procedure I assign the value like so
Code: Select all
FInsertUpdateProc.ParamByName('inShowTime').asDateTime := Now;
FInsertUpdateProc.Execute;
Do you know what am I doing wrong?
Edit:
I did a quick test using the following
Code: Select all
CREATE TABLE test (
id serial NOT NULL,
timestamptest timestamp without time zone,
PRIMARY KEY (id));
Code: Select all
program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils,
DateUtils,
Uni,
UniSQLMonitor,
DASQLMonitor,
PostgreSQLUniProvider,
STD_Database;
var
Conn : TUniConnection;
Qry : TUniQuery;
SQLMonitor : TUniSQLMonitor;
begin
SQLMonitor := TUniSQLMonitor.Create(nil);
SQLMonitor.Options := [moDBMonitor];
SQLMonitor.Active := true;
Conn := TUniConnection.Create(nil);
Conn.ProviderName := 'PostgreSQL';
Conn.Server := 'localhost';
Conn.Port := 5432;
Conn.Username := 'postgres';
Conn.Password := 'password';
Conn.Database := 'db';
Conn.Connect;
Qry := TUniQuery.Create(nil);
Qry.Connection := Conn;
Qry.SQL.Add('INSERT INTO Test (TimestampTest) VALUES (:TimestampTest)');
Qry.Prepare;
Qry.ParamByName('TimestampTest').AsDateTime := EncodeDateTime(2013, 6, 25, 18, 35, 0, 0);
Qry.Execute;
Qry.Free;
Conn.Disconnect;
Conn.Free;
end.
Thanks
Edit 2:
I forgot to include my versions so here they are
Windows XP SP3 32bit
Delphi 7 w/ Unidac 5.0.1 for Delphi7
PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 32-bit
I also added additional logging to PostgreSQL and it shows the parameter as
$6 = '152075-04-11 11:22:15.6288'