0

I am trying not to show the period in the values using the Replace function but I am getting Buffer Overflow error when I use my select statement like this:

SELECT 
       Volume, REPLACE(Volume,'.','')
      FROM MyTable

The data in my table looks like this:

88.97
448.58 and etc

i want to show like this with out the period:

8897
44858

I have tried to use different ways but still getting the error. How can I achieve this?

3
  • you need to cast volume to a string prior to replacing the decimal point with an empty string. Can't give you the prosgresql syntax for that though. Commented Sep 16, 2013 at 23:42
  • the data type is varchar in this case (character varying in postgres) Commented Sep 16, 2013 at 23:45
  • can someone please help? Commented Sep 17, 2013 at 0:26

1 Answer 1

1

One way: historical PostgreSQL syntax.

SELECT Volume, REPLACE((Volume)::text,'.','')
FROM MyTable

Another way: standard SQL syntax.

SELECT Volume, REPLACE(cast(Volume as text),'.','')
FROM MyTable

Yet another way: PostgreSQL function-like syntax.

SELECT Volume, REPLACE(text(Volume),'.','')
FROM MyTable
Sign up to request clarification or add additional context in comments.

2 Comments

thanks i really appreciate your help. i have tried but i am getting this error "on NPS CLOB data type" I am using Netezza database which uses PostgreSQL and the type for this field is Character Varying(6).
PostgreSQL doesn't have a CLOB data type. But Oracle does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.