Assignment value miss: null to TFloatField

Assignment value miss: null to TFloatField

Postby Eden0928 » Wed 13 Nov 2013 06:18

SQL:
Code: Select all
CREATE TABLE a_t2
(
  f1 integer NOT NULL,
  f2 varchar(10) NOT NULL,
  f3 float,
  f4 TimeStamp,
  PRIMARY KEY (f1, f2)
)


Delphi XE5
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var V: Variant;
begin
  V := null;
  SQLQuery1.SQL.Text := 'INSERT INTO a_t2(f1, f2, f3, f4) VALUES(:A, :B, :C, :D) ';
  SQLQuery1.Params[0].Value := 1;
  SQLQuery1.Params[1].Value := '';
  SQLQuery1.Params[2].Value := V;
  SQLQuery1.Params[3].Clear();
  SQLQuery1.ExecSQL(False);
end;


Get logs, below:
Code: Select all
  2013/11/13 pm 02:14:47 n/a DBXPGSQL monitoring is started Complete
  2013/11/13 pm 02:14:47 2.954 Execute: INSERT INTO a_t2(f1, f2, f3, f4) VALUES( $1 ,  $2 ,  $3 ,  $4 )
:1 (Int16,IN) = 1
:2 (WideString,IN)
:3 (Unknown,IN) = <NULL>
:4 (Unknown,IN) = <NULL>

Message:
Code: Select all
Column "f3" is of type double precision, but the expression is of type character varying
Eden0928
 
Posts: 44
Joined: Sun 22 Apr 2012 14:08

Re: Assignment value miss: null to TFloatField

Postby AlexP » Wed 13 Nov 2013 11:17

Hello,

You should explicitly specify the type of the parameters


Code: Select all
  sqlqry1.SQL.Text := 'INSERT INTO a_t2(f1, f2, f3, f4) VALUES(:A, :B, :C, :D) ';
  sqlqry1.Params[0].Value := 1;
  sqlqry1.Params[1].Value := '';
  sqlqry1.Params[2].DataType := ftFloat;
  sqlqry1.Params[2].Value := V;
  sqlqry1.Params[3].DataType := ftTimeStamp;
  sqlqry1.Params[3].Clear();
  sqlqry1.ExecSQL(False);
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35

Re: Assignment value miss: null to TFloatField

Postby Eden0928 » Wed 13 Nov 2013 14:55

Yes, You are right, when added DataType property Value.

It is OK, and solution in http://forums.devart.com/viewtopic.php?f=35&t=28284, too.

Because, DataSetProvider need DeltaDS.NewValue / OldValue convert Variant.

AsVariant := Variant <- This is easy! Auto convert datatype.(Speed down! :twisted: )

So, I hope could more smart with dbx for postgreSQL and PgDAC in Devart Products. :mrgreen:
Eden0928
 
Posts: 44
Joined: Sun 22 Apr 2012 14:08


Return to dbExpress driver for PostgreSQL