Page 1 of 1

column "userid" is of type numeric but expression is of type character varying

Posted: Tue 19 Dec 2017 13:26
by accion
Hello there,
I'm building a Delphi multi-database application which was originally developed to work with Oracle. Now, I'm facing the message "column "userid" is of type numeric but expression is of type character varying" when I try to assign an integer value as a valid string like the code below.

Code: Select all

ClientDataSet1.ParamByName('userid').AsString := Trim(MaskEdit1.Text);
ClientDataSet1.Active := True;
According through my studies, the problem is that the driver doesn't convert a valid integer string to integer as native dbExpress driver does.
How can I make a workaround there?

Re: column "userid" is of type numeric but expression is of type character varying

Posted: Mon 25 Dec 2017 11:20
by azyk
To avoid the specified error, you should set the type declared in the table on PostgreSQL to the TClientDataSet parameter. For example, if the userid field is declared as INTEGER, then INTEGER should be passed to the userid parameter:

Code: Select all

ClientDataSet1.ParamByName('userid').AsInteger := StrToInt(Trim(MaskEdit1.Text));
You can find more details about mapping data types in the Type map section in the Readme.html file . This file is located in the folder where dbExpress driver for PostgreSQLwas installed.