Solved

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

Posted on 2002-04-20
1
891 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
1 Comment
 
LVL 1

Accepted Solution

by:
pagerbak earned 50 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now