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

  • SEARCH
  • Home
  • 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 8436641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:14:07+00:00 2026-06-10T07:14:07+00:00

I have table which has two columns(CAGE,HCC) nulls allowed. I want to display duplicate

  • 0

I have table which has two columns(CAGE,HCC) nulls allowed. I want to display duplicate records in my procedure, i wrote like this.

 FOR REC IN (SELECT LOCATION, NIIN, INVL_DATE, CAGE, 
          HCC,SUM(CA_QTY) AS SUM_CA,SUM(COST_QTY) AS  SUM_COST,COUNT(*) FROM INVENTORY 
          GROUP BY LOCATION, NIIN, INVL_DATE,
          CAGE, HCC 
          HAVING COUNT(*)>1)
 LOOP  
  VAR_LOC_NAME    :=  REC.LOCATION;
  VAR_NIIN        :=  REC.NIIN;
  VAR_DATE        :=  REC.INVL_DATE;
  VAR_CAGE        :=  REC.CAGE; 
  VAR_HCC         :=  REC.HCC;
  VAR_CA_QTY      :=  REC.SUM_CA;
  VAR_COST_QTY    :=  REC.SUM_COST;

 FOR REC1 IN (SELECT SNO FROM INVENTORY WHERE LOCATION=VAR_LOC_NAME AND  
                NIIN=VAR_NIIN AND TUNC(INVL_DATE)=TRUNC(TO_DATE(VAR_DATE,'DD-MM-YY'))  AND
                CAGE=VAR_CAGE AND HCC=VAR_HCC)
    LOOP
        DBMS_OUTPUT.PUT_LINE('GET NUMBER '||REC1.SNO);
    END LOOP;
   end loop;

but for null values of CAGE and HCC it is not working.
FYI: I am using oracle 11g

  • 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-06-10T07:14:09+00:00Added an answer on June 10, 2026 at 7:14 am

    You need to find some value, that is not used in CAGE and HCC columns, and replace NULL values with this unique value using Oracle’s NVL function. So:

     FOR REC IN (SELECT LOCATION, NIIN, INVL_DATE, NVL(CAGE,-1) as CAGE, 
              NVL(HCC,-1) as HCC,SUM(CA_QTY) AS SUM_CA,SUM(COST_QTY) AS  SUM_COST,COUNT(*) FROM INVENTORY 
              GROUP BY LOCATION, NIIN, INVL_DATE,
              NVL(CAGE,-1), NVL(HCC,-1) 
              HAVING COUNT(*)>1)
    

    Of course -1 is just a sample here.

    As for the second loop:

    FOR REC1 IN (SELECT SNO FROM INVENTORY WHERE LOCATION=VAR_LOC_NAME AND  
                NIIN=VAR_NIIN AND TUNC(INVL_DATE)=TRUNC(TO_DATE(VAR_DATE,'DD-MM-YY'))  AND
                NVL(CAGE,-1)=VAR_CAGE AND NVL(HCC,-1)=VAR_HCC)
    

    On printout you can replace -1 back with NULL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table ProductNumberDuplicates_backups, which has two columns named ProductID and ProductNumber. There
I have a table companies , which has two columns named name and address
I have a table called Task which has, among others, two columns: Date_due: a
I have a table which has columns of data that contain status. Two example
I have a task_id table which has two columns: `tid`:task id, `state`:0:unfinished,1:processing,2:finished It's easy
Lets say I have two tables: table english which has two columns, id and
I have one procedure which retrieves all the records from one table which has
i have a table which has two columns i'd fill one of the columns
I have a table which has two columns FromDate and ToDate . Eg. ID
I have a table y Which has two columns a and b Entries are:

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.