Query OR Stored Proc to get data from Tables from All Schemas in the d/base

Hello Experts, (I appologize if i am not using the right way to ask questions)
I have a database, and it has around 400 schemas in it. I have designed a query which will fetch the data from three different table's from Schema1.
But it will be a tedious process of entering the 400 schemas names and pulling the information.
I would like to know as to what would be the best possible way to;
1) Look for all the schemas in the database
2) Look for those specific tables in the schema, which has the data in the tables.
3) If the tables are not present, than Ignore that schema and proceed further.
4) Load the data into a table
Any help, would appreciate it.
Thanks!
The query that i am using is as follows;
-- Query to select all the Schemas from the database
select username from all_users
order by username;
-- Sample Query to see if Tables exsist in the schema
SELECT DISTINCT OWNER, OBJECT_NAME
FROM ALL_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'
AND OBJECT_NAME IN ('ENROLLMENT', 'PRDCT', 'L_P_L')
AND OWNER in ('Schema_1', 'Schema_2', Schema_3', Schema_4',Schema_5', Schema_6')
ORDER BY OWNER;
--Query to get the data from the tables in a Schema
select 'Schema_1@DATABASE_NAME' AS SCHEMA,
(SELECT MAX(LOAD_DT) FROM Schema_1.LOAD_STATUS) AS MAX_LOAD,
L_PROD_LINE.PROD_LINE,
COUNT(DISTINCT ENROLLMENT.MEM_NBR) AS MEMBERSHIP
FROM
Schema_1.ENROLLMENT,
Schema_1.PRDCT,
Schema_1.L_P_L
WHERE
ENROLLMENT.PRODUCT_ID = PRDCT.PRODUCT_ID AND
PRODUCT.PROD_LINE_ID = L_P_L.ID
GROUP BY
L_P_L.PROD_LINE;

Hi,
999355 wrote:
Hello Experts, (I appologize if i am not using the right way to ask questions)See the froum FAQ {message:id=9360002}
I have a database, and it has around 400 schemas in it. I have designed a query which will fetch the data from three different table's from Schema1.
But it will be a tedious process of entering the 400 schemas names and pulling the information.
I would like to know as to what would be the best possible way to;
1) Look for all the schemas in the database
2) Look for those specific tables in the schema, which has the data in the tables.
3) If the tables are not present, than Ignore that schema and proceed further.
4) Load the data into a table
Any help, would appreciate it.
Thanks!
The query that i am using is as follows;
-- Query to select all the Schemas from the database
select username from all_users
order by username;
-- Sample Query to see if Tables exsist in the schema
SELECT DISTINCT OWNER, OBJECT_NAME
FROM ALL_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'
AND OBJECT_NAME IN ('ENROLLMENT', 'PRDCT', 'L_P_L')
AND OWNER in ('Schema_1', 'Schema_2', Schema_3', Schema_4',Schema_5', Schema_6')
ORDER BY OWNER; Do you want to give a list of possible schemas (like the 6 above), or do you want to consider all schemas, however many and whatever they are called?
You can get the right information for ALL_OBJECTS, but, since you known all the objects of interest are tables, ALL_TABLES will be faster and simpler.
--Query to get the data from the tables in a Schema
select 'Schema_1@DATABASE_NAME' AS SCHEMA,
(SELECT MAX(LOAD_DT) FROM Schema_1.LOAD_STATUS) AS MAX_LOAD,
L_PROD_LINE.PROD_LINE,
COUNT(DISTINCT ENROLLMENT.MEM_NBR) AS MEMBERSHIP
FROM
Schema_1.ENROLLMENT,
Schema_1.PRDCT,
Schema_1.L_P_L
WHERE
ENROLLMENT.PRODUCT_ID = PRDCT.PRODUCT_ID AND
PRODUCT.PROD_LINE_ID = L_P_L.ID
GROUP BY
L_P_L.PROD_LINE;I take it that the tables in question are ENROLLMENT, PRDCT and L_P_L; they won't have different names in different schemas.
You can start this way:
BEGIN
    FOR  c  IN  (
                      SELECT    owner
              FROM      all_tables
              WHERE     table_name  IN ( 'ENROLLMENT'
                                        , 'PRDCT'
                              , 'L_P_L'
              GROUP BY  owner
              HAVING    COUNT (*) = 3
    LOOP
        ...  -- Now get the results for tables in the c.owner schema
    END LOOP;
END;
/This will find the schemas that have all 3 of those tables.
Inside the loop, write another dynamic query. All that will change is the value of c.owner
Sorry, I'm running out of time now. I hope this helps.

Similar Messages

  • OracleConnection no need to open connection to query a stored proc

    I discovered something I would it strange today. As I was looking at my colleague code, I found that when whe query a stored proc, there's no need to open the connection before the instruction dataAdapter fill.
    here's the example
    Public Function getCodeBiensNi() As List(Of CodeBiensNi)
    Dim CodeBiensNis As New List(Of CodeBiensNi)
    Try
    Dim cursCmd As OracleCommand = New OracleCommand("b240004k.get_bdm_code_biens_ni_2", connection)
    cursCmd.CommandType = CommandType.StoredProcedure
    Dim param0 As New OracleParameter
    param0.OracleDbType = OracleDbType.RefCursor
    param0.Direction = ParameterDirection.ReturnValue
    cursCmd.Parameters.Add(param0)
    Dim da As New OracleDataAdapter(cursCmd)
    Dim ds As New DataSet
    Dim unCodeBiensNi As CodeBiensNi
    da.Fill(ds)
    ' loop through the data set and display each table/row/column
    For Each dt As DataTable In ds.Tables
    For Each dr As DataRow In dt.Rows
    unCodeBiensNi = New CodeBiensNi With {.bcbn_code = dr.Item("bcbn_code"), _
    .bcbn_description = dr.Item("bcbn_description").ToString, _
    .bcbn_date_debut = dr.Item("bcbn_date_debut"), _
    .bcbn_date_fin = dr.Item("bcbn_date_fin")}
    CodeBiensNis.Add(unCodeBiensNi)
    Next
    Next
    ds.Dispose()
    da.Dispose()
    param0.Dispose()
    cursCmd.Dispose()
    Catch ex As Exception
    Throw New Exception("Erreur d'interrogation dans code biens ni. " + ex.Message)
    Finally
    End Try
    Return CodeBiensNis
    End Function
    connection is a private member that has a valid connection string but that's not open. ie. I didn't issue open.
    I even was on debug mode and all the time the state of connection is close.
    Although it work for store proc, it didn't work for simple SQL query. If issue something simple like "select 'toto' from dual", if I don't open the connection it doesn't work, it raise a exception.
    someone know why? I'm just too curious about that. Try to google it but i can't find the right keyword...

    Hi Vishal,
    Get the URL of the document you want to open.
    There are various API/FM  of DMS available for this.
    You can use ACFexecute UI elemnet for opening the document ( lIke PDF, word etc )  with this URL{ Available with NW Ehp 1}.
    or you can try using LinktoUrl element.
    Warm regards,
    Atul

  • Someone is using faebook to run java script to get data and email from me in windows 8

    someone is using faebook to run java script  to get  data  and  email  from  me in  windows  8

    Is this a developer question?
    Jeff Sanders (MSFT)
    @jsandersrocks - Windows Store Developer Solutions
    @WSDevSol
    Getting Started With Windows Azure Mobile Services development?
    Click here
    Getting Started With Windows Phone or Store app development?
    Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

  • How to get name of table from front end

    Hi,
    How to get name of table from front end in EBS 11i?
    thanx
    Ashish

    Hi
    Sandeep is correct. The "Help"/"Record History" will give you the table/view name, but sometimes this particular menu function give me a "Record History is not available here." error message.
    I then use the following menu functions (this will also give you additional information, like column details).
    1) Open Forms
    2) Click on Help/Diagnostics/Examine (*you might have to enter the APPS password at this point)
    3) Change "Block" to "System"
    4) Change "Field" to "Last_query"
    The system will populate the "Value" field with the query that was executed in order to populate the form.
    Regards
    Frank

  • Can a procedure select data from tables on other schemas?

    Can a procedure select data from tables on other schemas?
    If it is posible, which syntax should I use to identify the tables and schemas on the SELECT query?

    Yes , it is possible..unless the current user has the right privileges on others' db objects schema.
    Now , as regards the syntax....
    1) The more descriptive way is to use the format ... <owner_schema>.<obj_name>.
    2) If you have declared public synonyms of other schema's objects then you can refer to them as just <obj.name>.... but the <owner_schema>.<obj_name> is not wrong.
    3) If the db objects reside on another database you must have declared a db link.... then the syntax is <owner_schema>.<obj_name>@<db_link_name>.
    Regards,
    Simon

  • Insert Data into Table from TXT or CSV file !!!!!

    Dear All,
    Recently I have started working on APEX. In Oracle Forms, we used to use TEXT_IO for inserting records into tables from txt files. Now I want to do the same thing in apex 3.2. How can I insert data into tables from txt of csv files.
    Waiting of your valuable suggestions.
    With kind regards,
    Yousuf.

    Yousuf
    wwv_flow_files is used by APEX to hold uploaded files.
    If you incorporate a file browse item on you page, browse for the selected file, then submit the page (having the PL/SQL process described as an on suibmit process) then what I detailed should work.
    If you don't need users to have access to this then just go to Home>Utilities>Data Load/Unload in APEX and there is a handy load utility there that does it all for you.
    Cheers
    Ben

  • Create a View from tables of different schemas

    hi all,
    can u pls give solution to create a View from tables of different schemas.
    i have to bring data from one DB Server A,
    which contains different schemas and tables in the schemas...
    i need to insert that data in another DBServer B.
    i made a procedure for this...
    but when the connection fails from A, then i could not get data...
    please suggest some solution..
    thanks,
    neelima

    I don't know what database system you use, but in the most I know it is done that way:
    SELECT
    A.COL1,A.COL2.....
    FROM
    SCHEMA_NAME.TABLENAME A,
    SCHEMA_NAME.TABLE_NAME B
    WHERE
    A.COL1 = B.COL2
    ...

  • I have windows 8 and I have the most updated version of Itunes, my iphone 4s connects, but nothing plays from my itunes all items have the cloud next to it, and they are dithered out

      I have windows 8 and I have the most updated version of Itunes, my iphone 4s connects, but nothing plays from my itunes all items have the cloud next to it, and they are dithered out

    In the course of your troubleshooting to date, have you worked through the following document?
    No content shows up in iTunes after updating

  • HI, I just bought an iPhone 4S. Although my iPad and other iPhone 3GS connect to our server (SBS2003) I cannot get through.  It checks all items in the connection and then I get the message :Cannot get mail, the connection to the server failed."

    HI, I just bought an iPhone 4S. Although my iPad and other iPhone 3GS connect to our server (SBS2003) I cannot get through.  It checks all items in the connection and then I get the message :Cannot get mail, the connection to the server failed."  I Tried everything, rebooting, reset all iPhone, etc.  All Apple devices work perfectly expect mine.  Please advise

    Look at iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    Additional things to try.
    Turn Off your iPad. Then turn Off (disconnect power cord) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
    On your iPad go to Settings > General > Reset > Reset network settings and see if that enables you to connect.
    If none of the above suggestions work, look at this link.
    iPad Wi-Fi Problems: Comprehensive List of Fixes
    http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
     Cheers, Tom

  • Error in abap query sq03,02,01(to get data from structure) it is possible?

    hi
    experts,
    i am developing a report using abap query .(stand t code is s_alr_87012277 it contain more fields but i want only 4 fields , i found 2 but remaining 2 are from structure)
    my problem is that debit and credit amount is in structure
    how  i can get data from structure(FAGL_S_RFSSLD00_LIST )
    solbm = debit.
    habbm  = credit.
    report is like
    op.
    gl acc no, discription, credit amount,debit amount.

    Hi ajay,
    try to use with  logical database  SDF.
    assign the logical database name in info set.
    gl acc no    -               SKA1-SAKNR
    debit.         -     Field: um02h
    credit.        -     field:  um02s 
    discription  -               SKAT-TXT20
    regards,
    sateesh.

  • Stored proc to pull data from INV/OM/ASCP and load into a user interface

    i'm trying to pull the data from inv, om and ascp into a user interface ? help me write a stored proc to write 3 procedures, with 3 custom tables for the 3 diff source systems i.e., OM/INV/ASCP and also provide these 3 programs in the request set so that when request set is run, it runs the programs one after the other.
    -please help me with a simple step by step process in doing so ?
    Thanks in advance !!
    Edited by: 1003397 on May 20, 2013 3:59 PM

    i'm trying to pull the data from inv, om and ascp into a user interface ? help me write a stored proc to write 3 procedures, with 3 custom tables for the 3 diff source systems i.e., OM/INV/ASCP and also provide these 3 programs in the request set so that when request set is run, it runs the programs one after the other.
    -please help me with a simple step by step process in doing so ?
    Thanks in advance !!
    Edited by: 1003397 on May 20, 2013 3:59 PM

  • To Get List of Tables from Database which has the data 'AAAA' - T-SQL Query

    Hi,
    I have a database "Adventureworks", I need to get list of tables, which has the data 'AAAA' in their rows.
    Is there any optimised or simple way to do this task?
    Any T-SQL Query Available
    --- Thanks in advance..

    You can refer the same below URL provided by Praveen:
    https://gallery.technet.microsoft.com/scriptcenter/c0c57332-8624-48c0-b4c3-5b31fe641c58
    It has the SQL SP - "SP_SearchTables". You can pass parameters the way you want and get the expected output.
    -- Search for 'bike' instead of 'AAAA'
    Use AdventureWorks2012
    EXEC SP_SearchTables @Tablenames = '%', @SearchStr = '%bike%'
    -Vaibhav Chaudhari

  • Want to create RFC FM for Getting data in CRM from R/3

    Hi,
    I have made the RFC connection in CRM system , now I want to make RFC FM for getting data from R/3 'MARD' table into CRM, If any one help me how to do this.
    From CRM system I will pass Plant & material no to FM and I need Storage location & Storage Bin from R/3 MARD table in CRM.
    Thanks
    Bobby

    Dear Bobby,
    You would create a FM in SE37 select 'Remote Enabled Module' radio-button in attributes tab of Function Builder.
    Select matnr werks LGORT LGPBE
               from MARD
               into ET_MARD
               where matnr = i_matnr
               and  werks = i_werks.
    Note:
    matnr is material number
    werks is plant
    LGORT is storage location
    LGPBE is storage bin
    Hope this will help.
    Regards,
    Naveen.

  • Is there a way to get data to and from the hard drive of a Powerbook 180 without having to use the floppy drive?

    Howdy folks!
    I have an 20 year old Powerbook 180 with what I think is an unreliable floppy drive. Sometimes while accessing a diskette the screen flickers and usually power to the whole computer drops out.
    I'm not familiar with Mac connectivity. Is there a way to access the hard drive--to get data off of, and install files, etc onto, the hard drive? 3.5 inch drives are 20th century.
    But... I am happy because my old Powerbook still boots up just fine and I can look at my old files installed on the HD ok.
    Thanks,
    Hayward Matt

    Hi Hayward,
    This may be a power supply issue, not necessarily a problem with the floppy drive itself. Any change if you try removing the battery?
    Would it be correct to assume that it is a plain PowerBook 180 (not 180c)? Which power adapter are you using? It must have a 7.5 DC output, but is it capable of supplying at least 2.0 A?
    Unfortunately it is difficult to remove and connect the (2.5" SCSI) hard drive to a modern computer. Had it been 2.5" IDE, things would have been much easier.
    It is possible to set up a serial null-modem connection from a PowerBook 180 to another computer. See the following discussion for details:
    https://discussions.apple.com/thread/4974860
    If the PB 180 has an internal modem (or an external modem connected to the modem port), you could send files to another modem-equipped computer over the phone lines. With the proper software installed, the PB 180 can even use a dial-up Internet connection.
    Alternatively, another semi-old (pre-1998) Macintosh computer with built-in Ethernet could be used as an intermediary, You could use LocalTalk (or a plain Mac printer cable) for file sharing between the PB 180 and the semi-old Mac (the latter could then forward files over a local network or via the Internet). It is also possible to connect the PB 180 to the semi-old Mac in SCSI disk mode (see the user guide below for additional information).
    manuals.info.apple.com/en_US/0302674APB160180UG.pdf
    Jan

  • Iphone sync is making me crazy how can I get data to and from my iphone without syncing?

    I'm a pc user and i'm sick of the iphone sync process jacking up my life when I decide to reinstall windows and the old itunes data is no longer there. how can I etup my iphone to not have to sync but transfer data to and from it like an android?

    The only way to get data onto the phone is by syncing.  To get some photos off the phone you can connect the phone to the computer with USB cable and use windows explorer to view and copy the photos from the phone to the computer.  You could use a program like ibackupbot or something similar on your computer and get data off the phone to your computer using that

Maybe you are looking for