Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL Variable Question

Re: PL/SQL Variable Question

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sun, 22 Nov 1998 17:42:03 GMT
Message-ID: <365d4cc6.16881404@192.86.155.100>


A copy of this was sent to shirushah_at_hotmail.com (if that email address didn't require changing) On Sun, 22 Nov 1998 02:35:02 GMT, you wrote:

>How do you assign, from the row of data that you have selected with a rowtype
>variable, just the data from one column into a variable? Here is an example
>
>SQL> variable li_deptname varchar2(20);
>SQL> declare
> li_dept dept%rowtype;
> begin
> select * into li_dept
> from dept
> where deptno = 40;
> end;
>
>In the dept table exsits a loc column, how do I get only data from that one
>column and assign it to the host variable li_deptname?
>

It could look like this:

SQL> variable li_deptname varchar2(20); SQL> declare
  2 li_dept dept%rowtype;
  3 begin
  4 select * into li_dept from dept where deptno = 40;   5 :li_deptname := li_dept.dname;
  6 end;
  7 /

PL/SQL procedure successfully completed.

SQL> print li_deptname

LI_DEPTNAME



OPERATIONS
>Thanks in advance
>
>SS
>&#137;
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Sun Nov 22 1998 - 11:42:03 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US