Save record in a 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
Post Reply
User avatar
tfg
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 83
Joined: Mon, 03 May 2004 3:38 pm
Location: Novo Hamburgo - RS

How do I recover an entire record and save in a variable?
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

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

This code is a very good practice.

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; 

Select all

SQL> set serveroutput on 
SQL> @t 
SCOTT 
 
PL/SQL procedure successfully completed. 
 
SQL> 
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest