Variable of type% ROWTYPE in a join of 2 or more tables

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 Fri, 18 Nov 2005 3:25 pm

Good afternoon guys, I wonder if someone could solve a problem.

For example, if I have a select that does a join on 3 tables, and I want to declare a variable of type% ROWTYPE to me to play the result of select. How can I do?!

With a table I know it's possible, but when you have more than 1 table?!
Location: São Paulo

Poston Fri, 18 Nov 2005 3:41 pm

See if this example doesn't help: about51.html I just created an equal using a JOIN in the cursor. Works beleza!

See my example:
Code: Select all

  --declara o cursor desejado
  CURSOR cur_emp
  select cim_processos.nro_proc,
  from cim_processos x,
       cim_faturas   y
where cim_processos.nro_proc               = y.proc_nro_proc
       and x.seq_proc                       = Y.proc_seq_proc
       and x.regs_codigo_regiao_do_sistema  = Y.pregs_codigo_regiao_do_sistema
       and x.regemgr_sigla_empresa_do_grupo = Y.regemgr_sigla_empresa_do_grupo
       and x.uneg_plta_sigla                = Y.proc_uneg_plta_sigla
       and x.uneg_negc_empg_sigla           = Y.proc_uneg_negc_empg_sigla
       and x.uneg_negc_sigla                = Y.proc_uneg_negc_sigla;

  --declara o array que conterá a linha toda
  rec_emp cur_emp%ROWTYPE;

  --Pega a linha desejada e grava no array
  OPEN cur_emp;
  FETCH cur_emp INTO rec_emp;
  CLOSE cur_emp;

Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?

Poston Fri, 18 Nov 2005 4:05 pm

Ah.. Sorry, I missed a detail!!

But what if this select were inside a dynamic sql? that is, if this sql was being assembled within an execute immediate.
Location: São Paulo

  • See also
    Last Post

    Return to PL/SQL

    Who is online

    Users browsing this forum: No registered users and 13 guests