Help with arrays

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc

Poston Tue, 23 Aug 2005 6:35 pm

Good Evening Friends ...

How can I do to create an array that stores dates of birth from a select?

Type: select name, dtnascimento from employees want to do array that stores this information generated by the select.

Could someone help me.

Thank [/b]
Location: Itapetininga

Poston Wed, 24 Aug 2005 10:19 am

Good day, well ... hope this helps you ... here's a cursor that guard your data select and fetch you're extracting the data.

Code: Select all
  -- Cursor
  Cursor Cur_emp Is ( Select Empno
                           , Ename
                           , Hiredate
                        From Emp
  -- Variaveis
  V_cur   Cur_emp%Rowtype;
  V_texto Varchar2(400);
  Nro     Number;


  -- Abre o cursor
  Open Cur_emp;

  -- Verifica quantos registros tem e adiciona o maior na variavel
  Select Max(Rownum)
    Into Nro
    From Emp;

  -- comeca em 1 ate o ultimo registro da tabela
  For I In 1..Nro Loop

    -- Com o FETCH pega o registro: toda vez que faz o fetch pega o proximo registro
    Fetch Cur_emp Into V_cur;

    -- Adiciona os dados do registro na variavel para montar o texto
    V_texto := V_texto||Rpad(V_cur.Ename, 10, ' ')||' - '||To_char(V_cur.Hiredate, 'DD/MM/RR')||Chr(10);

  End Loop;

  -- Imprime o 'texto'

  -- fecha o cursor
  Close Cur_emp;
Any doubt, suggestion, criticism, correction ... Let me know:D

Vinicius Benetti
Location: Sapiranga - RS

Return to PL/SQL

Who is online

Users browsing this forum: No registered users and 10 guests