?
Solved

decode function.

Posted on 2013-01-28
7
Medium Priority
?
427 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 77

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 77

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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 70

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 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 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 70

Expert Comment

by:Qlemo
ID: 38828131
Agree. You either have
    (select decode(...) from ...)
or just
    decode(...)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
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
Suggested Courses

771 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