Solved

decode function.

Posted on 2013-01-28
7
421 Views
Last Modified: 2013-01-28
I know the decode function.

But i am using in a PL,sql query such that there are multiple statements in the script.


(select ... from..    )
(select.. from.. )

select decode (,,,,....)


from

x,
y,
z,
where

x.id =y.id
z.id =x.id

The script was running fine and perfect.
until i added the queries for decode.

The decode query works perfect when executed separately  but within the script, the result are some errors..

rest of line ingored.


Can anyone tell how to have this decode function inside the script in this case.

I absolutely know the syntax of decode and its running perfect when executed separately from the script.

regards
0
Comment
Question by:AmmarDJ
  • 3
  • 2
  • 2
7 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38828007
I assume the script is running sqlplus.

Is there a blank line in the script?

by default sqlplus doens't like blank lines.

If this isn't it, can you post the script?
0
 

Author Comment

by:AmmarDJ
ID: 38828044
I have removed the spaces.
it comes down to one error.


From keywork not found where expected.

How can i put the statements from decode together with all other statements,
and put the from x,y,z at the end.

Currently the script is  constructed such that all the statements are together with the from statement at the end.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38828060
>>From keywork not found where expected.

Looks like you are missing a paran or it is some other syntax issue.

>>How can i put the statements from decode together with all other statements,

I would have to get a better idea of what you are trying to do.  From the little snippets above, I don't understand what it is you are attempting to do.

Can you provide a little more information about what you did have and what changes you made?

A simple test case showing the before and after would help a lot.
0
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.

 
LVL 68

Expert Comment

by:Qlemo
ID: 38828062
That's impossible to say without seeing more of your code. Are those subqueries in the column list of an outer SELECT?
0
 

Author Comment

by:AmmarDJ
ID: 38828083
Please see to only the statements for decode.

The other statments are correct and I have tested it without decode.

Please also note that the tables from where these values for decode are retrieved are present after from keyword already and also with the right relationship after where keyword.
xyz.sql
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 38828112
You don't reissue the 'select' keyword inside the select.

try this:

...
elHT.Splais_Comment ||','||
    Decode(elHT.End_Seal_Flg, 1 ,'N', 2 ,'Y') ||','||
    Decode(elHT.N_Flg, 1 ,'N', 2 ,'Y')||','||
...
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 38828131
Agree. You either have
    (select decode(...) from ...)
or just
    decode(...)
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.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

708 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

18 Experts available now in Live!

Get 1:1 Help Now