Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

equivale PL/SQL for simple expression 1

Status
Not open for further replies.

masiwan

Vendor
Feb 20, 2006
37
UG
In an SQL Transact SQL, one can write the following line:

select @cnt = Count(*) from employee

so that variable @cnt can be used to store the total number of records from the Employee table, and use it else where in your procedure;

I have tried;

cnt = Count(*) from Employee

in PL/SQL and I'm getting an error along this line, and PL/SQL does not seem to understand the COUNT(*) function whatcan I do ?
 
Masiwan,

Here is a sample proof-of-concept for what you want:
Code:
set serveroutput on format wrap
declare
    cnt number;
begin
    select count(*) into cnt from s_emp;
    dbms_output.put_line('S_EMP contains '||cnt||' rows.');
end;
/

S_EMP contains 25 rows.

PL/SQL procedure successfully completed.
Let us know if you have additional questions.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I can provide you with low-cost, remote Database Administration services: see our website and contact me via www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top