Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2002
    Posts
    3

    Unanswered: Select count into variable

    how can you get the number of rows in a table into a variable? This is on Oracle 9i if it matters. Thanks.

    skippy

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Here are 2 ways in SQL Plus:

    Method 1:

    VARIABLE v NUMBER

    COLUMN c NEW_VALUE v

    SELECT COUNT(*) c FROM mytable;

    Method 2:

    VARIABLE v NUMBER

    EXEC SELECT COUNT(*) INTO :v FROM mytable;

  3. #3
    Join Date
    Apr 2002
    Location
    California, USA
    Posts
    482

    Cool

    declare
    variable number;
    begin
    select count(*) into variable from table;
    end;


    Hope that helps,

    clio_usa
    OCP - DBA

    .
    .
    .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •