Skip to content
Advertisement

PL/SQL Block Finding number of suppliers for each nation

I’m still new to PLSQL and am currently using TPCH Dataset to practice. I have been trying this for a while not but I can’t seem to wrap my head around it and could use some advice. A rough overview of the dataset here.

Here is my code so far

However, when I tried just the select query, I got an error

If I remove the INTO countNationkey, I’m aware that countNationkey has no value thus I will get the output shown below.

This is the expected outcome that I want

Could really use some help! Thanks in advance!

Advertisement

Answer

Just remove INTO. It is required in PL/SQL, but not when select is part of a cursor (in your case, that’s a cursor FOR loop).

Also, you’d then reference countNationkey with cursor variable’s name (QROW.countNationkey), which also means that you don’t need a local variable.

So:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement