Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL Variable Question
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
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
--
http://govt.us.oracle.com/ -- downloadable utilities
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