How to write select query for all the user tables in database

Can any one tell me how to select the columns from all the user tables in a database
Here I had 3columns as input...
1.phone no
2.memberid
3.sub no.
I have to select call time,record,agn from all the tables in a database...all database tables have the same column names but some may have additional columns..
Eg: select call time, record,agn from ah_t_table where phone no= 6186759765,memberid=j34563298
Query has to execute not only for this table but for all user tables in the database..all tables will start with ah_t
I am trying for this query since 30days...
Help me please....any kind of help is appreciated.....

Hi,
user13113704 wrote:
... i need to include the symbol (') for the numbers(values) to get selected..
eg: phone no= '6284056879'To include a single-quote in a string literal, use 2 or them in a row, as shown below.
Starting in Oracle 10, you can also use Q-notation:
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#i42617
...and also can you tell me how to execute the output of this script. What front end are you using? If it's SQL*Plus, then you can SPOOL the query to a file, and then execute that file, like this:
-- Suppress SQL*Plus features that interfere with raw output
SET     FEEDBACK     OFF
SET     PAGESIZE     0
-- Run preliminary query to generate main query
SPOOL     c:\my_sql_dir\all_ah_t.sql
SELECT       'select call time, record, agn from '
||       owner
||       '.'
||       table_name
||       ' where phone_no = ''6186759765'' and memberid = j34563298'
||       CASE
           WHEN ROW_NUMBER () OVER ( ORDER BY  owner          DESC
                          ,        table_name      DESC
                          ) = 1
           THEN  ';'
           ELSE  ' UNION ALL'
       END     AS txt
FROM       all_tables
WHERE       SUBSTR (table_name, 1, 4)     = 'AH_T'
ORDER BY  owner
,       table_name
SPOOL     OFF
-- Restore SQL*Plus features that interfere with raw output (if desired)
SET     FEEDBACK     ON
SET     PAGESIZE     50
-- Run main query:
@c:\my_sql_dir\all_ah_t.sql
so that i form a temporary view for this script as a table(or store the result in a temp table) and my problem will be solved..Sorry, I don't understand. What is a "temporary view"?

Similar Messages

  • How to write selection Query for the following requirment.

    Hi All,
    I am new to ABAP, I need a help ,
    I need to select all plants(WERKS) from MARC at Plant/Material level,
    then I need to take all sales organozation(VKORG) from T001w,
    then I need the company code(BUKRS) from TVKO based on VKORG,
    then I need the currency key(WAERS) from T001 based on BUKRS,
    Can any one help me in writing selection Query for the same?
    Thanks All,
    Debrup.

    Hi,
    Its easy for you if you learn SELECT with JOIN to complete your task. So SEARCH the forum with SELECT statement and you will get a lot of examples using which you can write your own.
    If you struck up anywhere revert back.
    Regards
    Karthik D

  • How  to write select query for this

    Hi,
    I had a html form and in the for i had drop down box and it needs to select multiple values from the drop down box. When i select multiple values then i have to write the SQL select statement  query .
    When i try to write the select statement and trying to run i am getting error.
    select * from Table
    where emo_no = '1,2,3'
    this is how i write query please suggest me how  to write query for selecting multiple values from the drop down box.
    Thanks

    select * from Table
    where emo_no in ( 1,2,3)
    for integer values
    select * from Table
    where emo_no in ('1','2','3')
    for characters
    If we talk about large scale applications that may have millions of records, I would suggest this.
    declare @t table (v int)
    insert into t (v) values (1)
    insert into t (v) valves (2)
    insert into t (v) values (3)
    select *
    from table
         inner join @t t on table.emo_no = t.v
    Using "in" for a where clause is not so bad for filtering on a few values, but if you are filtering a lot of rows and a lot of values (emo_no) the performance degrades quickly for some reasons beyond the scope of this.
    This is just one solution, I'll through this out as well, instead of an in memory (@t) table, doing a disk based temp table (#t) and creating an index on the column "v".
    create table #t (v int)
    insert into #t (v) values (1)
    insert into #t (v) valves (2)
    insert into #t (v) values (3)
    create index ix_t on #t (v)
    select *
    from table
         inner join #t t on table.emo_no = t.v
    drop table #t
    Pardon any syntax errors and careful using a drop statement.
    Sometimes in memory tables work better than disk temp tables, it takes some testing and trial and error depending on your datasets to determine the best solution.
    Probably too much info  ;-)
    Byron Mann
    [email protected]
    [email protected]
    Software Architect
    hosting.com | hostmysite.com
    http://www.hostmysite.com/?utm_source=bb

  • How to write select query for below requirement

    Hi sir,
    i have a table x have one column y which containing value like below
    Y
    a
    b
    c
    d
    I want out put like below  kindly help me:
    Y
    a
    d
    c
    b

    Hi ,
    Please check:
    select y from (
    select case when y='a' then 1 else 2 end no, y from table_x
    ) order by no asc, y desc
    with table_x as(
    select 'a' y
      from dual
    union  
    select 'b' y
      from dual
    union 
      select 'c' y
      from dual
    union  
      select 'd' y
      from dual
    select y from (
    select case when y='a' then 1 else 2 end no, y from table_x
    ) order by no asc, y desc
    Thank you

  • How to write sql query for counting pairs from below table??

    Below is my SQL table structure.
    user_id | Name | join_side | left_leg | right_leg | Parent_id
    100001 Tinku Left 100002 100003 0
    100002 Harish Left 100004 100005 100001
    100003 Gorav Right 100006 100007 100001
    100004 Prince Left 100008 NULL 100002
    100005 Ajay Right NULL NULL 100002
    100006 Simran Left NULL NULL 100003
    100007 Raman Right NULL NULL 100003
    100008 Vijay Left NULL NULL 100004
    It is a binary table structure.. Every user has to add two per id under him, one is left_leg and second is right_leg... Parent_id is under which user current user is added.. Hope you will be understand..
    I have to write sql query for counting pairs under id "100001". i know there will be important role of parent_id for counting pairs. * what is pair( suppose if any user contains  both left_leg and right_leg id, then it is called pair.)
    I know there are three pairs under id "100001" :-
    1.  100002 and 100003
    2.  100004 and 100005
    3.  100006 and 100007
        100008 will not be counted as pair because it does not have right leg..
     But i dont know how to write sql query for this... Any help will be appreciated... This is my college project... And tommorow is the last date of submission.... Hope anyone will help me...
    Suppose i have to count pair for id '100002'. Then there is only one pair under id '100002'. i.e 100004 and 100005

    Sounds like this to me
    DECLARE @ID int
    SET @ID = 100001--your passed value
    SELECT left_leg,right_leg
    FROM table
    WHERE (user_id = @ID
    OR parent_id = @ID)
    AND left_leg IS NOT NULL
    AND right_leg IS NOT NULL
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to write Select statement for this codition

    I need to check whether SGTXT contains BELNR value.
    SGTXT is a text field and It should be matched with BELNR
    How to write select statement for this.
    Select AUGBL AUGDT into t_BSAD
    from BSAD
    where SGTXT should have the given BELNR Value.
    Plz note : Here I cannot give as SGTXT = BELNR as coz BELNR have only 10 digits.

    Hi,
    data temp(12).
    concatenate '%' belnr '%' into temp.
    Select AUGBL AUGDT into t_BSAD
    from BSAD
    where SGTXT like temp.
    If belnr is having multiple values,just create a internal table as follows.
    types : begin of ty,
            belnr....
            temp(12),
            end of ty.
    data itab_ type standard table of ty.
    data wa type ty.
    loop at itab into wa.
    concatenate '%' wa-belnr '%' into wa-temp.
    modify itab from wa index sy-tabix transporting temp.
    endloop.
    Change your select statement accordingly.
    Kindly reward poits if it helps.

  • Query regarding the fields details in particular form for all the users in

    Dear All,
                  I have one query regarding the fields details in particular form for all the users in company.
    Let take an exapmle if i had created Purchase Order having fields in content tab as 1.Item No. 2.Quantity 3.Unit Proce   4.Total   5. Location.
    While Login in User manager i set these fields only for Purchase order , but when i login from other user and open the similar purchase order the defaults fields are also seen including  above 4 fieds .
    Now my question is how to set the User choice fiels for the particular form that are common to all users.
    Means whenever i login in any user and opens the same document the same fields should be seen....Thanksssss.........

    You have to login with each and every user and do the Form Settings of every forms, so that all the forms look same for all the users.
    This is a manual job and you have do do it with every user login.
    Alternately, you can try out this link that explains
    [How to Copy One Screen Layout to Another User|http://www.sbonotes.com/2008/03/how-to-copy-one-screen-layout-to.html]

  • How to set up same timezone in BI Publisher for all the USERS?

    Hi Experts,
    My OBIEE version is 11.1.1.6.6  and any user can go into the My Account and then preferences  and set the timezone.
    But as an admin, i see they are too many users and wanted to setup common timezone for all of them.
    How do i setup common timezone in BI Publisher for all the users?
    Thanks
    Ashish

    Check
    Time Zone Specification from http://docs.oracle.com/cd/E12844_01/doc/bip.1013/e12187/T421739T481157.htm#4535403
    just in case https://blogs.oracle.com/xmlpublisher/entry/how_to_keep_your_dates_from_go

  • How create LOV(select List) with all LDAP users

    Hello,
    I am trying to create a selected list with all the users in my LDAP, note my LDAP is synchronized with my OID.
    Any suggestions, I'm searching the the pl/sql statment?
    Thanks
    Hussam

    Hi Hussam,
    Take a look at my comments in the following two threads -
    Re: LDAP
    Re: Cookie And LDAP
    The two different threads discuss the methods I use to do what you want to do (so you really need to 'combine' the two different threads).
    Hope this helps

  • How to write a Query for the mentioned scenario.

    Hi All,
    Table A
    ID|| Start_Date||End_date||Rate
    1||01-Jan-2011||31-Mar-2011||0.8
    1||01-Apr-2011||31-Jun-2011||0.9
    I have a table like above. I want to write a query to display the result as below.
    ID|| Start_Date||Rate
    1||01-Jan-2011||0.8
    1||01-Feb-2011||0.8
    1||01-Mar-2011||0.8
    1||01-Apr-2011||0.9
    1||01-May-2011||0.9
    1||01-Jun-2011||0.9
    Kindly help.
    Thanks!
    GJ

    Try to read link mentioned by SB. It will make you more interactive to share your problems. And immediate reply too from experts.
    Check your solution below.
    SQL> ed
    Wrote file afiedt.buf
      1  WITH data1 AS
      2  (
      3  SELECT 1 id, TO_DATE('01-Jan-2011' , 'DD-Mon-YYYY') stdt,TO_DATE('31-Mar-2011' , 'DD-Mon-YYYY') endt, 0.8 rate FROM dual
      4  UNION ALL
      5  SELECT 1 id, TO_DATE('01-Apr-2011' , 'DD-Mon-YYYY') stdt,TO_DATE('30-Jun-2011' , 'DD-Mon-YYYY') endt, 0.9 rate FROM dual
      6  )
      7  SELECT id, ADD_MONTHS(stdt, level -1) st_dt, rate FROM data1
      8  CONNECT BY  level <= ROUND(MONTHS_BETWEEN(endt,stdt))
      9  AND rate= prior rate  /* stick to current line */
    10* AND prior sys_guid() IS NOT NULL  /* used to terminate the connect by loop */
    SQL> /
            ID ST_DT           RATE
             1 01-JAN-11         .8
             1 01-FEB-11         .8
             1 01-MAR-11         .8
             1 01-APR-11         .9
             1 01-MAY-11         .9
             1 01-JUN-11         .9
    6 rows selected.Thanks!
    Ashutosh
    Edited by: Ashu_Neo on Oct 8, 2012 11:57 AM

  • How to write a query for the following issue

    Hello,
    I would like to write a query to display the result in the following format 
    Item
    Categort1
    Categort2
    Categort3
    Categort4
    Categort5
    Categort6
    Min
    Max
    Avg
    Min
    Max
    Avg
    Min
    Max
    Avg
    Min
    Max
    Avg
    Min
    Max
    Avg
    Min
    Max
    Avg
    01
    02
    03
    04
    For every item for the category i need to find Min,Max and Avg from the Value column
    Table structure is as follows
    ID
    Item Id
    Item
    Category
    value
    1
    01
    A
    Categort1
    1
    2
    01
    A
    Categort1
    2
    3
    01
    A
    Categort1
    3
    4
    02
    B
    Categort2
    7
    5
    02
    B
    Categort2
    8
    6
    03
    C
    Categort3
    6
    7
    04
    D
    Categort4
    12
    8
    04
    D
    Categort4
    14

    SELECT ItemID,
    MIN(CASE WHEN Category = 'Categort1' THEN value END) AS Min_category1,
    MAX(CASE WHEN Category = 'Categort1' THEN value END) AS Max_category1,
    AVG(CASE WHEN Category = 'Categort1' THEN value END) AS Avg_category1,
    MIN(CASE WHEN Category = 'Categort2' THEN value END) AS Min_category2,
    MAX(CASE WHEN Category = 'Categort2' THEN value END) AS Max_category2,
    AVG(CASE WHEN Category = 'Categort2' THEN value END) AS Avg_category2,
    MIN(CASE WHEN Category = 'Categort6' THEN value END) AS Min_category6,
    MAX(CASE WHEN Category = 'Categort6' THEN value END) AS Max_category6,
    AVG(CASE WHEN Category = 'Categort6' THEN value END) AS Avg_category6
    FROM Table
    GROUP BY ItemID
    The format can be achieved using tools like SSRS
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to write a procedure for update the table

    Hi all
    can any body please tell me how to write a procedure to update the table......
    I have a table with about 10,000 records...........Now I have add a new column and I want to add values for that like
    registration Code Creidits
    13213 BBA
    1232 MCS
    I had add the creidit now i want to update the table.........the new value want to get by SQL like
    Creidit = select creidit from othere_table...........
    Hope u can understand my problem
    Thanks in advance
    Regards
    Shayan
    [email protected]

    Please try the following --
    update Program_reg a
    set TotalCreidit = ( select tot_cr <Accroding to your logic>
                                from Program_reg b
                                where a.Registration = b.Registration
                                and    a.Enrollment = b.Enrollment
                                and    a.code = b.code
    where a.Registration in ( select distinct Registration
                                        from Program_reg );
    N.B.: Not Tested....
    Regards.
    Satyaki De.

  • Select query 'for all entries'

    Hello Friends,
           SELECT emp_id emp_name
           INTO corresponding fields of table itab_emp
           FROM employee
           for all entries in itab_dept
           WHERE emp_id = itab_dept_emp_id.
    In the above select query we are using 'for all entries' for the internal table itab_dept.What will happen if the join fails?Will we get any data in the output table?
    What is the prerequisites for using 'for all entries'.
    Please advice me on this.
    Regards
    Ashish.

    Hi
    In this case all the records available in employee table are extracted into internal table itab_emp.
    It is safe to check whether itab_dept is initial or not.
    If it is initial then stop the select query.
    Check the following program u will get an idea.
    Also try this program by removing comment to 'REFRESH IT_LFA1'.
    REPORT  ZBM_PG                                  .
    TABLES: LFA1, EKKO.
    DATA:
         IT_LFA1 TYPE TABLE OF LFA1 WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 10,
          IT_LFA1 TYPE TABLE OF LFA1 WITH HEADER LINE,
          IT_EKKO TYPE TABLE OF EKKO WITH HEADER LINE.
    SELECT * FROM LFA1 INTO TABLE IT_LFA1 WHERE LIFNR EQ '0000001000' OR LIFNR EQ '0000001500'.
    SELECT * FROM LFA1 INTO TABLE IT_LFA1 UP TO 1 ROWS.
    refresh it_lfa1.
    SELECT * FROM EKKO INTO TABLE IT_EKKO FOR ALL ENTRIES IN IT_LFA1 WHERE LIFNR = IT_LFA1-LIFNR.
    LOOP AT IT_EKKO.
      WRITE: / IT_EKKO-LIFNR, IT_EKKO-EBELN.
    ENDLOOP.
    Reward me if it is useful

  • How to write sql query for below mentioned eaxmple.

    Hi,
    I have requirement.
    There are number of rows and I need the result through query as follows.Please help me to proved sql query for below mentioned requirement.
    example: table TEST.
    COLA COLB COLC COLD COLE COLF MANAGER 5 NULL NULL 3 NULL
    SR.MANAGER 6 3 NULL NULL NULL
    VP 5 5 4 5 5
    I have to write the sql query if COLA IS MANAGER THEN CONSIDER MANGER RECORD,AND IF ANY COLUMN FILED IS NULL FOR MANGER THEN CONSIDER COLA IS SR.MANGER, AND IF ANY COLUMN FILED IS NULL FOR SR,MANGER THEN CONSIDER VP records.
    I need output as below.
    COLB COLC COLD COLE COLF
    5(manager) 3(sr.manger) 4(vp) 3(manger) 3(vp)
    Please provide the for above mentioned output.
    Thanks

    Duplicate thread. please view the answer posted in your first thread.
    how to write sql query.
    And, please don't post any duplicate thread.
    Regards.
    Satyaki De.

  • Custom CSS-Applying selected background for all the cols in the report

    Hi,
    I am trying to set a particular background for all the columns in the report(not for all the projects,so that I can avoid option of manually setting background color for complete report.For this I thought custom CSS is best option.So edited custom.css(C:\OBI11g_Middleware\Oracle_BI1\bifoundation\web\app\res\s_blafp\b_mozilla_4) file with below code and went to the Answers-> Criteria->Choose Column->style-> check "Use Custom CSS Class"->MyCell
    Code used in custom.css
    .MyCell { background-color: #00ff00; font-style:italic; font-weight: bold;}
    Somehow I dont see the background color applied to any of the columns in report.Can anyone had successful attempt of this Custom CSS.Thanks in Advance.

    I am trying both the solutions.
    User 979493,
    I started manually writing the code instead of pasting and almost worked.In the mentioned below paths I dont have custom.css file,so I created one and manually entered below code.But does it work for only that particular column and not for all the columns.Is it supposed to work for all the columns or just that column.
    For example: I have 2 cols in the report,I used "Use Custom CSS Class" -> MyCell for the first column and when I ran results it shows background color for only col1 and not for col2.I thought this feature will apply background color for all the columns in the report.Please correct me if I am wrong.
    custom.css file content:
    .MyCell{background-color: #00ff00;font-style:italic;font-weight:bold;}

Maybe you are looking for

  • If my iPhone is set up with a different apple ID than my itunes library, how do I add music onto my phone?

    I recently got an iPhone 4, and I set up an Apple ID of my own. I would like to put music on my phone, but all of my music is under another Apple ID and it won't let me add music from that account onto my phone. How do I add the music I would like?

  • Windows 8.1 Error 0xC1900101 – 0x40017

    I have an HP Envy DV7 7200 quad series notebook and have been trying to upgrade to Win 8.1.  I keep encountering an error (0xC1900101 – 0x40017) as the upgrade is finalizing PC settings.  Ultimately I get a BSOD and the OS reverts back to Win 8.  Mul

  • CVD and Excise Register Update for Free of charge Imported Material

    Hi, This is a scenario of Import Purchasing of Free Goods for which no price is paid to the Vendor. But the Custom and CVD Payment need to be made and we want to take benefit of CVD duties and update the Excise Register. Can anyone provide some idea

  • How to use multi prompts using java script in FF3.0*

    Hey i used the java script given in link :- http://sranka.wordpress.com/2008/11/09/how-to-replace-multi-go-button-prompt-by-one/#comment-96 to hide multi-go-button in prompts and it works for IE 7 and firefox 2.0* with 10.3.4.1. Now since 10.1.3.4.1

  • UPDATING the query in materialized view

    Hi, i have a little doubt in Materialized view. i created a materialized view and log with the following query, create table test_mv (a number ,b number ) alter table test_mv add constraint t_pk primary key ( a ); insert into test_mv values (1,2); in