How to get columns horizontal in pl/sql procedure

My task is I want to retrieve all the Insert Statements of the rows that are present in each table of a particular Schema.
When I give input as Schema name(Scott) in a Procedure, Then the procedure retrieves all the Insert statements of rows of all tables that are present in scott user.
For this I started like this
CREATE OR REPLACE PROCEDURE MYPROC(UID DBA_OBJECTS.OWNER%TYPE)
AS
CURSOR MYCUR IS select o.owner, o.object_name,c.column_name
from dba_objects o, dba_tab_cols c where o.owner=c.OWNER(+) AND O.OWNER=UID
AND O.OBJECT_NAME=C.TABLE_NAME AND ROWNUM<20 AND O.OBJECT_TYPE='TABLE';
BEGIN
FOR EREC IN MYCUR LOOP
DBMS_OUTPUT.PUT_LINE('insert into '||erec.object_name||'('||erec.column_name||')'||'values(');
END LOOP;
END MYPROC;
When I execute this procedure I got the result as follows.
EXEC MYPROC('SCOTT');
insert into DEPT(DEPTNO)values(
insert into DEPT(DNAME)values(
insert into DEPT(LOC)values(
insert into EMP(EMPNO)values(
insert into EMP(ENAME)values(
insert into EMP(JOB)values(
insert into EMP(MGR)values(
insert into EMP(HIREDATE)values(
insert into EMP(SAL)values(
insert into EMP(COMM)values(
insert into EMP(DEPTNO)values(
insert into BONUS(ENAME)values(
insert into BONUS(JOB)values(
insert into BONUS(SAL)values(
insert into BONUS(COMM)values(
insert into SALGRADE(GRADE)values(
insert into SALGRADE(LOSAL)values(
insert into SALGRADE(HISAL)values(
insert into PROJECT(PNO)values(
As you see the columns are coming in line by line.
Now My question is I want the columns of each table to come in only One Insert Statement.i.e. one insert statement for one table. All columns of one table should in one row. How to do this?
Please Help me
Thanks in Advance.

Hi,
two loops works the easiest way
CREATE OR REPLACE PROCEDURE MYPROC(UID DBA_OBJECTS.OWNER%TYPE)
AS
CURSOR MYtab
IS
select o.owner, o.object_name
from dba_objects o where O.OWNER=UID
and ROWNUM<20
AND O.OBJECT_TYPE='TABLE';
CURSOR MYCol(b_owner varchar2,b_table varchar2)
IS
select c.column_name
from dba_tab_cols c where c.owner=b_OWNER AND b_table=C.TABLE_NAME;
l_line varchar2(2000);
begin
  for r_tab in mytab
loop
  l_line :='insert into '||r_tab.object_name||'(');
  for r_col in mycol(r_tab.owner,r_tab.object_name)
  loop
    l_line := l_line||r_col.column_name||',';
  end loop;
  l_line := rtrim(l_line,',')||') values (';
dbms_output.put_line(l_line);
end loop;
end;Hope this will give you some insights how to get the results.
Herald ten Dam
Superconsult.nl

Similar Messages

  • How to get column names for a specific view in the scheme?

    how to get column names for a specific view in the scheme?
    TIA
    Don't have DD on the wall anymore....

    or this?
    SQL> select text from ALL_VIEWS
      2  where VIEW_NAME
      3  ='EMP_VIEW';
    TEXT
    SELECT empno,ename FROM EMP
    WHERE empno=10

  • How to get column header text in IWDTable

    Hi
    Just want to know how to get column header name in IWDTable.
    I know that you can get it with
    IWDAbstractTableColumn[] groupedColumns = table.getGroupedColumns();
    for (int i = 0; i < groupedColumns.length; i++) {
         IWDAbstractTableColumn column = groupedColumns<i>;
         column.getHeader().getText();
    But what if text isnt set on header level but its rendered from cellEditor  model binding (im not sure if its like that).

    Finally after your suggestion i did it with this code
    String header = column.getHeader().getText();
                       if ((header == null || header.length() == 0) && column instanceof IWDTableColumn){
                            IWDTableCellEditor tableCellEditor = ((IWDTableColumn) column).getTableCellEditor();
                            if (tableCellEditor instanceof IWDTextView){
                                 String bindingPath = ((IWDTextView)tableCellEditor).bindingOfText();
                                  StringTokenizer tokenizer = new StringTokenizer(bindingPath,".");
                                  String token = "";
                                  IWDNodeInfo nodeInfo = context.getNodeInfo();
                                  while (tokenizer.hasMoreTokens()){
                                       token = tokenizer.nextToken();
                                       if (tokenizer.hasMoreTokens()){
                                            nodeInfo = nodeInfo.getChild(token);          
                                  IWDAttributeInfo attribute = nodeInfo.getAttribute(token);
                                  ISimpleType simpleType = attribute.getSimpleType();
                                  simpleType.getDescription();
                                 header = simpleType.getDescription();

  • How to get Listener Information using PL/SQL code

    How to get Listener Information using PL/SQL code

    user2075318 wrote:
    How to get Listener Information using PL/SQL codeThis approach (somewhat of a hack) can be used - but it does not really provide meaningful data at application layer.
    SQL> create or replace function TnsPing( ipAddress varchar2, port number default 1521 ) return varchar2 is
      2          type THexArray is table of varchar2(2);
      3          --// tnsping packet (should be 10g and 11g listener compatible)
      4          TNS_PING_PACKET constant THexArray := new THexArray(
      5                  '00', '57', '00', '00', '01', '00', '00', '00',
      6                  '01', '39', '01', '2C', '00', '00', '08', '00',
      7                  '7F', 'FF', '7F', '08', '00', '00', '01', '00',
      8                  '00', '1D', '00', '3A', '00', '00', '00', '00',
      9                  '00', '00', '00', '00', '00', '00', '00', '00',
    10                  '00', '00', '00', '00', '00', '00', '00', '00',
    11                  '00', '00', '00', '00', '00', '00', '00', '00',
    12                  '00', '00', '28', '43', '4F', '4E', '4E', '45',
    13                  '43', '54', '5F', '44', '41', '54', '41', '3D',
    14                  '28', '43', '4F', '4D', '4D', '41', '4E', '44',
    15                  '3D', '70', '69', '6E', '67', '29', '29'
    16          );
    17 
    18          socket  UTL_TCP.connection;
    19          txBytes number;
    20          rxBytes number;
    21          rawBuf  raw(1024);
    22          resp    varchar2(1024);
    23  begin
    24          socket := UTL_TCP.open_connection(
    25                          remote_host => ipAddress,
    26                          remote_port => port,
    27                          tx_timeout => 10
    28                  );
    29 
    30          --// convert hex array into a raw buffer
    31          for i in 1..TNS_PING_PACKET.Count loop
    32                  rawBuf := rawBuf || HexToRaw( TNS_PING_PACKET(i) );
    33          end loop;
    34 
    35          --// send packet
    36          txBytes := UTL_TCP.write_raw( socket, rawBuf, TNS_PING_PACKET.Count  );
    37 
    38          --// read response
    39          rxBytes := UTL_TCP.read_raw( socket, rawBuf, 1024 );
    40 
    41          UTL_TCP.close_connection( socket );
    42 
    43          --// convert response to varchar2
    44          resp := UTL_RAW.Cast_To_Varchar2( rawBuf );
    45 
    46          --// strip the header from the response and return the text only
    47          return( substr(resp,13) );
    48  end;
    49  /
    Function created.
    SQL>
    SQL> select tnsping( '10.251.93.30' ) as TNSPING from dual;
    TNSPING
    (DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=0)(ALIAS=LISTENER))
    SQL> select tnsping( '10.251.95.69' ) as TNSPING from dual;
    TNSPING
    (DESCRIPTION=(TMP=)(VSNNUM=0)(ERR=0)(ALIAS=LISTENER))
    SQL>

  • How to call javascript function from PL/SQL procedure

    Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?

    Hi,
    I have a requirement to call Javascript function inside a After Submit Process.
    clear requirement below:
    1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
    2. user clicks on "save files" button
    3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
    Hope this clarify U.
    Krishna.

  • How to ftp a file within PL/SQL procedure?

    Hi, all:
    Any idea of how to ftp a file within PL/SQL procedure? I have scheduled a job to periodically generate a file and want to ftp this file to another machine. I know crontab can do the ftp part, since we can send email within Oracle, I am wondering whether we can ftp within Oracle as well? Thanks a lot!

    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:150612348067

  • How to use get column name.vi in SQL toolkit 2.0?

    Due to the vi "get column name.vi" paremeters,no table name has connected to the vi. So, I want to ask how to use this vi for gain one column name of a table. Maybe there are some other ways to solve column name getting.
    Thanks.

    Thanks!
    Error 4101 Description:
    Execute SQL - The connection, statement, or query handle you provided is not valid.
    I don't just used the toolkit in a while,now, I am developing a irrigation system. For the table field names defined by users,column names must be known before any select operations. Do you have any other good idea about drawing out the columnname parameters?
    As you know, a valid DSN and table have been also available. The database I used is Access. The bad thing to me is that there is no any text information gotten. And I think, it may be some problems in connection way which I don't find out.
    Really appreciated by your reply.
    Could you give me some example in the aspect?
    Thank you again.

  • Custom row-fetch and how to get column values from specific row of report

    Hi -- I have a case where a table's primary key has more than 3 columns. My report on the
    table has links that send the user to a single-row DML form, but of course the automatic
    fetch won't work because 1) I can't set more than 3 item values in the link and 2) the
    auto fetch only handles 2 PK columns.
    1)
    I have written a custom fetch (not sure it's the most elegant, see second question) that is working
    for 3 or few PK columns (it references the 1-3 item values set in the link), but when there are
    more than 3, I don't know how to get the remaining PK column values for the specific row that was
    selected in the report. How can I access that row's report column values? I'll be doing it from the
    form page, not the report page. (I think... unless you have another suggestion.)
    2)
    My custom fetch... I just worked something out on my own, having no idea how this is typically
    done. For each dependent item (database column) in the form, I have a source of PL/SQL
    function that queries the table for the column in question, using the primary key values. It works
    beautifully, though is just a touch slow on my prototype table, which has 21 columns. Is there
    a way to manually construct the fetch statement once for the whole form, and have APEX be smart
    about what items get what
    return values, so that I don't have to write PL/SQL for every item? Because my query data sources
    are sometimes in remote databases, I have to write manual fetch and dml anyway. Just would like
    to streamline the process.
    Thanks,
    Carol

    HI Andy -- Well, I'd love it if this worked, but I'm unsure how to implement it.
    It seems I can't put this process in the results page (the page w/ the link, that has multiple report rows), because the link for the row will completely bypass any after-submit processes, won't it? I've tried this in other conditions; I thought the link went directly to the linked-to page.
    And, from the test of your suggestion that I've tried, it's not working in the form that allows a single row edit. I tried putting this manually-created fetch into a before header process, and it seems to do nothing (even with a hard-coded PK value, just to test it out). In addition, I'm not sure how, from this page, the process could identify the correct PK values from the report page, unless it can know something about the row that was selected by clicking on the link. It could work if all the PK columns in my edit form could be set by the report link, but sometimes I have up to 5 pk columns.
    Maybe part of the problem is something to do with the source type I have for each of the form items. With my first manual fetch process, they were all pl/sql functions. Not sure what would be appropriate if I can somehow do this with a single (page level?) process.
    Maybe I'm making this too hard?
    Thanks,
    Carol

  • Get Column sum, count in sql developer

    Dear All seniors,
    I need help in oracle sql developer that after select statement when we got our result in below rows and coloums,
    then how to get its sum, count, etc.
    as in pl sql developer we simply right click at a column and then click on the desired function.
    is this facility also have in sql developer?

    We've kicked around the idea of doing this for awhile. I believe there's already an item in the Exchange if you want to up vote it. The challenge being if it's a result set which hasn't been fully fetched, doing an aggregate would require one - and that could be costly. Of course folks live in the grids so I see the value in this type of feature as well.
    As a workaround, you could of course export your data to CSV or XLS and do the calculations in your favorite spreadsheet software.

  • How to get column value from DB grid

    Hi!
    I wander how to get col value from GridControl?
    My app consists of one rowsetinfo with two
    columns CODE and DESCRIPTION and a jbutton
    titled SELECT. When user clicks SELECT button
    the app should show the value of the CODE col
    of the selected row in GridControl.
    I wander how to make this action ?
    XxpsTransTimesMasterIter.setAttributeInfo( new AttributeInfo[] {
    CODEXxpsTransTimesMasterIter,
    DESCRIPTIONXxpsTransTimesMasterIter} );
    XxpsTransTimesMasterIter.setName("XxpsTransTimes");
    XxpsTransTimesMasterIter.setQueryInfo(new QueryInfo(
    "XxpsTransTimesMasterIterViewUsage",
    "lov.XxpsTransTimes",
    "CODE, DESCRIPTION",
    "XXPS_TRANS_TIMES",
    null,
    null
    ));

    Hi,
    You could attach an ActionListener on the JButton, and try the following code :
    NavigationManager fm = NavigationManager.getNavigationManager();
    DataItem dataItem = fm.getFocusedControl().getDataItem();
    ImmediateAccess col_code = null;
    String code = null;
    if (dataItem != null && dataItem instanceof RowsetAccess) {
    RowsetAccess rowset = (RowsetAccess)dataItem;
    try {
    col_code = (ImmediateAccess) rowset.getColumnItem("CODE");
    code = col_code.getValueAsString();
    } catch (DuplicateColumnException de) {
    return;
    } catch (ColumnNotFoundException ce) {
    return;
    } catch (SQLException se) {
    return;
    JTextField tf = new JtextField();
    tf.setText(code);
    I haven't tested this code.
    I am curious to know, the Object type of the dataItem.If it doesnot happen to be RowsetAccess ..try.. ScrollableRowsetAccess OR ImmediateAccess.
    Your code would change accordingly, depending on the instance.Refer to the product documentation for this.
    Do let me know, if this works.
    TIA
    Sandeep

  • How to get the Horizontal Scroll Bar for a Table?

    Hi All,
    As per my requirement, I am displaying several records in a Screen in a Tabular Format. But here I have to show 21 Columns in that table which is too high. I am able to display it but due to it I am getting a Horizontal scroll bar for the whole screen since all the columns are not getting displayed in the normal window screen space. But its looking too odd since once I am scrolling it to right the columns are getting displayed but the above Header Bar and Global buttons are not displaying, they are bound to the normal screen space.
    Is there a way to have a Horizontal scroll bar only for that table instead of the entire screen so that on scrolling that bar only the table rows will beshifted ant got displayed?
    With Thanks
    Kumar Gautam

    try this approach.
    include a raw text item before and table item.
    include the appropriate HTML tags in raw text item to enable horizontal scroll
    --Prasanna                                                                                                                                                                                                                                                                                                                                   

  • How to get currency format using pl sql function

    Hi all,
    I am a newbee on the forum. currently i am facing an issue with the Format of Currency in an rdf report. This is a field of tax amount & i need to make some conditional formatting on this like if the tax amount is Zero then some static note is to be added before this field.
    I have tried a lot of functions on it like the one as below:
    IF :cp_org_id = 102
    AND :invoice_currency_code <> 'CAD'
    AND TO_CHAR (NVL (:cf_tax_amount, 0)) = 0
    THEN
    RETURN (TRUE);
    ELSE
    RETURN (FALSE);
    This is working fine in case of Zero tax amount But gets error out when there some Tax amount exists. It gives a VALUE ERROR in this format Trigger.
    Kindly suggest me how to solve this issue with right function. If possible then write the pseudo Code also.
    Thanks in advance
    D_Verma

    In addition to Satyaki:
    It might be a 'Reports Thing'.
    It works in SQL*Plus (although relying on implicit conversions is a bad idea, as mentioned):
    MHO%xe> begin
      2  IF 102 = 102
      3  AND 'DAC' != 'CAD'
      4  AND TO_CHAR (NVL (null, 0)) = 0
      5  THEN
      6  dbms_output.put_line('TRUE');
      7  ELSE
      8  dbms_output.put_line('FALSE');
      9  end if;
    10  end;
    11  /
    TRUE
    PL/SQL-procedure is geslaagd.
    MHO%xe> begin
      2  IF 102 = 102
      3  AND 'DAC' != 'CAD'
      4  AND TO_CHAR (NVL (0, 0)) = 0
      5  THEN
      6  dbms_output.put_line('TRUE');
      7  ELSE
      8  dbms_output.put_line('FALSE');
      9  end if;
    10  end;
    11  /
    TRUE
    PL/SQL-procedure is geslaagd.
    MHO%xe> begin
      2  IF 102 = 102
      3  AND 'DAC' != 'CAD'
      4  AND TO_CHAR (NVL ('0', '0')) = '0'
      5  THEN
      6  dbms_output.put_line('TRUE');
      7  ELSE
      8  dbms_output.put_line('FALSE');
      9  end if;
    10  end;
    11  /
    TRUE
    PL/SQL-procedure is geslaagd.

  • How to get rid of quotes in SQL?

    Hi All!
    Does anybody know how to get rid of quotes in
    generated SQL? I don't mean manual editing.
    Are there any properties controlling this
    behavior (adding "" automatically)?
    Thanks in advance!
    Sincerely,
    Lev

    Use PreparedSatement class,
    e.g.
    // Where the name field is defined as char, i.e. needs quotes in SQL.
    String sql = "select * from person where name = ? ";
    PreparedStatement statement = connection.prepareSatement(sql);
    statement.setString(1, "Bob");
    statement.executeQuery();
    This will get rid of hardcoding db vendor dependant quotes in your sql,
    Hope this helped.

  • How to get information from desktops into SQL?

    Hello Everyone,
    I could use some help with an idea that I have been working on. I basically am looking for a way to capture information from desktops and get that data into a SQL database. Could anyone give me any links, kb articles, etc on how I can go about doing this?
    Any help would be very appreciated
    Thanks :)

    Powershell is the tool for you. If you could please move this post to powershell; you should get better response.  I almost certain that there are already some powershell scripts that does this, or at least will give you a report or a excel\csv file
    with this information.
    once you have that info you import that data into sql and sql server agent jobs you can automate. 
    Below are some of the resources :
    http://serverfault.com/questions/585223/how-to-list-all-computers-operating-system-on-a-network-in-powershell
    https://www.simple-talk.com/sql/database-administration/let-powershell-do-an-inventory-of-your-servers/
    http://gallery.technet.microsoft.com/scriptcenter/Hardware-Inventory-Using-fe6611e0
    http://blogs.technet.com/b/heyscriptingguy/archive/2006/11/09/how-can-i-use-windows-powershell-to-get-a-list-of-all-my-computers.aspx
    Again, please move this powershell thread. you will get better response,
    Hope it Helps!!

  • How to get column values on item added event receiver

    Hi,
    I have two columns in a document library and one is people or group column and the other one is choice column with check boxes.
    I want to know how to read column values on Item Added event receiver, so that I can create if statements based on those values.
    Thank you,
    AA.

    Hi AOK2013, 
    Have you had a look at this Microsoft tutorial: http://msdn.microsoft.com/en-us/library/office/gg981880(v=office.14).aspx
    Essentially, you want to use the AfterProperties property to access the changed field value. 
    E.g. 
    var personvalue = properties.AfterProperties["YourPersonFieldName"]
    Regards, Matthew
    MCPD | MCITP
    My Blog
    View
    Matthew Yarlett's profile
    See my webpart on the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here:
    Upload and Crop User Profile Photos

Maybe you are looking for

  • Db link tables in processes and row fetch

    I have an application I developed in schema A that is referencing tables in schema B. I have been told that these tables need to be moved to another database for which I have created a database link. I know this database link is working because it te

  • Photoshop CS 4 plug in for Canon D5 Mark 2?

    Hello, sorry to ask maybe this basic question, but I am really desperate. I got RAW fotos from a friend and I cannot open them, she has a canon 5D mark 2.. I do have an old Canon 5D myself and they are fine. Where can I download the plug in that I ne

  • HT1430 need help with an ipod touch

    I tryed my password and it did not work and now it is telling me to connect to itunes what should i do from there.

  • Plant Maintenance_Goods Issue to Maintenance Order

    Dear Experts, Can you please suggest me how to map the following process in SAP PM. 1.     Mostly Engineers assigned to Maintenance raises MRN (Material Requisition Note) to Engineering Warehouse. 2.     Damage Items are returned as engineering scrap

  • Nokia E72 Troubleshoot

    Hello guys, I have a nokia E72 that was working well for almost 2 years 2 days ago after recharging my phone when the battery was empty, I turned my phone on and it took almost 5-8 hours so that my phone starts properly. I tried to reinstall the soft