0

I am using PostgreSQL and I need fields as strings not text. Here is the statement

select AutoNbr, 
       concat_ws(', ', Site_Street, Site_City, Site_Country, Site_PostCode) as cFullAddress , Order_Date 
from Porder

What I need is the cFullAddress to be a varchar not a text field.

sippytom
  • 27
  • 9
  • Why do you think you need that? Those two type are essentially identical in Postgres –  Mar 27 '17 at 06:00
  • The Delphi grid I am using sees the difference between Text (memo) and a string. The grid just said (memo) not the string information – sippytom Mar 27 '17 at 21:16

1 Answers1

0

According to documents:

If character varying is used without length specifier, the type accepts strings of any size. The latter is a PostgreSQL extension.

In addition, PostgreSQL provides the text type, which stores strings of any length. Although the type text is not in the SQL standard, several other SQL database management systems have it as well.

But you can cast it into varchar;

select AutoNbr, 
 concat_ws(', ', Site_Street, Site_City, Site_Country, Site_PostCode)::varchar as cFullAddress , Order_Date,
 CAST(concat_ws(', ', Site_Street, Site_City, Site_Country, Site_PostCode) as VARCHAR)
from Porder

Related link for using cast: type cast

Difference between text and varchar (character varying)

Community
  • 1
  • 1
light souls
  • 698
  • 1
  • 8
  • 17