Solved

invalid number in a select statement

Posted on 2008-09-30
4
813 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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now