Doubt T-SQL

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Fri, 20 Jul 2007 9:53 am

Can I post a question about T-SQL?

Is the following, I would like to put the amount of return lines from a query, e.g. select * from pfunc how do I get in this query is placed a counter lines?
rhicky
Location: S. J. do Rio Preto/SP

Poston Fri, 20 Jul 2007 10:49 am

Brother, would that be?

Example 1:
Code: Select all
DECLARE
  V_CONTADOR NUMBER(04) := 0;
BEGIN
  SELECT COUNT(1)
    INTO V_CONTADOR
    FROM EMP;

  dbms_output.put_line('Total de linhas: ' || V_CONTADOR);    
END;
Example 2:
Code: Select all
DECLARE
  CURSOR CUR_EMP
    IS
      SELECT *
        FROM EMP;
 
  V_CONTADOR NUMBER(04) := 0;
BEGIN
  FOR X IN CUR_EMP
  LOOP
     V_CONTADOR := V_CONTADOR + 1;
     dbms_output.put_line('Contador: ' || V_CONTADOR);
  END LOOP; 
END;       
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Fri, 24 Aug 2007 4:37 pm

What do you mean?
Only the count doesn't work?
select count(*) from pfunc Lucius Santos/SP
lucio.ss
Location: Santos/SP

Lúcio Suizu - Santos/SP

Poston Fri, 24 Aug 2007 5:33 pm

If you are running a SELECT, such as SQL, without problems.
In PL/SQL, you must assign this value to a variable, or a loop etc.
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP


  • See also
    Replies
    Views
    Last Post


    Return to SQL

    Who is online

    Users browsing this forum: No registered users and 1 guest