Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: UPDATE the column (Parametrization)
> SQL> Create table Parameters(Parameter_ID number,Description
> varchar2(50), Source_Parameter varchar2(400),Target_Parameter
> varchar2(400));
>
> Insert Statement:
>
> SQL> 'insert into parameters(Parameter_ID,Description,Source_Parameter,
> Target_Parameter)
> select 19,''DataFile Paths'',file_name,null from dba_data_
>
> Update Code:
>
> accept trg_prm1 prompt 'Enter the name of DataFile of the Source
> Parameter Column: '
> accept trg_prm2 prompt 'Enter the name of DataFile for the Target
> Parameter Column: '
> declare
> b varchar2(20);
> begin
> select count(*) into b from parameters where description='DataFile Paths';
> For i in 1..b
> loop
> update parameters set TARGET_PARAMETER = '&&trg_prm2'
> where Source_Parameter = '&&trg_prm1';
> end loop;
> end;
> /
> The above code works, but I run it every time in order to update the
> target_parameter column with datafiles.
> Is there a way or what changes I should do in the update code that at
> a single time I updated all the datafiles in the
> target_parameter”>
> Any suggestion will be appreciated.
Yikes! What a weird code!
Why not simple
UPDATE parameters
SET target_parameter = '&&trg_prm2'
WHERE Source_Parameter = '&&trg_prm1'
AND description='DataFile Paths';
You used syntax that shouldn't work.
You declared a variable as varchar2 and put into it count(*) result.
Then used it in loop.
It shouldn't work.
-- NoelReceived on Wed Feb 04 2004 - 03:01:20 CST
![]() |
![]() |