Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8608197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:32:46+00:00 2026-06-12T03:32:46+00:00

I have the following stored procedure: create or replace PROCEDURE A2CountSkus (v_count out Number

  • 0

I have the following stored procedure:

create or replace PROCEDURE A2CountSkus
(v_count out Number )
AS
 BEGIN 
   SELECT count(*)
      INTO v_count
      FROM a2sku;
   EXCEPTION 
 When Others THEN
    RAISE;
END A2CountSkus;

When I run this script.

SET SERVEROUTPUT ON 
BEGIN 
DBMS_OUTPUT.PUT_LINE('SKU COUNT ' || A2CountSkus); 
END; 
/ 

Instead of output being printed it gives an error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:32:47+00:00Added an answer on June 12, 2026 at 3:32 am

    First, normally, if you have a named PL/SQL block whose only purpose is to return a value, you would declare a function rather than a procedure. If you had declared A2CountSkus as a function that returned a number, the syntax that you want to use would work.

    Second, you do not want that exception clause– it does nothing useful. It should be eliminated.

    Third, if you do want the block to be a procedure, the caller would need to declare a local variable that can be passed in to the procedure and then print the value in the local variable.

    If you want to declare a function

    create or replace FUNCTION A2CountSkus
      return integer
    AS
      l_count integer;
    BEGIN 
      SELECT count(*)
        INTO l_count
        FROM a2sku;
      RETURN l_count;
    END A2CountSkus;
    

    If you are sure that you want to declare a procedure, the caller would need to be something like

    DECLARE
      l_count integer;
    BEGIN 
      A2CountSkus( l_count );
      DBMS_OUTPUT.PUT_LINE('SKU COUNT ' || l_count); 
    END; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Compare the following stored procedures: CREATE PROCEDURE testProc1 AS SELECT * INTO #temp FROM
I have following stored procedure: CREATE PROCEDURE testProc(IN p_idProject INTEGER) BEGIN DECLARE nowTime DATETIME;
I have the following SQL Server stored procedure : BEGIN TRAN CREATE TABLE #TempTable
I have the following Java stored procedure: CREATE OR REPLACE AND RESOLVE JAVA SOURCE
I have stored procedure: CREATE OR REPLACE udp_get_employeeaddress ( result_set out sys_refcursor ) AS
I have a following stored procedure CREATE PROCEDURE [dbo].[MyStored] @state int AS SELECT blahblahblah
I am using Oracle 10g and I have the following stored procedure: CREATE OR
I have the following stored procedure that I have to get data from: EXECUTE
i have a simple oracle stored procedure proc1 as follows: CREATE OR REPLACE PROCEDURE
I have a problem with the following stored procedure CREATE PROCEDURE LockRoots -- Add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.