If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Loop in cursors and update some values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-04, 05:55
jdbf jdbf is offline
Registered User
 
Join Date: Jun 2002
Location: India
Posts: 40
Loop in cursors and update some values

Hello

i want to create one cursor with null values.
like
Cursor test is
Select a,b,c,d,e,f,g,h,i,j,k from dual

After this i want to pass values for a,b,c,d in that cursor
Once it is done, again i want to pass values for
a,b,e,f, after this once again
i want to pass values to a,b,g,h

Can i do that , if S please give me some code sample.

I have one SQL in which for now we are creating one
temp table and in each SQL we are inserting values into
required columns in that temp table

Finally we are taking values from temp , combining
with other main tables.

Now are forced to go for PL/SQL so ..let me know
what i can do for this

Is it possible to insert only some column values in
cursor...

Thanks
__________________
Suryadevara
Reply With Quote
  #2 (permalink)  
Old 05-21-04, 09:02
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
I don't understand what you are trying to do, really. You can't select a,b,c,... from dual because table dual doesn't possess such columns:

SQL> select a,b,c from dual;
select a,b,c from dual
*
ERROR at line 1:
ORA-00904: invalid column name

But let's suppose you are really selecting from another table:

SQL> create table t1 (a int, b int, c int);

Table created.

Now, you can set values in the cursor record like this:

Code:
declare
  cursor test is
    select a,b,c from t1;
begin
  for r in test loop
    r.b := 1;
    r.c := 2;
    update test set b = r.b, c=r.c
    where a = r.a;
  end loop;
end;
/
Is that what you meant?
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On