Results 1 to 5 of 5

Thread: No data when query run using Excel from Oracle

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    4

    No data when query run using Excel from Oracle

    Hi,

    I would like to extract data from Oracle to Excel. I have created and tested the connection using ADO. When I run the query in Oracle SQL Developer client, it runs fine. However the same query run in Excel, does not provide any data. Here is the query:
    Code:
    select decode(b.location,'Bangkok','Thailand','Beijing','China','China WSBB','China','Colombo','Sri Lanka','Colombo','Sri Lanka', 'DBIA', 'Singapore','DSI Tokyo','Japan','Guangzhou','China','Ho Chi Minh','Vietnam','Hong Kong','HONGKONG', 'Hong Kong LON','HONGKONG','Jakarta','Indonesia','Karachi','Pakistan','Kuala 
    Lumpur','Malaysia','London','Malaysia', 'Manila','Philippines','Mumbai','India','Seoul','South Korea','Shanghai','China','Singapore','Singapore', 'Singapore local','Singapore','Sydney','ANZ','Sydney GMF','ANZ','Taipei','Taiwan','Tokyo 
    Consolidated','Japan', 'Tokyo Sales','Japan',b.location), count(t.systemid) 
    from rms_owner.trade t, book b
    where t.systemid > 209240000
    and t.systemid < 209250000
    and t.book in (
    select name from book where location in ('Bangkok','Beijing','China 
    WSBB','Colombo','Colombo','DBIA','DSI Tokyo','Guangzhou',
    'Ho Chi Minh','Hong Kong','Hong Kong LON','Jakarta','Karachi','Kuala 
    Lumpur','Manila','Mumbai','Seoul','Shanghai','Singapore',
    'Singapore local','Sydney','Sydney GMF','Taipei','Tokyo Consolidated','Tokyo Sales')
    AND status = 'Open' AND bookgroupYN = 'N'   
    )
    and t.lastupdated between '01-JUN-2009' and '30-JUN-2009'
    and t.datecreated between '01-JUN-2009' and '30-JUN-2009'
    and t.tradetable  not in ( 'FXCASHBALANCE','CASHBALANCE')
    and t.action !='Roll'
    and b.name = t.book
    group by b.location
    Why is there a problem?

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: No data when query run using Excel from Oracle

    Try giving your decoded field allias (perhaps location?):
    Code:
    SELECT
    	decode(b.location,
    		  'Bangkok','Thailand',
    		  'Beijing','China',
    		  'China WSBB','China',
    		  'Colombo','Sri Lanka',
    		  'Colombo','Sri Lanka', 
    		  'DBIA', 'Singapore',
    		  'DSI Tokyo','Japan',
    		  'Guangzhou','China',
    		  'Ho Chi Minh','Vietnam',
    		  'Hong Kong','HONGKONG', 
    		  'Hong Kong LON','HONGKONG',
    		  'Jakarta','Indonesia',
    		  'Karachi','Pakistan',
    		  'Kuala Lumpur','Malaysia',
    		  'London','Malaysia', 
    		  'Manila','Philippines',
    		  'Mumbai','India',
    		  'Seoul','South Korea',
    		  'Shanghai','China',
    		  'Singapore','Singapore', 
    		  'Singapore local','Singapore',
    		  'Sydney','ANZ',
    		  'Sydney GMF','ANZ',
    		  'Taipei','Taiwan',
    		  'Tokyo Consolidated','Japan', 
    		  'Tokyo Sales','Japan',
    		  b.location)    location, 
    	count(t.systemid) 
    FROM
    	rms_owner.trade t, book b
    where 
    	t.systemid > 209240000
    and t.systemid < 209250000
    and t.book in (select name 
    			   from book 
    			   where location in ('Bangkok','Beijing','China WSBB','Colombo','Colombo','DBIA','DSI Tokyo','Guangzhou',
    								  'Ho Chi Minh','Hong Kong','Hong Kong LON','Jakarta','Karachi','Kuala Lumpur',
    								  'Manila','Mumbai','Seoul','Shanghai','Singapore',
    								  'Singapore local','Sydney','Sydney GMF','Taipei','Tokyo Consolidated','Tokyo Sales')
    				AND status = 'Open' 
    				AND bookgroupYN = 'N'   
    				)
    and t.lastupdated between '01-JUN-2009' and '30-JUN-2009'
    and t.datecreated between '01-JUN-2009' and '30-JUN-2009'
    and t.tradetable  not in ( 'FXCASHBALANCE','CASHBALANCE')
    and t.action !='Roll'
    and b.name = t.book
    group by b.location
    Also, why not defining a Country directly in the database so you wouldn't have to decode that many values?

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    4

    Re: No data when query run using Excel from Oracle

    Hi,

    I tried using alias. It did not work. I dont think the problem is in decode. When I tried running the query using * instead of decode, it still did not work in excel.

    Regards.

  4. #4
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: No data when query run using Excel from Oracle

    Quote Originally Posted by aseem12321 View Post
    Hi,

    I tried using alias. It did not work. I dont think the problem is in decode. When I tried running the query using * instead of decode, it still did not work in excel.

    Regards.
    Are you able to fetch data from Oracle into your Excel spreadsheet?
    Did you try with any other table?

    Sometimes the issue lies elsewhere, like user permissions on the object, etc.
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    4

    Re: No data when query run using Excel from Oracle

    Hi, I found the error. I was just using column name to fetch data where as when I tried using table.column, it worked. Thanks guys.

    Cheers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width