Re: PL/SQL Question: How to Assign a CHAR variable to a NVARCHAR2 variable

From: Ranga Chakravarthi <ranga_at_removethis.cfl.rr.com>
Date: Sat, 09 Nov 2002 20:21:03 GMT
Message-ID: <P6ez9.105115$fa.1818610_at_twister.tampabay.rr.com>


Try this:
  sDate := TRANSLATE(TO_CHAR(TRUNC(SYSDATE), 'YYYY-MM-DD') USING NCHAR_CS);

"news" <jbfidelia_at_multicorpora.ca> wrote in message news:8fxy9.332$CP2.59461_at_wagner.videotron.net...
> Hi there,
>
> I'm new to PL/SQL (Oracle 8i) and I need to convert a DATE variable to
 Text
> into a NVARCHAR2.
> I tried to write the following code function:
>
> RETURN NVARCHAR2
> AS
> sDate NVARCHAR2(10);
> BEGIN
> sDate := TO_CHAR(TRUNC(SYSDATE), 'YYYY-MM-DD');
>
> RETURN sDate;
> END;
>
> I recieved the following error when I compile:
>
> PLS-00560: character set mismatch.
>
>
> The NLS_LANG variable from the registry is AMERICAN_AMERICA.WE8ISO8859P1.
>
> Is there another function in Oracle 8i to return the date as a NVARCHAR2
 or
> is there a way to convert a CHAR to a NVARCHAR2. If not how can I convert
> from one character set to another (CAST and CONVERT doesn't seem to work).
>
> PS: Its mandatory that the date is returned as a NVARCHAR2 in 'YYYY-MM-DD'
> format.
>
> Thanks you for your help.
>
> J.B. Fidelia
>
>
>
Received on Sat Nov 09 2002 - 21:21:03 CET

Original text of this message