Re: Update nth Byte of a varchar2 field

From: Tony <andrewst_at_onetel.net.uk>
Date: 20 Mar 2003 08:10:50 -0800
Message-ID: <c0e3f26e.0303200810.1d4cb864_at_posting.google.com>


Not perhaps the simple answer you were hoping for:

update table set vfield = substr(vfield,1,3)||'Y'||substr(vfield,5);

You could wrap that in a function if it's something you want to do often:

CREATE FUNCTION update_char( string in varchar2, pos in number, value in varchar2 ) RETURN varchar2
IS
  RETURN substr(string,1,pos-1)||value||substr(string,pos+1); END;
/

update table set vfield = update_char( vfield, 4, 'Y' );

"Peter Kowalski" <PKowalski2_at_gmx.de> wrote in message news:<1048148218.963197_at_news.thyssen.com>...
> Hallo,
> I want to update the 4th char in a varchar2 Field :
>
> vfield : varchar2(32);
>
> update table set vfield[4] = 'Y';
> ---------------------^ ORA-00927: = expected
>
> How can I do this ?
>
> Thanks
Received on Thu Mar 20 2003 - 17:10:50 CET

Original text of this message