• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 430
  • Last Modified:

decode function.

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
AmmarDJ
Asked:
AmmarDJ
  • 3
  • 2
  • 2
1 Solution
 
slightwv (䄆 Netminder) Commented:
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
 
AmmarDJAuthor Commented:
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
 
slightwv (䄆 Netminder) Commented:
>>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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
QlemoC++ DeveloperCommented:
That's impossible to say without seeing more of your code. Are those subqueries in the column list of an outer SELECT?
0
 
AmmarDJAuthor Commented:
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
 
slightwv (䄆 Netminder) Commented:
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
 
QlemoC++ DeveloperCommented:
Agree. You either have
    (select decode(...) from ...)
or just
    decode(...)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now