Solved

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

Posted on 2002-04-20
1
892 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

911 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

22 Experts available now in Live!

Get 1:1 Help Now