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

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for PostgreSQL in Delphi and C++Builder
Post Reply
accion
Posts: 1
Joined: Mon 18 Dec 2017 11:50

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

Post by accion » Tue 19 Dec 2017 13:26

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?

azyk
Devart Team
Posts: 1047
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

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

Post by azyk » Mon 25 Dec 2017 11:20

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.

Post Reply