Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

710 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