Home » SQL & PL/SQL » SQL & PL/SQL » How to CAST a String
How to CAST a String [message #289298] Thu, 20 December 2007 10:42 Go to next message
bigpapi
Messages: 6
Registered: June 2007
Junior Member
Hey Guys;

I need to write an SQL statement that does a cast or some type of conversion from a number to a string.

I have tried a number of things and can't get it to work.

Here's what i currently have:

SELECT *
FROM TABLE1
WHERE COLUMN1 = CAST(12345678 AS STRING)

I've tried using CHAR, VARCHAR2 instead of string and it still doesn't work. When i use VARCHAR2 it says i'm missing a left parenthesis and when i use CHAR it says data value out of range. That doesn't make sense, because if i put the same value in quotes, it runs fine.

Hope someone can help me out.
thanks in advance
Re: How to CAST a String [message #289299 is a reply to message #289298] Thu, 20 December 2007 10:45 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
With VARCHAR2 you have to precise the length (thus the error).
CHAR means 1 character.

Regards
Michel
Re: How to CAST a String [message #289412 is a reply to message #289298] Fri, 21 December 2007 07:46 Go to previous message
Bill B
Messages: 1482
Registered: December 2004
Senior Member
Why no use


SELECT *
FROM TABLE1
WHERE COLUMN1 = to_char(12345678);
Previous Topic: Display duplicate record (merged)
Next Topic: virtual column 11g new feature
Goto Forum:
  


Current Time: Sun Dec 04 12:41:38 CST 2016

Total time taken to generate the page: 0.11534 seconds