Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Assign the variable from a cursor for loops into second cursor for loop

Carl CNov 7 2018 — edited Nov 7 2018

Hi Guys,

I hope you can help me with this question.

I've a procedure which purpose is to update the content of a set of columns from few tables where data format was wrongly inserted.

So, 3 tables and each table 10 columns where I need to replace double quotes by nothing, just to give you an idea.

I've create a procedure kind off

Create procedure  name ...

Declare

     var x

     var z

     etc ..

Begin

     for rec1 in --- > My 1st cursor

               ( select

                    table_name

               from

                    all_tables

               where

                    table_name in (tab1, tab2, tab3)

                )

          loop;  ----> my firs loop will gives me the values for rec.table_name

             

                    for rec2 in

                              (select

                                       column_name

                                 from

                                        all_tab_columns

                                where

                                        table_name = rec1.table_name  ---->  My first Question : Can I do this?

                                        and column_name like '%ABC%'

                                )

                               loop; --- Second loop

                                      --- here I need to execute a statement  .... kind of

                                     stmt := 'update/ Insert/delete'  '|| rec1.table_name||' '|| "rec2.column_name|| ....  ---->>> Second Question ? How

                                      dbms_output.put_line

                                end loop; -- end loop 2

              end loop;  --- end loop 1

end;

My question?

How do I assign the result from first cursor inside second cursor ina second loop?

Thank you if you can help

This post has been answered by mathguy on Nov 7 2018
Jump to Answer
Comments
Post Details
Added on Nov 7 2018
13 comments
2,522 views