Keep a record variable

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 Wed, 02 Jun 2004 12:48 pm

How do you retrieve an entire record and save in a variable?
tfg
Location: Novo Hamburgo - RS

Poston Wed, 02 Jun 2004 12:49 pm

This code is a very good practice.

Code: Select all
DECLARE

  --declara o cursor desejado
  CURSOR cur_emp ( p_empno EMP.EMPNO%TYPE )
  IS
  SELECT * FROM EMP WHERE EMPNO=p_empno;

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

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

  DBMS_OUTPUT.PUT_LINE( rec_emp.ENAME );
END;


Code: Select all
SQL> set serveroutput on
SQL> @t
SCOTT

PL/SQL procedure successfully completed.

SQL>
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered



Return to PL/SQL

Who is online

Users browsing this forum: Google [Bot] and 9 guests