Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: INSERT command question
Jim Kennedy schrieb am 07.10.2005 in
<R_adnb__hP-GH9veRVn-sA_at_comcast.com>:
> "Tarby777" <nick_williamson_at_mentorg.com> wrote in message > news:1128692544.251221.221500_at_g44g2000cwa.googlegroups.com...
> INSERT INTO table_1 (col1,col2,uid_column) > (SELECT col1,col2, > 'UID' || SUBSTR(sysdual.guid,1,6) || '-' > SUBSTR(sysdual.guid,7,11) || '-' || SUBSTR(sysdual.guid,18) > from table_2, > (select SYS_GUID() as guid from dual) sysdual);
To avoid this I wrote a stored procedure that encapsuletes this. INSERT INTO table_1 (col1,col2,uid_column) (SELECT col1,col2,NewGUID() from table_2);
with
function NewGUID return varchar2 as
lvsGUID varchar2(40);
lvsResult varchar2(40);
begin
--{5A7A7F02-40BA-4503-99F2-092C2B35B039}
select
sys_guid
into
lvsGUID
from
dual;
lvsResult:=substr(lvsGUID,1,8)||'-'; lvsResult:=lvsResult||substr(lvsGUID,9,4)||'-'; lvsResult:=lvsResult||substr(lvsGUID,13,4)||'-'; lvsResult:=lvsResult||substr(lvsGUID,17,4)||'-'; lvsResult:=lvsResult||substr(lvsGUID,-12);return
> I think that would work. Try it on a small test case. Jims version should work, but if you have this situation in more than 1 cases you IMO should use a central function for it.
> Jim
Andreas
-- wenn email, dann AndreasMosmann <bei> web <punkt> deReceived on Fri Oct 07 2005 - 10:04:36 CDT
![]() |
![]() |