Re: Count(*) and Variables in SQL*Plus
Date: Fri, 15 May 1998 00:41:06 GMT
Message-ID: <35638ef0.38824827_at_192.86.155.100>
A copy of this was sent to haakefan_at_aol.com (HaakeFan) (if that email address didn't require changing) On 15 May 1998 00:14:00 GMT, you wrote:
>This seems so simple, but I'm stumped.
>
>In SQL*Plus, I'm trying to do a record count, and then storing that count to a
>defined variable. Is that possible? Can I do something that looks like:
>
>DEFINE variable_name = (SELECT COUNT(*) FROM table_name)
>
>Can the variable be defined as a particular number of digits?
>
>Obviously, I'm missing something here. Any help would be greatly appreciated.
>
>Jeff Axelson
>Oracle Newbie
It'll look like this:
SQL> column the_cnt new_val My_Var
SQL> select count(*) the_cnt from dual;
THE_CNT
1
SQL> prompt and the count is &My_Var
and the count is 1
SQL>
So, alias the count(*) in the query, use the column command prior to running
that query to tell sql plus to stuff the results of that column into that macro
variable...
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
http://govt.us.oracle.com/ -- downloadable utilities
Opinions are mine and do not necessarily reflect those of Oracle Corporation
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Fri May 15 1998 - 02:41:06 CEST