0

I have two table .one from server and another from host.I have to union them and count total donor by gender.I tried to run this function.But It shows error.How can I solve it?

**create or replace function count_donor_by_gender(g in Donor.gender%TYPE)
    return number
    is
    
    g_donor number:=0;
    
begin

    FOR R IN (select *  from Donor@site_link union Donor) LOOP
        if(R.gender=g) then
            g_donor:=g_donor+1;
        end if;
    END LOOP;
    
    return g_donor;

end count_donor_by_gender;
/**

Compilation Error

3
  • Hi. What does the error say? Commented Mar 19, 2021 at 6:30
  • Missing Select Keyword and sql statement ignored...I have added a pic Commented Mar 19, 2021 at 7:50
  • I have two table .one from server and another from host.I have to union them and count total donor by gender Commented Mar 19, 2021 at 7:52

1 Answer 1

1

The error is here

select *  from Donor@site_link union Donor

The "union" statement append results of 2 SELECT statements into one, so you need to

select *  from Donor@site_link union select * from Donor

Please be aware that "UNION" causes database to remove duplicates which may degrade the performance. If removing duplicates was not intented, use "UNION ALL" instead

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.