NULL question

NULL question

Post by Christophe » Wed, 17 Jan 2001 17:56:24



I create a table with the following structure :
sql > create table  gmember (mem_id NUMBER(38), mem_group_id NUMBER(38));
     > insert into gmember (1, NULL);
     > insert into gmember (2,1);
    >commit;

And then, I execute the following statment but get the ORA-01790 error.

sql > select A.mem_id , B.mem_id From gmember A, gmember B
    where A.mem_id =1 and B.mem_gid = A.mem_id
UNION
select A.mem_id , NULL From gmember A
    where A.mem_id =1 ;

select A.mem_id , B.mem_id From gmember A, gmember B
                            *
ERROR at line 1: ORA-01790: expression must have same datatype as
corresponding expression

--------

Any suggestion is appreciated. Thank you.

Chris

 
 
 

NULL question

Post by Lev Smirno » Wed, 17 Jan 2001 18:37:37




Quote:> I create a table with the following structure :
> sql > create table  gmember (mem_id NUMBER(38), mem_group_id NUMBER
(38));
>      > insert into gmember (1, NULL);
>      > insert into gmember (2,1);
>     >commit;

> And then, I execute the following statment but get the ORA-01790
error.

> sql > select A.mem_id , B.mem_id From gmember A, gmember B
>     where A.mem_id =1 and B.mem_gid = A.mem_id
> UNION
> select A.mem_id , NULL From gmember A
>     where A.mem_id =1 ;

> select A.mem_id , B.mem_id From gmember A, gmember B
>                             *
> ERROR at line 1: ORA-01790: expression must have same datatype as
> corresponding expression

> --------

> Any suggestion is appreciated. Thank you.

> Chris

You can use TO_NUMBER function:

select A.mem_id , B.mem_id
  from gmember A, gmember B
  where A.mem_id = 1 and B.mem_gid = A.mem_id
UNION
select A.mem_id , TO_NUMBER(NULL)
  from gmember A
  where A.mem_id = 1;

Lev Smirnov
Brainbench MVP for Oracle admin
http://www.brainbench.com

Sent via Deja.com
http://www.deja.com/

 
 
 

NULL question

Post by Christophe » Wed, 17 Jan 2001 19:11:43


The statement work for Oracle but not for other database servers (Microsoft,
Sybase). Any solution that can work for all datbase servers.

Thanks.




> > I create a table with the following structure :
> > sql > create table  gmember (mem_id NUMBER(38), mem_group_id NUMBER
> (38));
> >      > insert into gmember (1, NULL);
> >      > insert into gmember (2,1);
> >     >commit;

> > And then, I execute the following statment but get the ORA-01790
> error.

> > sql > select A.mem_id , B.mem_id From gmember A, gmember B
> >     where A.mem_id =1 and B.mem_gid = A.mem_id
> > UNION
> > select A.mem_id , NULL From gmember A
> >     where A.mem_id =1 ;

> > select A.mem_id , B.mem_id From gmember A, gmember B
> >                             *
> > ERROR at line 1: ORA-01790: expression must have same datatype as
> > corresponding expression

> > --------

> > Any suggestion is appreciated. Thank you.

> > Chris

> You can use TO_NUMBER function:

> select A.mem_id , B.mem_id
>   from gmember A, gmember B
>   where A.mem_id = 1 and B.mem_gid = A.mem_id
> UNION
> select A.mem_id , TO_NUMBER(NULL)
>   from gmember A
>   where A.mem_id = 1;

> Lev Smirnov
> Brainbench MVP for Oracle admin
> http://www.brainbench.com

> Sent via Deja.com
> http://www.deja.com/

 
 
 

NULL question

Post by Martin Haltmaye » Wed, 17 Jan 2001 20:18:12


Try

null + 0

instead.

Martin

 
 
 

1. newbie null question

Select budgetedamount,  sum(postedamount)as totalspent,
budgetedamount-sum(postedamount) as amountleft from budgets

this is part of my select statement.  I have two tables one table budgets
hold the dollar amount that has been budgeted.  and the orders table
contains the total amount of the posted orders (I know its is not best
practice to hold calculated totals but once an order is posted the total
never changes)

The problem I have is when no orders have been placed against a budget. when
I subtract sum(postedsamount) form the budgeted amount I get null.  I get
these since nothing has been posted and sum(postedamount) is null.  and I
know a calculation with null always returns null.  Is there a way I could
say if null use 0 for the calculation? Or what is the best way to handle

thanks
bert

2. Borland Announces Intersolv ODBC connection

3. Order by with nulls question

4. access table updated by Visual Basic passed on to visual Foxpro

5. NULL question

6. MVBASE and Delete-account Verb

7. Yet another NULL question.

8. Merge Replication Connection

9. basic NULLS question

10. NULL question...

11. NULL Question

12. DAO 3.51 to DAO 3.6 NULLs question

13. asp IF, THEN Null question