Referring to the dynamic cursor rows and columns in SQL

I have a procedure that dynamically reads a schema name and a table name in a table entry. The code must loop through all the rows and the columns in each table and the output data. I'm done with what I want to achieve 95%, but there is a little bug. The dbms_output.put(*col.column_name* ||) line '',''); ' ||
return to something like rec.col.column_name , so that it is the column of the current record. Currently, it simply displays the name of the column for each record instead of the actual value. Can someone help me to change the code to get the real value?

CREATE OR REPLACE PACKAGE BODY some_proc
-Function and procedure implementations
PROCEDURE create_files IS
CURSOR c_tbls IS
SELECT * FROM tbl_list;
l_sql VARCHAR2 (4000);
BEGIN
-To loop through all the tables
FOR tbl IN c_tbls LOOP
l_sql: = "DECLARE" | «C_tbl_recs CURSOR IS» | ' SELECT * ' |. '
'FROM ' | tbl.schema_name | '.' || tbl.table_name | '; ' ||
' t_tbl_rowtype c_tbl_recs % ROWTYPE; ' || "START" |
"FOR rec IN c_tbl_recs LOOP |
' FOR col IN (SELECT column_name ' |)
"FROM dba_tab_cols" |
"Owner WHERE ="' | " tbl.schema_name | '''' ||
' AND table_name = "' | tbl.table_name | '''' ||
ORDER BY column_id) LOOP '.
*' dbms_output.put(col.column_name ||) '',''); ' || * "END OF LOOP; dbms_output.put_line('''); END LOOP; ' ||
' END; ';
-dbms_output.put_line (l_sql);
EXECUTE IMMEDIATE l_sql;
END LOOP;
EXCEPTION
WHILE OTHERS THEN
dbms_output.put_line (SQLERRM);
END;
END;

Is this what you are looking for?
(it took a few minutes)

create or replace
package some_proc is
procedure create_files;
end;
/

CREATE OR REPLACE
PACKAGE BODY some_proc
IS
  -- Function and procedure implementations
PROCEDURE create_files
IS
  CURSOR c_tbls
  IS
    SELECT * FROM tbl_list;

  CURSOR c_cols (p_table_owner VARCHAR2, p_table_name VARCHAR2)
  IS
    SELECT column_name
    FROM all_tab_columns
    WHERE owner   =p_table_owner
    AND table_name=p_table_name
    ORDER BY all_tab_columns.column_id;

  l_sql     VARCHAR2(32000);

  separator VARCHAR2(1):=';';

BEGIN
  --Loop through all tables
  FOR tbl IN c_tbls
  LOOP
    dbms_output.put_line('TABLE: '||tbl.schema_name||'.'||tbl.table_name);
    l_sql := 'DECLARE ' ;
    l_sql := l_sql|| '  CURSOR c_tbl_recs IS ' ;
    l_sql := l_sql||'    SELECT * FROM ' || tbl.schema_name || '.' || tbl.table_name || '; ' ;
    l_sql := l_sql||'    linenr number:=1; ';
    l_sql := l_sql||'BEGIN ' ;
    l_sql := l_sql|| ' FOR rec IN c_tbl_recs LOOP ';
    FOR c IN c_cols(tbl.schema_name,tbl.table_name)
    LOOP
      l_sql:=l_sql ||' if linenr=1 then  dbms_output.put('''||c.column_name||''||separator||'''); end if; ' ;
    END LOOP;
    l_sql :=l_sql||'  dbms_output.put_line(''''); linenr:=linenr+1; ';
    FOR c IN c_cols(tbl.schema_name,tbl.table_name)
    LOOP
      l_sql:=l_sql ||' dbms_output.put(rec.'||c.column_name||'||'''||separator||'''); ' ;
    END LOOP;
    l_sql:=l_sql||'  end loop; ';
    l_sql:=l_sql||'  dbms_output.put_line(''''); ';
    l_sql:=l_sql||'  dbms_output.put_line(''''); ';
    l_sql:=l_sql||'end;';
    EXECUTE IMMEDIATE l_sql;
  END LOOP;
EXCEPTION
WHEN OTHERS THEN
  dbms_output.put_line(SQLERRM);
END;
END;
/

Tags: Database

Similar Questions

  • How to find the way to rows and columns of matrix

    Hello everyone

    I have a matrix N * M with some of the elements with only 0 and 1.

    has every element that is 1 (line, column).

    I want to find the elments 1 and find the way to lines which is 1, and also the average columns.

    Thank you very much

    my email: [email protected]


  • How to change the rows and columns of newtabs?

    I can't change the rows and columns to mozilla version 33

    From topic: config browser.newtabpage.columns shows 5 by default, but these 5 columns appear not only 3 as before. Don't know why, but I use generally not even the default new tab page in my profile daily.

    Still works this - https://addons.mozilla.org/en-US/firefox/addon/new-tab-tools/ - extension to change the page of newTab via a user accessible interface name in the Addons, rather than routing autour Manager inside Firefox. I use this add-on in a second profile that I use for my favorite sites

  • How to get the string (specified by row and column) of txt file with labview

    Hello world

    How to get the string (specified by row and column) of txt file with labview

    THX

    As far as I know, a text file has no column.  Be more specific.  Do you mean something like the 5th word on line 4, where the words are separated by a space, and lines are separated by a newline character?  You can read from the spreadsheet String function and set the delimiter to a space.  This will produce a 2D channels table.  Then use the table to index and give the line number and column number.

  • Write multiple rows and columns of the worksheet

    Is it possible to write several rows and columns of the spreadsheet, with the ability to add data to the file and create a new file if it does not exist?
    I tried to write to table vi, but I couldn't make it work.
    It won't let me write several lines in the same column.
    Can someone please give me an example?
    Thanks in advance.

    If you want to use the tab character (\t) as the delimiter, then check the txt file.  Then Excel will open as you wish.

    If you want to keep the csv extension, then use comma (,) as a separator.

  • How to create the table with the rows and columns using the layout?

    One of my friends advised me to put my site on the mode of provision as it is better than the standard as he said
    but I couldnot make an ordinary table with the rows and columns in mode available th
    y at - there someone who can tell me how to?
    Thank you very much

    Wednesday, April 18, 2007 21:01:38 + 0000 (UTC), "Mr.Ghost".
    wrote:

    > A friend of mine advised me to put my whole site on the mode of disposal as its
    > better than standard, as he says

    Your friend won't. Don't listen to him any more. Mode of disposal creates
    very fragile and rigid code pauses at the first opportunity.

    Gary

  • How to Exchange rows and columns where to access the paper web in html IE

    Hi all!

    I use web analytics studio Oracle hyperion with Version: 11.1.1.2.0.940. Design of web document analysis, I use the spreadsheet, then turn to the analysis view, I can swap the row and column position by dragging and pulling.

    But when I access the document by the smartcut in ie browser, opening in the html template, how can I exchange line and column position?

    Thank you very much in advance.

    OK, I think I understand what you're saying. The problem is that it does not show the left pane with a smartcut.

    Here's a tip. Add a button of 'Service '. Add "Information Toggle Pane" as the service.

    When you click the button that will open the left handle in HTML view panel. You will then see row and column and you should be able to switch the dimensions as needed. I just tested and it works.

    hope that helps.

  • Rows and columns help

    Previously on AI9 when I wanted to change a matrix that I created using rows and columns, I select the cells in the matrix and then click rows and columns.  Now I have CS4 and the documentation says that I should be able to do the same thing using the Options of the Type of area.  However, when I select the cells of a matrix that I created in AI9, Options of Type box is ghost out.  How to change this matrix?

    I would copy and paste in front before I try this.

    Then select the text which is place the text cursor in the text frame, you want to split or select it with the selection tool.

    then see if the Type > text box Options are available. They should be.

    If this isn't the case, it means they aren't object path text box.

    Click on the image with the tool text box to make a block of text in box now the options should be available.

    The way to know if these are paths of purpose is to select one and go to object > path > split into grid and if it's available, then it is an object path.

    The text engine and this feature was changed to AI CS1 and this is probably the cause of the translation to be a little messed up.

  • How can I insert a number to a specific index (row and column) to a table

    I had the most with function 'insert into array' problem because of its counter-intuitiveness. I want to insert a number I got inside a loop IN a table. The ROW and COLUMN of this table I want enter the number is specified by the number of loops of two loops FOR. It did not work.

    So, I have isolated and tested this function further. Frankly, I initialized a table 2D with ZEROS and plugged into the "insert into array" function (on top of entry). I then put the number '1' for the index (line) and the number "2" for the index (column) and then put the entry number "6" for the "new item/sub-table. Then, I hung a picture of 2-D (indicator) output to the output of the function "insert into array. When I did all that, it means I want to just put the number '6' in line '1' and the column '2'... This isn't letting me do it.

    How can I do this SIMPLE?

    Hi Darrell h...,

    Looks like you can use the function "autoindexing. Take your value and connect it to your loop, it will be a default autoindexing. Right-click on the last tunnel of output and select Create indicator, the result is your table.

    It will be useful.

    Mike

  • Obtaining of row and column of a table element

    Hello

    I have a table of 24 rows and column 24 giving me a total of 576 items. How can I get the row and column of a particular element in a table in LabView. For example if I write to item 127 How can I get the column and line item 127 is located.

    Kind regards

    Bastien

    Hi Marion,.

    Maybe just need to find the right "address" element in your 2D table?

    Use something like this:

    Maybe you have to out of line & column according to your numbering scheme...

  • How to copy/paste in rows and columns

    Let's say I have an object in PS (gummy bear for example) and I want to duplicate in rows and columns. Is there a way to do it automatically?

    1. open your file of gummy bear and resize the image to a smaller, if necessary.

    2 file > set the model. Name it and ok.

    3. open a new file, 8 x 10, for example

    4 edit > fill > model... and in the Custom model drop-down list, it will be the last of them. Choose it.

    5. click on OK

    Fact.

    If your want a space between gummy bear, add space in step 1

    Good luck

  • Sortable rows and columns

    Is it possible to drag and drop the rows and columns of a multicolumn script to rearrange them. If this isn't the case, it would be appropriate.

    Please write to us.

    We do not expect to support mobile in an AV Scripts columns because they are only 2 columns fixed in script format.

    If you create a script to multiple columns and click on a column heading, you will end up by selecting the contents of that column. Press CTRL-X to cut this column, then press CTRLV to paste the column somewhere before an existing column.

    This should solve your problem.

    -Anubhav

    Anubhav Rohatgi

    Senior product manager

  • Max rows and columns

    What can be the maximum number of rows and columns, you can have in a table in an oracle database?

    See the limits of logical database in http://download.oracle.com/docs/cd/E11882_01/server.112/e17110/limits003.htm#i288032.

  • Add a table with the number of lines and columns JS

    Hello

    Simple question: what is the syntax for adding a table with a specified number of rows and columns? I don't get it. (I don't know how to add them later, but I want to do when I create the table). Here is the entry in the ESTK:

    Tables.Add (to: LocationOptions, reference: all, withProperties: Object): array

    Creates a new table.

    (optional): Data Type: LocationOptions, by default: LocationOptions.UNKNOWN
    The location of the new table to the object within the container object or reference. (Optional)

    Reference: Data Type: no
    The reference object. Note: Required when the value specifies before or after. Can accept: Table, XmlStory, XMLElement, TextFrame, text, character, Word, line, paragraph, TextColumn, PointInsertion, story, cell or TextStyleRange. (Optional)

    withProperties: Data Type: object
    Initial values for the properties of the new Table (optional)

    Thank you

    Ariel

    After much experimentation, I found this works:

    t = app.selection [0].tables.add (LocationOptions.AT_BEGINNING, undefined, {columnCount:2, headerRowCount:1, bodyRowCount:5, footerRowCount:3});})

  • When I click on the 'Get' button in the app store for El Capitan, the beachball cursor rises and crashes the app store (not responding) in the force quit window...

    When I click on the 'Get' button in the app store for El Capitan, the beachball cursor rises and crashes the app store (not responding) in the force quit window...

    How can I fix it?

    Nevermind, I restarted the computer and it was fixed

Maybe you are looking for

  • Why not given priority of a show of note sent anywhere in the grade received?

    In Thunderbird, you can set the priority of a mark composed and sent.However, I don't see any indication who give priority either the note which is sent in the sent folder or in the grade received. In particular, the recipient does not see the note a

  • Restore settings facotry Equium A100-206

    Hi all I would put my laptop to factory settings. Its been very slowly so I thought put to factory settings would help?Also do I need to save all the hard drive before I restore it to factory settings? Thanks in advance for help you

  • Updated power supply with h8 - 1360t (after installing HD 9750 / 3 gb)

    I am the owner of a h8 - 1360t with Win 8.1, 8 GB of memory and a (new to me) Sapphire HD 9750 3 GB card video. I "think" my system has the 460W power supply - this is due to the strange re-boots that my system has when playing video games online (I.

  • VAIO Motion Eye Camera stop working

    Laptop: VGN-SR190EProblem: USB Motion Eye Camera stop workingOS: Vista Edition Home Premium The Sony Visual Communication Camera died in this laptop. I want to talk about the "Motion Eye" webcam above the screen. In the Arcsoft window, frame (window

  • Error code 0 x 643 for updating security (KB2656370)

    I could not update since April 10, 2012 - error Code 0 x 643 to update security for Microsoft .NET Framework 1.1 SP1 on Windows XP, Windows Vista and Windows Server 2008 x 86 (KB2656370) My question is - do I really need Microsoft .NET Framework? I o