From: carnwath@synygy.com (SteveC)
Newsgroups: comp.databases.oracle
Subject: Re: A PL\SQL Questions
Date: 8 Aug 2001 07:29:51 -0700
Organization: http://groups.google.com/
Lines: 149
Message-ID: <cea788de.0108080629.3b4fe916@posting.google.com>
References: <3271719f.0108031221.77749dec@posting.google.com> <DNyb7.164$PE5.41026@typhoon.jacksonville.mediaone.net> <32d39fb1.0108061313.2ab5be96@posting.google.com>
NNTP-Posting-Host: 207.106.136.2
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 997280991 24342 127.0.0.1 (8 Aug 2001 14:29:51 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 8 Aug 2001 14:29:51 GMT


seems a bit more complex than need be (by using a cursor)...
try

declare
 custct number(10,0);
begin
  Select count(*) into custct from customer_accounts;
  dbms_output.put_line('The number of cusomter accounts is: ' || custct);
end;

simple is good :)


oratune@msn.com (David Fitzjarrell) wrote in message news:<32d39fb1.0108061313.2ab5be96@posting.google.com>...
> Let's make that:
> 
> dbms_output.put() and dbms_output.put_line()
> 
> The first will output text without a newline character, allowing you
> to build output text of variable length (within the confines of the
> package limitations) whereas the second outputs text WITH a newline.
> 
> Examples:
> 
> rem
> rem DBMS_OUTPUT.PUT_LINE example
> rem
> 
> rem
> rem Enable output
> rem
> 
> set serveroutput on size 1000000
> 
> declare
>      --
>      -- Declare cursor to return count of
>      -- valid customer accounts
>      --
>      cursor custaccts is
>      select count(*)
>      from customer_accounts;
> 
>      --
>      -- Variable to 'hold' returned count
>      --
>      custct   number:=0;
> begin
>      --
>      -- Open the cursor
>      --
>      open cursor custaccts;
>      --
>      -- Fetch the value into the declared variable
>      --
>      fetch custaccts into custct;
>      --
>      -- Close the cursor
>      --
>      close custaccts;
> 
>      --
>      -- Output the results to the terminal
>      --
>      dbms_output.put_line('The number of customer accounts is:
> '||custct);
> end;
> /
> 
> 
> rem
> rem DBMS_OUTPUT.PUT example
> rem
> 
> rem
> rem Enable output
> rem
> 
> set serveroutput on size 1000000
> 
> declare
>      --
>      -- Declare cursor to return count of
>      -- valid customer accounts
>      --
>      cursor custaccts is
>      select count(*)
>      from customer_accounts;
> 
>      --
>      -- Variable to 'hold' returned count
>      --
>      custct   number:=0;
> 
>      --
>      -- Variable to 'hold' current date/time
>      --
>      currdt   date;
> begin
>      --
>      -- Open the cursor
>      --
>      open cursor custaccts;
>      --
>      -- Fetch the value into the declared variable
>      --
>      fetch custaccts into custct;
>      --
>      -- Close the cursor
>      --
>      close custaccts;
> 
>      --
>      -- Get current date
>      --
>      select sysdate into currdt from dual;
> 
>      --
>      -- Output the results to the terminal
>      --
>      dbms_output.put('The number of customer accounts is: '||custct);
>      dbms_output.put_line(' for period ending: '||currdt);
> end;
> /
> 
> 
> David Fitzjarrell
> 
> 
> "Steve Long" <slong3@mediaone.net> wrote in message news:<DNyb7.164$PE5.41026@typhoon.jacksonville.mediaone.net>...
> > look up dbms.output and dbmsw.putline
> > 
> > "Frank" <fcolon@onebox.com> wrote in message
> > news:3271719f.0108031221.77749dec@posting.google.com...
> > > Quick question....is there a way to get a PL\SQL query to print some text?
> > >
> > > For example, if I had the query:
> > >
> > > Select count(*) from customer_accounts; (will return a count of 10)
> > >
> > > How can I change that query so that the following prints out:
> > >
> > > The number of cusomter accounts is: 10
> > >
> > > Thanks.
> > >
> > > --Frank
> > >
> > > P.S. Do you know of any good PL\SQL resources on the net?

