Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: about the REPLACE function in PL/SQl:newbie here
There are two ways you can do it, and it appears you are trying to use both :-)
Once you have the value in the variable, you can simply reassign that variable the results of the REPLACE function. In other words:
v_name := replace(v_name,'I','*');
The other is to SELECT the modified value directly into the variable. Such as:
select replace(ename,'I','*')
into v_name
from ...
Lastly, to get both upper and lower case I's without effecting the case of the variable value, you will have to nest the REPLACE calls.
v_name := replace(replace(v_name,'I','*'),'i','*');
You could use UPPER or LOWER, but then the value assigned to v_name will be all upper- or lower-case.
HTH
<" srcnckpc"@hotmail.com> wrote in message
news:3AB7ED7E.6C4E31AD_at_hotmail.com...
> Hello:
>
> I am trying to create a PL/SQL block to select ename into a PL/SQL
> variable.
> In the PL/SQL variable I have to replace every I or i with a *.
>
> How can I do this?
>
> I know the syntax is: SELECT REPLACE ('YYY', 'YY', 'P') from table_name.
>
> But I don't know to code this in the BEGIN block, ie,
>
> DECLARE
> v_name emp.ename%TYPE;
> BEGIN
> SELECT ename
> FROM emp
> INTO v_name;
>
> SELECT REPLACE ??????
>
> END;
>
> Thanks so much for any clues.
>
>
Received on Wed Mar 21 2001 - 07:48:12 CST
![]() |
![]() |