Oracle SQL question

5 pts.
Tags:
CASE statement
IF THEN statement
IIF statement
Oracle developers
Oracle development
Oracle SQL
SQL
I want to create a SQL script in Oracle that will run one of two possible SQL scripts based on what the user enters in the Parameter request. Since I'm unable to use IIF and If Then like I can in SQL Server, is there another way to do this? I have tried using case statements but Oracle doesn't like it. One example I tried is: case when x then '' else select * from db end Let me know if that isn't enough information!!! Thanks!!

Answer Wiki

Thanks. We'll let you know when a new response is added.

Oracle does indeed have if-then-else constructs as well as many other programmatic functions available in PL/SQL. I suggest you get some documentation so that you can learn allthe available options you have as well as correct syntax, etc.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Kccrosser
    First principle: Anything that you can do in SQL Server can be done in Oracle. If you think you found a SQL Server function that isn't in Oracle, you just haven't yet found the corresponding Oracle function. Note: The reverse is definitely NOT true - there are lots of things available in Oracle that are NOT available in SQL Server. One powerful Oracle function is the "DECODE" expression, which is: DECODE(<argument>, <case_value_1>, <result_1> [, <case_value_2>, <result_2> ...], <default_result>) You can have many value/result pairs, so it is essentially a shorthand Case expression for: Case When <argument> = <case_value_1> Then <result_1> When <argument> = <case_value_2> Then <result_2> ... Else <default_result> End; Which can be used like: sSQL varchar(255); sSQL := DECODE(myParameter, 'Do This', 'script_name_1', 'Do That', 'script_name_2', 'bad_input_script'); execute immediate sSQL; Oracle also has Case statements, If ... then ... else, and pretty much anything else you can think of.
    3,830 pointsBadges:
    report
  • carlosdl
    Did you get this working ? If not, please provide more details. As Kccrosser and Jcmdba said, you can do many things with Oracle and there is for sure a way to do what you need.
    69,065 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following