Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Query problem...

Re: Query problem...

From: Gaetan Poitras <poitrasg_at_crcsogema.com>
Date: 21 Mar 2002 09:34:52 -0800
Message-ID: <3ebc2be2.0203210934.5b5f4c95@posting.google.com>


I think you want to concatenate then use || instead of +

salil_khedkar_at_yahoo.com (Neo) wrote in message news:<a6c24f5.0203210319.e7c0c68_at_posting.google.com>...
> Hi Folks,
>
> I am working on a application designed for Microsoft SQL server which
> I am am now porting to Oracle.
>
> I want to get a ':' separated list of IDs from a table. So on MSSQL a
> query like works fine...
> SELECT RTRIM(CAST(FIELD1 AS char(30))) + ':' + RTRIM(CAST(FIELD2 AS
> char(30))) as LIST from TABLE1
> and return the following as result for example.
> 123:1234
> :123 (if first value is null)
> 123: (if first value is null)
> : (if first value is null)
>
> But on oracle if I do the same query
> SELECT RTRIM(CAST(FIELD1 AS char(30))) + ':' + RTRIM(CAST(FIELD2 AS
> char(30))) as "LIST" from TABLE1
> (1) It says I cant add mixed types like this
> (2) If I remove the + ':' + part, it gives me numeric addition of the
> two fields instead of string concatenation.
> (3) Finally, if any of the field is null, it does not return any value
> at all
>
> What is the correct query for oracle in this case?
>
> Regards,
> Neo
Received on Thu Mar 21 2002 - 11:34:52 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US