How can I iterate over the columns of a REF CURSOR?

I have the following situation:
DECLARE
   text   VARCHAR2 (100) := '';
   
   TYPE gen_cursor is ref cursor;
   c_gen gen_cursor;

   CURSOR c_tmp
   IS
        SELECT   *
          FROM   CROSS_TBL
      ORDER BY   sn;
BEGIN
   FOR tmp IN c_tmp
   LOOP
      text := 'select * from ' || tmp.table_name || ' where seqnum = ' || tmp.sn;

      OPEN c_gen FOR text;

      -- here I want to iterate over the columns of c_gen
      -- c_gen will have different number of columns every time,
      --        because we select from a different table
      -- I have more than 500 tables, so I cannot define strong REF CURSOR types!

      -- I need something like
      l := c_gen.columns.length;
      for c in c_gen.columns[1]..c_gen.columns[l]
      LOOP
          -- do something with the column value
      END LOOP;
   END LOOP;
END;
As you can see from the comments in the code, I couln would find examples on the internet with a REF CURSOR low and selecting from multiple tables.
What I found was:
CREATE PACKAGE admin_data AS
   TYPE gencurtyp IS REF CURSOR;
   PROCEDURE open_cv (generic_cv IN OUT gencurtyp, choice INT);
END admin_data;
/
CREATE PACKAGE BODY admin_data AS
   PROCEDURE open_cv (generic_cv IN OUT gencurtyp, choice INT) IS
   BEGIN
      IF choice = 1 THEN
         OPEN generic_cv FOR SELECT * FROM employees;
      ELSIF choice = 2 THEN
         OPEN generic_cv FOR SELECT * FROM departments;
      ELSIF choice = 3 THEN
         OPEN generic_cv FOR SELECT * FROM jobs;
      END IF;
   END;
END admin_data;
/
But they have only 3 tables here and I have like 500. What can I do here?

Thanks in advance for any help!

Hope it will help > [Ref Cursor dynamic dynamic Fetch | http://www.oracle.com/technology/oramag/code/tips2003/042003.html]

See you soon,.
AA

Tags: Database

Similar Questions

  • How a TableView can iterate over the lines and get the cells?

    I need to iterate over all rows in a TableView without using events. I would like to get the total number of lines, TableRow and a cell of a TableColumn specified in the TableRow.

    Something like this:
    for(TableRow tableRow: tableView.getRows()){
        Cell cell = tableRow.getColumn(4).getCell();
        // do something to the cell 
    }
    Is this possible?

    Published by: Conzar on May 19, 2013 23:18

    However, the problem with the checkbox has been resolved so I don't need to iterate over the lines longer.

    Yes, don't use do not research to manage this is a much better solution, I just gave my search for a solution based on because you asked an iterative solution.

    Below (research) code produces no output.

    It works for me, I've included an example of executable, so you can try it.

    My guess is that you are not taking into account the fact that the research is just a glimpse of the cells of the table at a time in time.
    If you do a search for cell before show you the table on a stage, he's not coming back what it is because the cells are generated only on an as needed basis, and there is no need to generate all the cells before displaying the table on a stage.

    I get the following output on Win7 Java8b89:

    NumberedTableViewSample$2$1@344fe46[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@44187690[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@34618adc[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@61eb7609[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@50b006a1[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@307d4153[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@89b7483[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@70ce61fd[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@178969ad[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@e3149ea[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@3683d879[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@589e421f[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@7e26215b[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@69d59720[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@1ad26ff1[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@32b058e4[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@582e254[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@261c4ebd[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@2cb9cfb[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@63c6fe00[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@16a98443[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@58247401[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@34dc3da4[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@78a62ea[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@29e0032e[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@1781c971[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@18b2e479[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@4801295b[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@19e4c622[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@6a766d41[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@572aed5d[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@3bdf71a4[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@524c48c7[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@47b5a3ea[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@6ef8b38b[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@7fd2ee72[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@4994195c[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@49620450[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@246d8751[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@17e90472[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@def00[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@d1aa50a[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@2a7a58ba[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@2675cbd1[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@1c06ee08[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@1685718d[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@6ba1936c[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@61ef15e5[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@6b2ace30[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@3c4d17c7[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@1c3c9aad[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@27eadfe[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@3f83a064[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@579615f1[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@52a9271b[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@1d221557[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@18947d9e[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@537eab32[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@687cc257[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@3d524978[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@44554375[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@22f89594[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@1f891aaf[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@bafcb2f[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@7ddeea8c[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@26023325[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@4b14700f[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@89eb58[styleClass=cell indexed-cell table-cell table-column]
    NumberedTableViewSample$2$1@6a55a4a6[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@7d95454d[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@375592eb[styleClass=cell indexed-cell table-cell table-column]
    TableColumn$1$1@7add3f35[styleClass=cell indexed-cell table-cell table-column]
    

    TestApp:

    import javafx.application.Application;
    import javafx.beans.property.ReadOnlyObjectWrapper;
    import javafx.beans.property.SimpleStringProperty;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.geometry.Insets;
    import javafx.scene.Group;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.control.TableCell;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableColumn.CellDataFeatures;
    import javafx.scene.control.TableView;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.layout.VBox;
    import javafx.scene.text.Font;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    
    public class NumberedTableViewSample extends Application {
    
        private TableView table = new TableView<>();
        private final ObservableList data =
            FXCollections.observableArrayList(
                new Person("Jacob", "Smith", "[email protected]"),
                new Person("Isabella", "Johnson", "[email protected]"),
                new Person("Ethan", "Williams", "[email protected]"),
                new Person("Emma", "Jones", "[email protected]"),
                new Person("Michael", "Brown", "[email protected]")
            );
    
        public static void main(String[] args) {
            launch(args);
        }
    
        @Override
        public void start(Stage stage) {
            Scene scene = new Scene(new Group());
            stage.setTitle("Table View Sample");
            stage.setWidth(470);
            stage.setHeight(500);
    
            final Label label = new Label("Address Book");
            label.setFont(new Font("Arial", 20));
    
            table.setEditable(true);
    
            TableColumn numberCol = new TableColumn("#");
            numberCol.setMinWidth(20);
            numberCol.setCellValueFactory(new Callback, ObservableValue>() {
              @Override public ObservableValue call(CellDataFeatures p) {
                return new ReadOnlyObjectWrapper(p.getValue());
              }
            });
    
            numberCol.setCellFactory(new Callback, TableCell>() {
              @Override public TableCell call(TableColumn param) {
                return new TableCell() {
                    @Override protected void updateItem(Person item, boolean empty) {
                        super.updateItem(item, empty);
    
                        if (this.getTableRow() != null && item != null) {
                          setText(this.getTableRow().getIndex()+"");
                        } else {
                          setText(null);
                        }
                    }
                };
              }
            });
            numberCol.setSortable(false);
    
            TableColumn firstNameCol = new TableColumn("First Name");
            firstNameCol.setMinWidth(100);
            firstNameCol.setCellValueFactory(
                    new PropertyValueFactory("firstName"));
    
            TableColumn lastNameCol = new TableColumn("Last Name");
            lastNameCol.setMinWidth(100);
            lastNameCol.setCellValueFactory(
                    new PropertyValueFactory("lastName"));
    
            TableColumn emailCol = new TableColumn("Email");
            emailCol.setMinWidth(200);
            emailCol.setCellValueFactory(
                    new PropertyValueFactory("email"));
    
            table.setItems(data);
            table.getColumns().addAll(numberCol, firstNameCol, lastNameCol, emailCol);
    
            final VBox vbox = new VBox();
            vbox.setSpacing(5);
            vbox.setPadding(new Insets(10, 0, 0, 10));
            vbox.getChildren().addAll(label, table);
    
            // this lookup set won't print anything as no cells have been generated.
            for (Node r: table.lookupAll(".table-row-cell")){
                for (Node c: r.lookupAll(".table-cell")){
                    System.out.println(c);
                }
            }
    
            ((Group) scene.getRoot()).getChildren().addAll(vbox);
            stage.setScene(scene);
            stage.show();
    
            // now the table has been initially rendered and it's initial set of cells generated,
            // the cells can be looked up.
            for (Node r: table.lookupAll(".table-row-cell")){
                for (Node c: r.lookupAll(".table-cell")){
                    System.out.println(c);
                }
            }
        }
    
        public static class Person {
    
            private final SimpleStringProperty firstName;
            private final SimpleStringProperty lastName;
            private final SimpleStringProperty email;
    
            private Person(String fName, String lName, String email) {
                this.firstName = new SimpleStringProperty(fName);
                this.lastName = new SimpleStringProperty(lName);
                this.email = new SimpleStringProperty(email);
            }
    
            public String getFirstName() {
                return firstName.get();
            }
    
            public void setFirstName(String fName) {
                firstName.set(fName);
            }
    
            public String getLastName() {
                return lastName.get();
            }
    
            public void setLastName(String fName) {
                lastName.set(fName);
            }
    
            public String getEmail() {
                return email.get();
            }
    
            public void setEmail(String fName) {
                email.set(fName);
            }
        }
    } 
    
  • How iterate over the attributes of a single entity?

    I'm working on a script of transformation of the logic model. I take a list of entities:

    var = model.getEntitySet () .toArray () entities;

    iterate over the entities:

    for (var e = 0; e < entities.length; e ++) {}

    var = [e] entities entity;


    and try to get a list of all the attributes of the current entity:

    var attributes = entity.getAttributeSet () .toArray ();

    After that, I try to iterate through the attributes:

    for (var a = 0; a < attributes.length; a ++) {}

    attribute var = attributes [a];

    While performing an iteration on the attributes, I realized that the list is always the same. I always get a list of all the attributes probably of the whole model, even for entities without any attribute.

    How can I get a list of the attributes of a single entity?

    Hello

    Use entity.getAttributes)

  • need to take my computer back in the day that I first started it on7/21/2011 my restore point back up to now how can you start over from scratch with no disc?

    need to take my computer back in the day that I first started it on7/21/2011 my restore point back up to now how can you start over from scratch with no disc?

    Most OEM computers have a partition on the hard drive, that allows to give it bought as provided.  Usually, you activate this feature by pressing a key or combination of keys when the first splash screen appears at startup.  Look quickly at the first screen that appears, and you could see the key that you press.  Otherwise, go to your computer manufacturer's website and download the manual for your computer.  Instructions must be there.

    HTH,
    JW

  • When I list all PROGRAMS menu START, I can't see the third column because it is off the screen. So, how can I scroll to the third column, no scroll bar is present.

    hen I list all PROGRAMS menu START, I see the third column, because it is off the screen. So, how can I scroll to the third column, no scroll bar is present.

    Hello

    You did it changes on your computer before this problem?

    You try to increase the resolution of the screen and check if the problem persists.

    For more information, see these links: to change your screen resolution

    Change the resolution of your monitor

    Hope the helps of information.
    Please post back and we do know.

  • How can I lock you the desktop icons so that they change position. I use windows 7

    How can I lock you the desktop icons so that they change their position? I use windows 7.

    Try this:

    Right-click on an empty area of the desktop (not on an icon).

    In the menu that appears, move your mouse over "display".

    Is there a check mark next to "reorganization automatic icons? If so, click it to remove the check mark.

  • How can I get all the ID of SQL the same SQL literals change?

    My SQL statement is the same throughout, but only changing the literals, and therefore the SQL ID, i.e. SQL ID change also. How can I get all the SQL ID this SQL?

    Hello

    the FORCE_MATCHING_SIGNATURE column is also entered in the ASH / historical AWR views V$ ACTIVE_SESSION_HISTORY / DBA_HIST_ACTIVE_SESS_HISTORY / DBA_HIST_SQLSTAT.

    .. and after all, you can join these views as described with DBA_HIST_SQLTEXT, if necessary.

    DBA_HIST_SQLTEXT displays the text of SQL statements belonging to shared SQL cursors captured in the repository of the workload. This perspective captures information from V$ SQL and is used with the DBA_HIST_SQLSTAT view.

    Concerning

    Stefan

    P.S.: AWR is only based on the captured of course SQLs.

  • How can I get off the annoying ads for Apple music for good?

    How can I get off the annoying ads for Apple music for good?

    Settings-> music-> see music from Apple (off)

    Does that help?

  • I delete an email, how can I remove it &amp; the sender of a search?

    I delete an email, how can I remove it & the sender of a search?

    I assume you mean global search. If this does not work, you can rebuild its search-db

    https://support.Mozilla.org/en-us/KB/rebuilding-global-database

  • How can I find all the plugins in the firefox browser

    HI I was wondering if I could ask a question how can I find all the installed plugins in the firefox lasted I would like to be able to know if, for example, if the shockwave plugin is updated and which version is currently installed in the firefox browser lasted.

    Thank you

    Hello Funny78, type Subject: addons in the address bar and then select plugins, add-ons manager opens and you can see the last version of the plugins (and other info), now click on the click to see if your plugins are up to date and see if it is.

    Thank you

  • I use the beta version, how can I return to the basis of Firefox?

    How can I return to the basis of Firefox instead of the beta?

    Backup of your profile and you will not lose your add-ons and bookmarks.

  • How can I enter in the Gallery of photos iPhone 6s

    How can I enter in the Gallery of photos iPhone 6s? Like the ones you see on banners or commercials. Thank you

    If you mean the shooting on the campaign of the iPhone, you have not. If Apple sees your work and think it would be a good fit, they as you approach. So, better than you can do is put your work out there on things like Instagram.

    otograph https://photographicpunctuation.com/2015/03/07/The-Story-of-My-Shot-on-iPhone-pH.

  • How can I transfer only the music I want?

    Hello.

    Our iMac iTunes is full of music for the whole family. How can I transfer only the songs I want on my iPod and my iPad?

    Second...

    When connecting from my iPad to my iMac USB cable the iPad goes into sync mode and transfers all sorts of things on the iMac and gets things from him. All I want is to transfer my music? How can I do this?

    Create your own playlists in iTunes.

    Connect your iDevice to the iMac - in the main iTunes window select your iDevice - menu drop-down upper left box located to the left of the music-movies, etc.

    You will see a list of 'Settings' for this device - select a tab and check the boxes of what content you want on your device.

    Also in the Group of settings select 'Summary' - from there, in the 'Options' section, you have a few additional items to choose from.

    MJ

  • I have a partitura with 18 instruments. Problem is that only 16 of the sheed. How can I vertically down the music?

    I have a partitura with 18 instruments. Problem is that only 16 of the sheed. How can I vertically down the music?

    Make a score set with 18 all instruments. Then use the scale parameter set score to all fit on a single page.

  • Stolen phone. How can I check when the last time saved my phone to my laptop (without my iphone of course)?

    My iPhone was stolen. How can I check when the last time that I backed up my phone to my laptop without my iPhone?

    Click here and either use iTunes to check or browse to the path of the backup manually.

    (142338)

Maybe you are looking for