Returning operation, table and column from a sql query

Hi,
I am working on Oracle 10g and i have to do achieve something like this.
i have to create procedure or functions which will accept a SQL query and will return following :
1).  Operation like 'SELECT', 'INSERT', 'UPDATE', 'DELETE' etc.
2).  Column names
3).  Table involved.
One way to achieve this would be through hard parsing of string which might be time consuming. So do we have any in-built oracle package or function for the same job ?
Regards,
Vikas Kumar

Check for DBMS_SQL package and DESCRIBE_COLUMNS procedure in that package.
You might need a combination of this package and Hard parsing of the input string.
For operation you can trim any space and brackets using TRIM function and then you can extrcat first 6 characters using SUBSTR for Operation.
I have not worked or used DBMS_SQL so wont be able to help you much on this.
Here is the link for DBMS_SQL
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm#i1026120
Regards
Arun

Similar Messages

  • Can we hide the tables and columns from subject areas in the front end

    Hi,
    Is there any way to hide the tables and columns from the subject area in front end.I need to create a report with some tables which the user does not want to see.So after creating the reprot can I hide those tables and columns in the front end

    Hi,
    Your question is not that clear to me...do you want to hide the entire table/column that dont want to show up in the front end then you could do in Presneation Layer in the RPD by going Permissions in the property of that object.
    But if you want to hide the column in the report that can be visible in the subject Area: go to column properties -> Column fomat...thereis Hide option.
    Can you please elaborate your question...what exactly you are looking for...
    --SK                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Chart not getting columns from the SQL Query with InlineTransform(xsl)

    Hi All,
    I am using MII 12.0 . I tried to use the mii standard xsl for converting rows into columns by  Inline Transform in a SQL Query.
    while executing the Query it is giving me the correct output but i tried to load the same Query in a IChart there it is not showing me the available columns that i can able to see in simple executiion and chart is also not plotting it keeps on loading.
    Thanks in Advance.

    Hi LinoVaz,
    Some things to try for testing purposes -
    1. Don't do any Data Mapping of the query columns
    2. If a SQL Query, you may need to change the Server Scaling to use Global AutoScale.
    I found that when I mapped the inline-transformed query into a bar chart display template, and hit the Refresh button, only the first column name show in the Column Names area.  If I mapped it, I got only that column.  If I didn't map any columns, I got them all.
    Let me know if you find similar results.  I think this is likely a bug, so you may consider using a Business Logic Transaction and an XacuteQuery to accomplish the same result.
    Kind Regards,
    Diana Hoppe
    Edited by: Diana Hoppe on Mar 25, 2011 11:46 AM

  • Parse SQL query and extract source tables and columns

    Hello,
    I have a set of SQL queries and I have to extract the source tables and columns from them.
    For example:
    Let's imagine that we have two tables
    CREATE TABLE T1 (col1 number, col2 number, col3 number)
    CREATE TABLE T2 (col1 number, col2 number, col3 number)
    We have the following query:
    SELECT
    T1.col1,
    T1.col2 + T1.col3 as field2
    FROM T1 INNER JOIN T2 ON T1.col2=T2.col2
    WHERE T2.col1 = 1
    So, as a result I would like to have:
    Order Table Column
    1 T1 col1
    2 T1 col2
    2 T1 col3
    Optionally, I would like to have a list of all dependency columns (columns used in "ON", "WHERE" and "GROUP BY" clauses:
    Table Column
    T1 col2
    T2 col1
    T2 col2
    I have tried different approaches but without any success. Any help is appreciated. Thank you in advance.
    Best regards,
    Beroetz

    I have a set of SQL queries and I have to extract the source tables and columns from them. In a recent db version you can use Re: sql injection question for this.

  • Sql query parsing (retrieve tables and columns used in query)

    Hi,
    1. Is there any view in Oracle which can tell me, which tables and columns were used in the last ran query, no matter how complex the query is.
    2. Secondly I can get table names, used in stored procedures and views, using USER_DEPENDENCIES VIEW, however this System View does not return column names, used in that procedure / view, any idea please .
    Thanks and Regards,
    Luqman

    luqman123 wrote:
    Hi,
    1. Is there any view in Oracle which can tell me, which tables and columns were used in the last ran query, no matter how complex the query is.I don't believe so. You can look at V$SQL and retrieve the actual SQL text from there.
    2. Secondly I can get table names, used in stored procedures and views, using USER_DEPENDENCIES VIEW, however this System View does not return column names, used in that procedure / view, any idea please .Oracle added fine grained dependency tracking in 11g, but didn't expose any views to query this information. However, it has been reverse engineered a bit: About Oracle: DBA_DEPENDENCY_COLUMNS

  • SQL text parsing to obtains referenced tables and columns

    I wonder if anyone has a method of scanning an SQL statement to retrieve tables and columns referenced. EG:
    select
    f.cola, f.colb, f.colc, b.cold
    from
    foo f, bar b
    where
    f.cola=b.cola and f.colb=b.colb
    order by f.colz, b.colawould provide
    Tables
    foo
    bar
    Columns
    foo.cola [SELECT] [WHERE]
    foo.colb [SELECT] [WHERE]
    foo.colc [SELECT]
    foo.colz [ORDER BY]
    bar.cola [WHERE] [ORDER BY]
    bar.colb [WHERE]
    bar.cold [SELECT]The reason is that I'd like to query through several SQL scripts and validate tables and columns in a new version of the ERP system exist

    That query with date substitution should also work. Are you seeing some errors?
    SQL> explain plan for select * from scott.emp where hiredate = to_date(':some_date', 'dd-mon-yyyy') ;
    Explained.
    SQL> @utlxpls
    PLAN_TABLE_OUTPUT
    | Id  | Operation            |  Name       | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT     |             |     1 |    40 |     2 |
    |*  1 |  TABLE ACCESS FULL   | EMP         |     1 |    40 |     2 |
    Predicate Information (identified by operation id):
       1 - filter("EMP"."HIREDATE"=TO_DATE(':some_date','dd-mon-yyyy'))
    Note: cpu costing is off
    14 rows selected.
    SQL>

  • Parse SQL: How to extract column names, table names from a SQL query

    Hi all,
    I have a requirement wherein a SQL query will be given in a text file.
    The text file has to be read (probably using text_io package), the SQL query needs to be parsed and the column names, table names and where clauses have to be extracted and inserted into separate tables.
    Is there a way to do it using PL/SQL ?
    Is there a PL/SQL script available to parse and extract column names, table names etc ?
    Pls help.
    Regards,
    Sam

    I think I jumped to conclusion too early saying it is completely possible and straight forward. But after reading through your post for one more time I realised you are not interested only in the column_names, also the table_names and the predicates .
    >
    SQL query needs to be parsed and the column names
    >
    The above is possible and straight forward using the dbms_sql package.
    I am pasting the same information as I did in the other forum.
    Check this link and search for Example 8 and .
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sql.htm#sthref6136
    Also check the working example from asktom
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1035431863958
    >
    table names and where clauses have to be extracted
    >
    Now this is the tricky bit. You can extract the list of tables by getting the sql_id from v$sql and joining it with v$sql_plan. But sometimes you may not get all the results because the optimizer may choose to refine your query (check this link)
    http://optimizermagic.blogspot.com/2008/06/why-are-some-of-tables-in-my-query.html
    and you can get the predicate information from the same table v$sql_plan but I will leave that area for you to do some R&D.
    Regards
    Raj
    Edited by: R.Subramanian on Dec 10, 2008 3:14 AM

  • Tables and Columns used in Universe (BO 6.5)

    Hi All,
    Please help me out with the below queries:
    1. Is there any automated way to find out which report is using which universe? (may be through a SQL fired in BO repository)
    (Note: As per the BO Documentation, OBJ_X_DOCUMENTS This is the only table in the document domain. It stores the binary content of all documents sent to the repository (through the user actions Publish to corporate documents, Send to users or Send to Broadcast Agent). The document contents are stored as BLOBs (Binary Large Objects) stored in slices.)
    2. I need to identify the universes which use certain tables and columns.
    I fired the following SQL in BO repository:
    SELECT
    UNV_UNIVERSE.UNI_FILENAME,
    UNV_UNIVERSE.UNI_LONGNAME,
    UNV_TABLE.TAB_NAME,
    UNV_COLUMNS.COLUMN_NAME
    FROM UNV_UNIVERSE, UNV_TABLE,UNV_COLUMNS
    WHERE
    UNV_UNIVERSE.UNIVERSE_ID = UNV_TABLE.UNIVERSE_ID
    AND UNV_TABLE.TABLE_ID = UNV_COLUMNS.TABLE_ID
    But as 'UNV_COLUMNS' table is empty, no data is returned. My question is is this table supposed to be empty in BO repository?
    Is there any other way to find out this (identify the universes which use certain tables and columns)?
    Many Thanks & Regards,
    Sandeep

    Hi,
    Please find the below list of tables created in the BO repository, which helps you to retrieve the information related to reports, universes, users e.t.c.
    OBJ_M_ACTOR
    OBJ_M_ACTORDOC
    OBJ_M_ACTORLINK
    OBJ_M_CATEG
    OBJ_M_CONNECTDATA
    OBJ_M_CONNECTION
    OBJ_M_DOCAT
    OBJ_M_DOCATVAR
    OBJ_M_DOCCATEG
    OBJ_M_DOCCST
    OBJ_M_DOCUMENTS
    OBJ_M_GENPAR
    OBJ_M_MAGICID
    OBJ_M_OBJSLICE
    OBJ_M_REPOSITORY
    OBJ_M_RESERVATION
    OBJ_M_RESLINK
    OBJ_M_TIMESTAMP
    OBJ_M_UNIVCST
    OBJ_M_UNIVDBCST
    OBJ_M_UNIVERSES
    OBJ_M_UNIVSLC
    OBJ_M_USRATTR
    OBJ_X_DOCUMENTS
    UNV_AUDIT
    UNV_CLASS
    UNV_CLASS_DATA
    UNV_COLUMNS
    UNV_COLUMN_DATA
    UNV_CONTEXT
    UNV_CONTEXT_DATA
    UNV_CTX_JOIN
    UNV_DIMENSION
    UNV_DIM_OBJ
    UNV_JOIN
    UNV_JOINCONTENT
    UNV_JOIN_DATA
    UNV_JOIN_OBJECT
    UNV_OBJCONTENT
    UNV_OBJECT
    UNV_OBJECT_DATA
    UNV_OBJECT_KEY
    UNV_OBJ_COLUMN
    UNV_OBJ_TAB
    UNV_PROPERTY
    UNV_PROP_DATA
    UNV_PROP_TAB
    UNV_RELATIONS
    UNV_TABLE
    UNV_TABLE_DATA
    UNV_TAB_OBJ
    UNV_TAB_PROP
    UNV_UNIVERSE
    UNV_UNIVERSE_DATA
    UNV_X_UNIVERSES
    Hope this tables helps you.

  • Get description of tables and columns

    Good afternoon.
    Is there any option in SAP B1 to get a description of table and column dynamically? That is, without the "Tools -> Queries -> Query Generator"?
    I am developing an add-on, which lists all the tables and columns of the sap, and I have to bring the descriptions automatically. If you do not have to get the SDK route descriptions, as you suggest doing this?
    Edited by: Harley Rodrigues on Feb 1, 2012 9:38 PM

    Hi Harley,
    Welcome to the Forum!
    please refer to your SDK Help. you can find it from this path C:\Program Files\SAP\SAP Business One SDK\Help
    also alternatively you can view it from your MS SQL Server Management under Databases
    regards,
    Fidel

  • Table and columns separation  in string

    Hi,
    I am having one column data containing combining table and column names like
    act_hand_table.work_order
    i want seperate table and column names
    i want separte . filed
    Please help me
    Regards,
    Kiran

    Kiran Bathula wrote:
    Hi,
    I am having one column data containing combining table and column names like
    act_hand_table.work_order
    i want seperate table and column names
    i want separte . filed
    Please help me
    Regards,
    KiranTry
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2  (select 'act_hand_table.work_order' col from dual)
      3* select substr(col,1,instr(col,'.',1)-1)tbl,substr(col,instr(col,'.',1)+1) from t
    SQL> /
    TBL            SUBSTR(COL
    act_hand_table work_orderHope this helps
    Regards,
    Achyut

  • Can Verity/Solr index files AND columns from db into one resultset?

    Hi,
    I have a form where users upload a document and also add some meta data that goes with the document.  I currently store the meta data in the db and the actual document on the file system.
    How can I use Verity/Solr to index files and columns from a database table so it will return one recordset?
    -ws

    <cfindex type="file"> should do the trick, shouldn't it?
    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d 04.html
    Adam

  • Data in multiple tables and columns

    Hi,
    How to find if multiple tables are containing the same data?
    'Apple' text is in three different tables and under three different column names.
    Expected result
    fruits_one
    fruits_two
    fruits_three
    Select name, quantity from fruits_one;
    Apple   1
    Orange  1
    Pear    1
    select flavour, desc from fruits_two;
    Red,   Apple
    Blue, Berry
    select order,date,details  from fruits_three;
    101  11/11/2011    Grapes
    102  12/01/2010    AppleThanks
    Sandy

    SQL> create table fruits_one (name varchar2(100), quantity number);
    Table created.
    SQL> insert into fruits_one
      2  select 'Apple'  name, 1 quantity from dual union all
      3  select 'orange'  name, 1 quantity from dual;
    2 rows created.
    SQL> commit;
    Commit complete.
    SQL> create table fruits_two (flavour varchar2(100), des varchar2(100));
    Table created.
    SQL> insert into fruits_two
      2  select 'Red' flavour,   'Apple' des  from dual union all
      3  select 'blue' , 'berry'  from dual ;
    2 rows created.
    SQL> commit;
    Commit complete.
    SQL> set serveroutput on
    SQL> declare
      2  l_search varchar2(10) := 'APPLE';
      3  l_cnt number := 0;
      4  begin
      5 
      6  for x in (select column_name, data_type, table_name from user_tab_cols where data_type in ('VAR
    CHAR2'))
      7  loop
      8     
      9    execute immediate  'select count(*) from "' || x.table_name ||'" where upper("' || x.column_n
    ame || '") like ''%' || l_search || '%''' into l_cnt;
    10   
    11    if l_cnt > 0  then
    12    dbms_output.put_line('table = "' || x.table_name ||'", column = "' || x.column_name ||'"');
    13    end if;
    14   
    15  end loop;
    16 
    17  end;
    18  /
    table = "FRUITS_ONE", column = "NAME"
    table = "FRUITS_TWO", column = "DES"
    PL/SQL procedure successfully completed.
    SQL>

  • Capture DB Table and column comments when creating new Business Area/Folder

    Does anyone know if it is possible to pull the DB table and column comments into Discoverer when creating new Business Area/Folders? Our developers take the time to put the information in the Db data dictionary and we would like to leverage it (reduce need for manually adding descriptions) ... has anyone done this?
    If there isn't a way to automatically do it, would there be any harm in using a sql script to populate the description fields from the DB data dictionary directly into the EUL tables appropriate?
    I have been searching through documentation and forums for information - with no luck at this point.
    Thanks!

    Hi Seymour
    You can add column comments to views as well, as this example will show:
    CREATE OR REPLACE FORCE VIEW MY_SEQUENCE
    (SEQ_ID, SEQ_NAME, SEQ_NEXTVAL)
    AS
    SELECT "SEQ_ID","SEQ_NAME","SEQ_NEXTVAL" FROM EUL5_SEQUENCES;
    COMMENT ON COLUMN MY_SEQUENCE.SEQ_NAME IS 'The sequence';
    So you could add the comments at the view level and then refresh Discoverer.
    Best wishes
    Michael

  • List tables and column names a stored procedure is querying

    Hello,
    Is there a way to list tables and column names that a stored procedure is querying, i.e, selecting from, using T-SQL?  If yes, is there a way to also show data types for the columns that a stored procedure is querying, i.e, selecting from?
    Thank you,  
    Lenfinkel

    One way to view the dependencies of an object is to use SSMS; navigate to the object, right click and select "view dependencies".  However this does not tell you what columns are being referenced by the Stored Procedure.
    One way to view what is being referenced by a stored procedure is to run something like
    select
    text
    from syscomments
    where
    id in
    (select id
    from sysobjects
    where
    name
    =[Your Object Name]
    And xtype
    in
    ('p','P')
    Please click "Mark As Answer" if my post helped. Tony C.

  • Using of already existing logical tables and columns in a new subject area.

    Hi Every one,
    i am new to OBIEE technology.
    In my project i need to create a new subject area for already existing RPD.
    In that RPD there are some logical tables and column created for previous project and i need to use those in this new subject area that i am going to create.
    My question is what is the best way to use them .
    I mean just to drag and drop them into new subject area or any other way.
    please have your valuable suggestions
    thanking you

    Yes, you can basically copy paste all the tables that you need from BMM layer into your new folder in the presentation layer. Just make sure all the joins are defined well between all the tables that exists in the new folder, so you wont end up running into ODBC errors when you run analysis.
    Hope this helps.
    Thanks,
    -Amith.

Maybe you are looking for

  • System monitoring - DSWP and RZ21

    Hi all, I am using sap solution managers workcenter "System monitoring" to set up the sap monitornig for a huge landscape. This works well, but to receive alerts (e.g. per mail)  I additionaly have to do the settings in RZ21 (assign central autoreact

  • Help - problems waking up

    Over the last week I have started to have problems waking up my iMac. The problem occurs randomly with the following symptoms: - the screen stays dark but the hard drive and fan start, with the fan gradually building to a dull roar. I have reset the

  • I changed my WRT54G security settings from WPA to WEP

    I changed my WRT54G security settings from WPA to WEP and now one of my latops (Dell 5100) will not connect wirelessly. It is using a linksys wireless-B notebook adapter. I am at a loss at how to reconnect this to my wireless network.

  • HT1498 How do I retrieve a movie that quite with 30 min to go?

    Rented a movie with Apple TV and it quite with 30 min to go.  I went to settings then to check for rentals and can't reload the movie to watch the end.  This has happened to me twice now! What do I need to do?

  • Casting Confusion

    Hi, I am studying for the SCJP exam, and there is something I've read that I can't figure out about Object Reference casting. I have read that to cast a Final Class to a Non Final class, the Final Class must "extend" the Non Final Class. Does this me