Solved

decode function.

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

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 69

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.

Question has a verified solution.

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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

831 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