Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PL*SQL - Oracle 8i - Setting result of count(*) to a variable?

Posted on 2002-04-20
1
Medium Priority
?
900 Views
Last Modified: 2008-02-01
Hello.

Is there a way of setting the value of "select count(*)..." to a variable in PL*SQL?
0
Comment
Question by:Adam Leinss
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
pagerbak earned 200 total points
ID: 6956862
Hi

Here's a small procedure that show both "select into ..." and a cursor solution

CREATE OR REPLACE PROCEDURE test IS
cnt NUMBER;

CURSOR c IS
   SELECT COUNT(*) cnt
     FROM USER_TABLES;

BEGIN
   SELECT COUNT(*)
     INTO cnt
     FROM USER_TABLES;
   dbms_output.PUT_LINE('cnt=' || TO_CHAR(cnt));
   
   FOR ROW IN c LOOP
       cnt := ROW.cnt;
   END LOOP;  
   dbms_output.PUT_LINE('cnt=' || TO_CHAR(cnt));

END test;
/

regards pagerbak
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question