Solved

decode function.

Posted on 2013-01-28
7
422 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
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…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

929 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

9 Experts available now in Live!

Get 1:1 Help Now