Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6331391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:03:22+00:00 2026-05-24T18:03:22+00:00

I encountered the following PL/SQL code(variables modified) at work: PROCEDURE test(i_w IN a.w%type,o_result IN

  • 0

I encountered the following PL/SQL code(variables modified) at work:

PROCEDURE test(i_w IN a.w%type,o_result IN OUT resu_cur_type) IS
BEGIN
    IF i_w IS NULL THEN
      open o_result for SELECT a.x, b.y FROM a,b WHERE a.z=b.z;
    ELSE
      open o_result for SELECT a.x, b.y FROM a,b WHERE a.z=b.z AND a.w=i_w;
    END IF;
END test;

I think the above is equivalent to the following:

PROCEDURE test(i_w IN a.w%type,o_result IN OUT resu_cur_type) IS
BEGIN
      open o_result for SELECT a.x, b.y FROM a,b WHERE a.z=b.z AND NVL(a.w,1)=NVL(NVL(i_w,a.w),1);
END test;

Won’t it be the same?. Could somebody please explain is there any reason to use the
original version?.
Please note that the original cursor is a 50 line query, so refactoring might improve its readability and keep it simple.

Edit:

To address the problem in Kevin Burton’s answer, I’ve updated the WHERE condition.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:03:22+00:00Added an answer on May 24, 2026 at 6:03 pm

    if a.w is null you will not select the records

    as

    a.w=NVL(i_w,a.w); 
    

    will be

    a.w=NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am debugging some code and have encountered the following SQL query (simplified version):
I encountered the following ddl in a pl/sql script this morning: create index genuser.idx$$_0bdd0011
ISQL-SE 4.10.DD6 (DOS 6.22): My app has the following SQL script (CODE REVIEW) which
I encountered the following code in a file (looks like header file) iomanip of
Possible Duplicate: How does SQL server work out the estimated number of rows? I
Has anyone encountered the following problem: I have IIS7 running on my computer. On
We've encountered the following issue. I like to use the following writing: SELECT Id,
I encountered a problem when running some old code that was handed down to
I am trying to run the following code within SQLPlus: exec lbacsys.sa_sysdba.create_policy(policy_name => 'ACCESS_LOCATIONS',
Greetings to all! I want to create a pl/sql query by declaring variables for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.