Select column from user.table

Hi,
I have 100 users. Each one has same table let's say tableA. I want a query that return back the value of a given column in that table for all users with their names. I thought about a join between dba_users (username) and that table. Basically I generate a script by this :
select 'SELECT CULOMN FROM '||owner||'.'||TABLE_NAME||';' from all_tables where table_name='TABLEA';
I execute the result script as sysdba.
But when executed it does not show the name of each user. I mean we can not see which value belongs to whom.
How can I do that ?
many thanks before.
Message was edited by:
user522961

Or perhaps you just want some dynamic SQL like this:
SQL> ed
Wrote file afiedt.buf
  1  DECLARE
  2    CURSOR u IS
  3      SELECT username
  4      FROM   all_users
  5      ORDER BY username;
  6    v_cnt1 NUMBER;
  7    v_cnt2 NUMBER;
  8    v_tbl  VARCHAR2(30) := 'EMP';
  9  BEGIN
10    FOR users IN u
11    LOOP
12      SELECT count(*)
13      INTO   v_cnt1
14      FROM   ALL_TABLES
15      WHERE  owner = users.username
16      AND    table_name = v_tbl;
17      IF v_cnt1 > 0 THEN
18        EXECUTE IMMEDIATE 'SELECT count(*) FROM '||users.username||'.'||v_tbl INTO v_cnt2;
19        DBMS_OUTPUT.PUT_LINE('User: '||users.username||' Count on '||v_tbl||':'||v_cnt2);
20      END IF;
21    END LOOP;
22* END;
SQL> /
User: FRED Count on EMP:27
User: BOB Count on EMP:34
PL/SQL procedure successfully completed.
SQL>

Similar Messages

  • How can I select columns from a table EMP, using Select statement?.

    Hi Friends,
    How can I select columns from a table EMP?.
    I want to select columns of EMP table, using select statement.
    Please reply me urgently.
    Shahzad

    Something like this:
    scott@DBA> select empno,ename,job from emp;
         EMPNO ENAME      JOB
          7369 SMITH      CLERK
          7499 ALLEN      SALESMAN
          7521 WARD       SALESMAN
          7566 JONES      MANAGER
          7654 MARTIN     SALESMAN
          7698 BLAKE      MANAGER
          7782 CLARK      MANAGER
          7788 SCOTT      ANALYST
          7839 KING       PRESIDENT
          7844 TURNER     SALESMAN
          7876 ADAMS      CLERK
          7900 JAMES      CLERK
          7902 FORD       ANALYST
          7934 MILLER     CLERK
    14 rows selected.Check the documentation:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#sthref9697
    Message was edited by:
    Delfino Nunez

  • Selecting columns from two table is slow but same

    I am selecting 27 columns from two tables
    which running for more than 30 minutes. but
    if I select count(*) with the same query
    except the columns it is coming in seconds.
    Where is the error?

    If you post
    1) The table definitions for the underlying tables
    2) The indexes that are on the tables
    3) The two SQL statements you're running
    4) The explain plan for both statements
    we can probably be of some assistance.
    My guess is that the count(*) is able to return much more quickly because the optimizer is able to use a significantly faster query plan that is based on an index which the longer-running query cannot utilize. Without the information I've requested, though, it's hard to do more than speculate.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to select columns from internal table using 'GUI_DOWNLOAD' ?

    Hi,
    i am running a report & the fields for output is saved in an internal table which has as many as 10 fields. But I want to select only a few fields for output. There is a option COL_SELECT in function 'GUI_DOWNLOAD'. How to use it. If possible with example.

    Hai VijayKumar
    Try with the following code
    tables : mara.
    data : begin of it_mara occurs 0,
           matnr like mara-matnr,
           mbrsh like mara-mbrsh,
           mtart like mara-mtart,
           meins like mara-meins,
           end of it_mara.
    parameters : P_mtart like mara-mtart default 'ROH'.
    start-of-selection.
    perform select_data.
    perform download_data.
    *&      Form  select_data
          text
    -->  p1        text
    <--  p2        text
    FORM select_data .
    select
          matnr
          mbrsh
          mtart
          meins
          from mara into table it_mara
          where mtart = p_mtart.
    ENDFORM.                    " select_data
    *&      Form  download_data
          text
    -->  p1        text
    <--  p2        text
    FORM download_data .
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME                        = 'c:\down.txt'
        FILETYPE                        = 'ASC'
        COL_SELECT                      = 'X'
        COL_SELECT_MASK                 = 'X XX'
      TABLES
        DATA_TAB                        = it_mara.
      IF SY-SUBRC = 0.
        SORT IT_MARA BY MATNR.
      ENDIF.
    ENDFORM.                    " download_data
    Thanks & Regards
    Sreenivasulu P

  • How to select columns in a table by their column id and not the column name

    Hello,
    How do you select columns from a table based on their column_id.
    I have create a view
    but other than Select * , i cant now select one just one column from it
    the view as follow:
    create view count_student as
    select a.acode "acode",aname "Activity Name",count(ae.acode) "Number of student joined"
    from aenrol ae, activity a
    where a.acode= ae.acode
    group by a.acode,aname;

    The issue is that you have decided to use quoted column names. A pretty horrible idea (mostly for the reasons that you are now finding).
    Re-create the view and get rid of the silly double quotes.

  • Selecting data from a table which has a LONG column

    hi all,
    In the table user_views there is a LONG column. Now i want to select rows from that table based on this LONG column. like....
    select *from user_views where text like '%account%;
    but i am getting the error.."ORA-00932: Inconsistent datatypes:Expected NUMBER got LONG".
    How do I overcome this error.
    Please give me some suggestions.
    Thanks & Regards,
    Vijay

    In the table user_views there is a LONG column. Now i want to select rows from that >table based on this LONG column. like....LONG columns cannot appear in a WHERE or
    AND clause.

  • How to insert select columns from one internal table to another

    Hi,
    How to insert select columns from one internal table to another based on condition as we do from a standart table to internal table.
    regards,
    Sriram

    Hi,
    If your question is for copying data from 1 int table to other ;
    we can use
    APPEND LINES OF it_1 TO it_2.
    or if they have different columns then:
    loop at it_1 into wa_it1.
    move wa_it1-data to wa_it2-d1.
    apped wa_it2 to it_2.
    clear wa_it2.
    endloop.
    thnxz

  • How to get selected entity from ADF Table

    I'm using EJB and ADF Faces.
    I have an ADF Table, and when a row is selected I'd like to be able to get the EJB Entity that was selected, is this feasible?
    The reason I would like to do it, is for a Dialog. I have a popup dialog, and in the popup the user can do a search. The results are displayed in the ADF table. When supplying the return value from the dialog:
    AdfFacesContext.getCurrentInstance().returnFromDialog(?, null);
    I would like ? to be the EJB entity representing the row, because I need to return the value of more than one of the columns. Is this not realistic, or should I just add then to a List and pass that back?
    thanks
    R

    Thanks KUBA,
    I hacked some code from the inbuilt JDeveloper Help. Are you saying there is an easier way than this, or did I state the question poorly and you gave an answer to something else? My english is not always perfect.
    This is the code that works for me. (cmdSelect is the submit button on the table)
    public String cmdSelect_action() {
    //Access the tableSelectMany1 table. Note that the table name
    //is taken from the id of the table in the JSF page.
    CoreTable table = this.getUserResultsTable();
    //Obtain a list of all selected rows from the table
    Set rowSet = table.getSelectionState().getKeySet();
    Iterator rowSetIter = rowSet.iterator();
    //Use the declarative method to get the ADF bindings
    BindingContainer bindings = getBindings();
    //Get the object to delete. To do this, you must get the
    //iterator binding for the Products in the page definition file,
    //and cast it to DCIteratorBinding for further processing
    DCIteratorBinding pr_dcib = (DCIteratorBinding)
    bindings.get ("queryUserVFindByFullNameIter");
    //Loop through the set of selected row numbers and delete the
    //equivalent object from the Products collection.
    UserV userV = null;
    while (rowSetIter.hasNext()){
    //get the table row
    Key key = (Key) rowSetIter.next();
    //set the current row in the ADF binding to the same row
    pr_dcib.setCurrentRowWithKey(key.toStringFormat(true));
    //Obtain the Products object to delete
    RowImpl prRow = (RowImpl) pr_dcib.getCurrentRow();
    //using the generated code to execute the declarative method
    userV = (UserV)prRow.getDataProvider();
    break;
    AdfFacesContext.getCurrentInstance().returnFromDialog(userV, null);
    return null;
    }

  • Selecting data from two tables

    I am trying to select data from two tables.  The only problem that I am running into, is that i am only seeing results from my 'uploads' table.  there is also a record in documents where user = 1 that should show up.  here is my sql:
    $userIDNum = 1;
    $sql="Select *
    from uploads, documents
    WHERE uploads.user = documents.user AND uploads.user = $userIDNum
    ORDER BY uploads.title ASC, documents.title ASC";

    You'll need to explain a little more about your data and what you are trying to accomplish. Your current sql will select all columns from both the uploads and documents tables but only rows where the user id in both tables match, AND the user id equals 1. Is that not what you are seeing? Where's the code that outputs the results?

  • Error while selecting date from external table

    Hello all,
    I am getting the follwing error while selecting data from external table. Any idea why?
    SQL> CREATE TABLE SE2_EXT (SE_REF_NO VARCHAR2(255),
      2        SE_CUST_ID NUMBER(38),
      3        SE_TRAN_AMT_LCY FLOAT(126),
      4        SE_REVERSAL_MARKER VARCHAR2(255))
      5  ORGANIZATION EXTERNAL (
      6    TYPE ORACLE_LOADER
      7    DEFAULT DIRECTORY ext_tables
      8    ACCESS PARAMETERS (
      9      RECORDS DELIMITED BY NEWLINE
    10      FIELDS TERMINATED BY ','
    11      MISSING FIELD VALUES ARE NULL
    12      (
    13        country_code      CHAR(5),
    14        country_name      CHAR(50),
    15        country_language  CHAR(50)
    16      )
    17    )
    18    LOCATION ('SE2.csv')
    19  )
    20  PARALLEL 5
    21  REJECT LIMIT UNLIMITED;
    Table created.
    SQL> select * from se2_ext;
    SQL> select count(*) from se2_ext;
    select count(*) from se2_ext
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04043: table column not found in external source: SE_REF_NO
    ORA-06512: at "SYS.ORACLE_LOADER", line 19

    It would appear that you external table definition and the external data file data do not match up. Post a few input records so someone can duplicate the problem and determine the fix.
    HTH -- Mark D Powell --

  • How to add the values of all selected columns in a table and display it ?

    Hi all,
    I am using jdeveloper 11.1.1.6.0
    Page:
    my page jsff page contains one ADF table and one textbox
    DB:
    i have two database tables A & B ,
    i need 2 columns from each table . say (A.product_no ,A.product_name,B.prodeuct_price ,B.confirm)
    here product_no is primary key and present in both tables.
    i need to create a VO combining these two tables and put it as ADF table in a jspx page
    Functionality :
    my 'confirm' field is a checkbox field in table . whenever the checkbox is selected,
    the corresponding price will be getting added and display it in a textbox.
    Eg:
    if my first 4 price values are 3000 , 2000 ,4000,2000
    and if i select first 3 values , then the text box should contain 9000 value.
    i need help ...
    Problem:
    i need help in creating VO and functionality part

    Hi,
    it is easy: create an entity object for every table and one view object where you select your both entity objects and join them in your select statement.
    Your desired 'confirm' functionality could be achieved with helpp of view object transient attributes - for more information see: http://docs.oracle.com/cd/E21764_01/web.1111/b31974/bcquerying.htm#CHDHJHBI
    Regards
    Pavol

  • How to bind the data from user table into user report

    Hi All,
      Please assist me to bind the data from user table into user report. I did create an user table with data and create a user report template (using Query Print Layout). How can I display my data into report format which I created before? Any sample program or document I can refer?
    Platform: SAPB1 2005A
    Add On Language: VB.Net 2003
    Thanks.
    rgds
    ERIC

    Hi Ibai,
      Thanks for your feed back. I give you an example.
    Let say now i wanna print employee list, so i will go
    1. Main Menu -> Reports -> HR -> Employee List
    2. Choose the Selection Criteria -> OK
    3. Matrix will display (Employee List)
    4. I can print the report click on print button
    5. Printing report
    My target
    1. Main Menu -> Eric_SubMenu -> Employee List
    2. Matrix will display (Employee List)
    3. Print button
    4. Print report
    My problem
    Now I would like to use my own report format. My own report format means I wanna add on my logo or do some customization within the employee report. So how I am going to do? I only able to display the employee list in matrix. How do I create a new report format and display it.
    Thanks.
    rgds
    ERIC

  • I need below fields at my selection screen.From which table we can find the

    Sales Org > only one selection field
    Division > only one selection field
    Channel > from u2013 to fields
    Sales Office Channel > from u2013 to fields
    Sales Rep Channel > from u2013 to fields
    User ID of the CSR Channel > from u2013 to fields
    Customer Channel > from u2013 to fields
    Material Channel > from u2013 to fields
    Date: Channel > from u2013 to fields
    I need these fields at my selection screen.From which tables I find these things.I need this logic also.

    I need help

  • Select data from two tables...!

    HI Experts...!
    i m a beginner user and i want to select data from two tables proj and prps.....using joins.....and internal tables i have written a code...
    SELECT prps~pspnr
           prps~objnr
           prps~psphi
           proj~ernam
           proj~erdat
           proj~pspnr
    INTO  table itab   -
    itab is internal table
    FROM prps inner join proj
    WHERE pspnr in p_no and prpspsphi = projpspnr.
    but there is error in from clause ..please help me....
    Advance thanx....

    Hi,
    check the sample code bellow above two reply will solve out your problem but one more extra line in your code pointed out bellow.
    TABLES: prps, proj.
    TYPES:  BEGIN OF ty_test,
            pspnr LIKE prps-pspnr,
            objnr LIKE prps-objnr,
            psphi LIKE prps-psphi,
            ernam LIKE proj-ernam,
            erdat LIKE proj-erdat,
            END OF ty_test.
    DATA: itab TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.
    SELECT-OPTIONS: p_no FOR prps-pspnr.
    SELECT  prps~pspnr
            prps~objnr
            prps~psphi
            proj~ernam
            proj~erdat
    *        proj~pspnr " No need for this you have selected this in
    *     the first line because it is commone so you only need to select from any one
            INTO TABLE itab
    FROM prps INNER JOIN proj ON ( prps~pspnr = proj~pspnr  )
    WHERE prps~pspnr IN p_no.
    Best Regards,
    Faisal
    Edited by: Rob Burbank on Dec 24, 2009 12:24 PM

  • How to make validation in Bean and select value from another table

    I want to know how to select data from table in backing bean according to primary key i have
    the problem is that
    i have a table Employee_Salary contains Employee ids and their salary
    Empoloyee_Salary table
         Employee_ID      Number
         Employee_salary Number
    And Another table Called Employees
    Employees table
         Employee_ID     Number
         IsManager Varchar2 its value is [*Yes or NO*]
    and other columns that i don't care about this table
    i have on a jsff page an <af:table> this table is editable this is the Empoloyee_Salary table
    *i want to check before save or after insert if this employee is Manager [from Employees tabke(yes or no)] the salary*
    cannot be less that 100
    i want to know how to make this how to select the value from employees table according to the id i have in the employee_salary table how to make this and make this validation
    i have to select IsManager from Employees Table to see if this manager or no
    i want to know how to make this in a bean
    i use jdeveloper 11g
    and my project is ADF Fusion project
    and the page that have the Emplpyee_Salary table is JSFF
    thanks in advance

    You might want to write this code in a validator on the entity object if it should apply from every screen.
    If you want to access view objects from a backing bean the basics are here: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcservices.htm#sthref918

Maybe you are looking for

  • Problem with emailing pictures

    When emailing pictures from iPhoto using mail they always convert to small format whatever option is selected from actual size to large medium etc. Have checked the original size in iPhoto and there is no problem it is only when they are emailed. Usi

  • Never saw Safari doing this before! Won't display some images !!! *** ??

    So I am using Safari for quite some time. All of a sudden, in the middle of the day, Safari won't display all the images on any given web page. For example, I go to flickr.com and see that half the photos on the page wont load. The status indicator s

  • Calling a frame to return a value

    I have a frame with a JButton. When pressed, a calendar frame I had created will be displayed. A user will select the date from the calendar frame and the value will be returned to the frame where the JButton was pressed. The following is a section o

  • TWO Internal Tables Access

    Hi, I have 2 internal tables with different struc: 1 itab1                                          2. itab2 CID,                                                 CID CEID,                                               CEID Month                      

  • Oracle 9.2 Install on Operating System 2003

    Hi colleague, I have install oracle 9.2 on Windows 2003 release2 but i am facing problem in increase there some parameter which are following. Buffer Cache from 24 to 48 large pool from 08 to 504 db_cache_size from 25165824 to 50331648 when i increas