Solved

invalid number in a select statement

Posted on 2008-09-30
4
814 Views
Last Modified: 2012-05-05
The following query is okay.  
    SELECT code_desc  FROM  dm_codes WHERE   code in   ( SELECT   emp_no FROM emp ) ;

But, the following query result in invalid number.  Why?  Thanks.
            select ( SELECT code_desc   FROM  dm_codes    WHERE  code  = emp_no )  
                             from     ( SELECT   emp_no FROM emp  ) ;


                           
0
Comment
Question by:ewang1205
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
paquicuba earned 250 total points
ID: 22607274
It looks like you have a column named EMP_NO in dm_codes as well that is a VARCHAR2 datatype, so need to qualify your subselect in order for it to work:

select ( SELECT code_desc   FROM  dm_codes    WHERE  code  = x.emp_no )  
                             from     ( SELECT   emp_no FROM emp  )  x;
 
0
 

Author Comment

by:ewang1205
ID: 22607871
Tried.  That is not where the problem is.  
0
 
LVL 20

Assisted Solution

by:gatorvip
gatorvip earned 250 total points
ID: 22608993
What is the error that you are getting?
0
 

Author Comment

by:ewang1205
ID: 22609029
The following is working.  I will split the points between you two.  Thanks.
 
select ( SELECT code_desc   FROM  dm_codes    WHERE  code  =  to_char(emp_no  ) )  
                             from     ( SELECT   emp_no FROM emp  ) ;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to recover a database from a user managed backup

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question