Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: datatype
Hi Christopher,
what about changing the order of the two selects. AFAIK in the first select of an union alle columns must have defined types (i.e. not NULL) (and names?).
hth
Stephan
Christopher schrieb:
> I got "ORA-01790: expression must have same datatype as corresponding
> expression"
> when executing the following SQL statment :
>
> select A.gpm_ent_id_group A_id
> ,NULL B_id
> from GroupMember A
> where A.gpm_ent_id_member = 6
> UNION
> select A.gpm_ent_id_group A_id
> ,B.gpm_ent_id_group B_id
> from GroupMember A, GroupMember B
> where A.gpm_ent_id_member = 6
> and A.gpm_ent_id_group = B.gpm_ent_id_member ;
>
> p.s. Both gpm_ent_id_member and gpm_ent_id_group are NUMBER(38)
>
> So I modify the SQL to :
>
> select A.gpm_ent_id_group A_id
> ,to_number(NULL) B_id
> from GroupMember A
> where A.gpm_ent_id_member = 6
> UNION
> select A.gpm_ent_id_group A_id
> ,B.gpm_ent_id_group B_id
> from GroupMember A, GroupMember B
> where A.gpm_ent_id_member = 6
> and A.gpm_ent_id_group = B.gpm_ent_id_member ;
>
> However, it is not an ANSI SQL. Is there any ANSI solution for this
> situation?
>
> Thanks.
Received on Mon Jan 15 2001 - 03:40:17 CST
![]() |
![]() |