You are here:

Oracle/putting pl/sql snippets in select statement

Advertisement


Question
Hi,

I wish to know that how can we insert pl sql snippets into select statement.
as example,
is it possible to obtain information in a way like shown below( i know its incorrect, but does there exist a correct version to do things like the way shown below in a correct way)

select a, begin if b>2 then '2' endif end as Result from sometable;

in sql statements?

Answer
Hi Devanshu,

You cannot write pl/sql blocks in select statement. If you want some if-then-end if condition, then you can use 'case' function, or if you need to use pl/sql you will have to create a function which can then be used in select statement.

Hope this helps.

Regards

Suchitra

Oracle

All Answers


Answers by Expert:


Ask Experts

Volunteer


Suchitra Joshi

Expertise

I can answer questions regarding SQL, PL/SQL, Procedures, Functions, Triggers, SQL Loader, Oracle Forms, Oracle Reports, and some basic dba and performance tuning activities.

Experience

15+ years of Oracle PL/SQL Development

Education/Credentials
B.Sc (Electronics), Diploma in Computer Applications (DCA)

Awards and Honors
Oracle PL/SQL Developer Certified Associate (OCA)
Oracle Database: SQL Certified Expert
Brainbench certifications in Oracle Administration, PL/SQL, Developer 2000

©2016 About.com. All rights reserved.