Parse SQL

I'm trying to create a simple user reporting package for use on the web using pl/sql. The concept is simple, allow the user to type in a SQL statement into a web form. When it is submitted, I need to parse the SELECT in order to create a table with column headers in order to display the data. Does anyone have any info on how this could be accomplished? This is already done inside of portal report applications but I cannot see the code in order to figure out how it is done.

Use the DBMS_SQL package. See this doc:
http://download-west.oracle.com/docs/cd/B13789_01/appdev.101/b10802/d_sql.htm#ARPLS058
You'd use (at least) PARSE, and DESCRIBE_COLUMNS.
Tom Best

Similar Messages

  • Failed to parse SQL query: ORA-01403: no data found

    I'm going to post and answer my own question in the hope that others will not have to struggle with this error.
    Using a report of the type PL/SQL Function Body Returning SQL and using generic columns you may run into this error
    failed to parse SQL query:
    ORA-01403: no data found
    The SQL will run stand alone but the report fails.
    There is a setting just below the source you should check:
    "Maximum number of generic report columns"
    In my case the number of columns was dynamic and when it exceeded the number set as the maximium number of generic columns I received the 1403 error.
    Hope this helps someone.
    Greg

    Thanks for much for the pointer. For anyone else struggling with this too, I found that my generic columns had unordered themselves. Reordering them solved the problem for me.
    Edited by: user11096971 on Jul 22, 2010 3:19 AM

  • Classic Report CSV output failed to parse SQL query

    Hi,
    I'm trying to get a CSV output from a classic report. I'm generating the report based on a PL/SQL block that will return an SQL query. But when i download the CSV excel just gives me a:
    failed to parse SQL query:
    ORA-00936: Missing expression
    and shows me the query that the application is trying to parse. I'm also using bind variables (page items) in the PL/SQL block that is returning me the SQL query. I think that the reason that it fails to parse the query is that the query that is shown in excel has no bind variable values.
    Anyone got any ideas?

    Hi Arif,
    run your page in debug mode and check out the SQL statement which is actually executed for the report. That might help to diagnose what is going wrong.
    If you wish you can also post the report SQL statement which is getting executed.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Failed to parse SQL query by one user

    Hi all,
    in my app i have a text-item with a submit button. In this item i type a name and a report after the item-region show me the result(s). this works for all my users (>2000) perfectly, but one of this users become an error in the report-region:
    failed to parse SQL query:
    ORA-01403: no data found
    We try this with the same searchstring on the same computer/browser. If i logged in the result is ok, if the user logged in, the error message shows. If i try this on the computer from the user with me logged in, result ok. If the user try this on an other pc, results error.
    I have an productive and a developer workspace. In the developer workspace the user can try this perfectly without errors. Only in the productive workspace the error shows.
    The SQL-Select in the reprirt ist verry simple:
    select id
    , name
    , raum
    from table
    where instr(upper(name), upper(:P60_SEARCH))>0
    However all users can use this search-field with report perfectly, only this one user has the error. It is no restrictions on this item or report.
    Can anybody help me?

    Carsten,
    user preferences do not have anything to do with the fact where the user resides (apex built in, LDAP, whatever). User Preferences are saved for a named user and they are loaded next time the same user loggs in. For example, if you sort your report on a column x, apex will save this as a setting and next time you call the same report, this report will be sorted the same way. Since you don't have a permission to edit services, you should check your adminstrative permissions and conntact the real administrator of the workspace to do that "purge prefference" for you. I could bet this is the reason you are getting that strange error message.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    ------------------------------------------------------------------------------

  • Failed to parse SQL Query - External Tables [Apex 4.0.2]

    Greetings experts -
    Has anyone encountered errors when creating a report in Apex that sources from an external table within the database? I'm using the 4.0.2 version that is packaged with the 11g XE edition on 64bit CentOS.
    For example, I might run:
    SELECT NULL LINK,
    COL1 LABEL,
    COL2 VALUE
    FROM MYTAB;
    Where MYTAB is an external table sitting on top of a comma-separated file. When I go to create the page, I'm prompted with the "Failed to parse SQL" dialogue.
    I noticed that if I did CTAS on the external table, and referenced the CTAS table, my page ran without problem!
    Any ideas? Is this a known "limitation" of Apex?
    Thanks,
    CJ

    Chiedu,
    Please try removing all declarative validations on this tabular form, and see if it works as expected then. There are some limitations on the type of views and joins that are supported by tabular forms when using the new declarative validations, i.e. you'll need a key preserved table in your view or join.
    Regards,
    Marc

  • Report failed to parse SQL query:ORA-01745: invalid host/bind variable name

    Hi,
    We are currently upgrading from v2.2.0.00.32 to v4.0.0.00.46.
    I have copied the applications onto our test server along with the various database objects and data etc.
    When I am running a report in v4, it is failing with the following error: "failed to parse SQL query: ORA-01745: invalid host/bind variable name".
    When I copy the SQL that builds the report into TOAD (on out test server) it runs OK so really cant see why it would fail in APEX. It works fine when I run the query in our APEX v2 and in TOAD in our live server.
    The query is as follows:
    SELECT
    aea.ALTERATION_ID
    ,aea.ALTERATION_ID "ALTERATION_ID_DISPLAY"
    ,aea.assembly_name "Revised BOM"
    ,assembly.description "Revised BOM Description"
    ,assembly.INVENTORY_ITEM_STATUS_CODE "Revised BOM Status"
    ,aea.BEFORE_CHANGE_QTY
    ,flv.MEANING "Alteration Type"
    ,aea.component_name "Part No"
    ,component.description "Part No Description"
    ,component.INVENTORY_ITEM_STATUS_CODE "Part No Status"
    ,aea.AFTER_CHANGE_QTY
    ,TO_CHAR(aea.last_update_date,'DD-MM-YYYY HH24:MI:SS')"Last Update Date"
    ,aea.LAST_UPDATE_BY
    ,aea.COMMENTS
    ,aea.ORACLE_CHANGE_NOTICE
    ,AEA.SELECTION_CRITERIA
    FROM XXMEL_APEX_ECO_ALTERATIONS aea
    , fnd_lookup_values flv
    , (SELECT INVENTORY_ITEM_STATUS_CODE
    ,segment1
    ,description
    FROM mtl_system_items_b
    WHERE 1=1
    AND organization_id = 26) component
    , (SELECT INVENTORY_ITEM_STATUS_CODE
    ,segment1
    ,description
    FROM mtl_system_items_b
    WHERE 1=1
    AND organization_id = 26) assembly
    WHERE 1=1
    AND aea.COMPONENT_NAME = component.segment1 (+)
    AND aea.assembly_NAME = assembly.segment1 (+)
    AND flv.lookup_code = aea.acd_type
    AND aea.eco = :P13_ECO
    AND flv.lookup_type = 'ECG_ACTION'
    AND modify_flag = 'Y'
    ANy help would be great,
    Thanks
    Chris
    Edited by: Cashy on 22-Nov-2010 04:13
    Edited by: Cashy on 22-Nov-2010 04:14

    For some reason, the updatable fields (this is a updateable report) where not connecting to the database properly. Whn I changed them to a report columns and removed the database field reference, the report rendered

  • Chart Query and Failed to parse SQL query

    Hi,
    first of all, this is not a question. It is a reminder for me and maybe for someone with the same problem.
    I just fell over this for the 123124 time.
    I have a 3D Chart Query
    select sum(order_ok) value,
          count(*) maximum_value
    from      v_dialer_campaign
    where campaign_uuid = :P300_CAMPAIGN_IDSaving fails with
    "1 error has occurred Failed to parse SQL query!" ...
    Saving the query without validation works, but does not show any result in the chart.
    v_dialer_campaign is a view selecting from a view in a mssql db over database link and HS.
    running the select in sqlplus or toad works.
    Without any trace on freetds/unixodb/hs side, i would have not found the following line:
    [FreeTDS][SQL Server]The data types nvarchar and text are incompatible in the equal to operator.[FreeTDS][SQL Server]Statement(s) could not be prepared.
    Solution:
    with q as (select :P300_CAMPAIGN_ID val from dual)
    select     sum(order_ok) value,
         count(*) maximum_value
    from     v_dialer_campaign
    where     campaign_uuid in ( select val from q)Maybe the error output when validating the query should be included in the APEX error message.
    Same solution applies for dynamic LOV's reading from HS using a where clause.

    I tried your first query on Apex 3.2 and it created a nice dial chart.
    Is there any ORA-xxxxx error along with the "failed to parse SQL query" message? Did you double check column & table name spelling?
    P.S. The second query is invalid (a superfluous comma after the second column).

  • Concurrent sessions accessing parsed sql from the library cache

    Hi there,
    I am having five concurrent session firing exactly same SQL statement inside a stored procedure.
    Stored Procedure
    PROC1(a int)
    begin
    select <C1>,<C2> into <V1>,<V2> from <T1>, <T2> where <JOIN between both table> and T1.<C3>=a;
    end;
    All those five sessions are calling the procedure PROC1 which subsequently executes the sql statement.
    Execution time of sql statement is 2 seconds.
    I ma wondering whether all other sessions will wait for the currently executing session to release the latch on parsed sql(getting stored in the library cache)? (In this case last session will wait for 8 seconds) Or would they execute in parallel with their own copy of parsed sql?
    Please help!!!
    TIA,
    Nishant

    Would it be like that the first session will hard parse the SQL statement and all other concurrent sessions will have a "softer" soft parse and take a copy of query plan and execute the statement without waiting for each otherYes, I think this is the way it works according to official Oracle documentation
    (and why there is a shared pool).:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14220/sqlplsql.htm#i2196
    But I don't know if you can find detailed documentation about all latching steps for hard parse and soft part steps.

  • Concurrent sessions accessing parsed sql from teh library cache

    Hi there,
    I am having five concurrent session firing exactly same SQL statement inside a stored procedure.
    Stored Procedure
    PROC1(a int)
    begin
    select <C1>,<C2> into <V1>,<V2> from <T1>, <T2> where <JOIN between both table> and T1.<C3>=a;
    end;
    All those five sessions are calling the procedure PROC1 which subsequently executes the sql statement.
    Execution time of sql statement is 2 seconds.
    I ma wondering whether all other sessions will wait for the currently executing session to release the latch on parsed sql(getting stored in the library cache)? (In this case last session will wait for 8 seconds) Or would they execute in parallel with their own copy of parsed sql?
    Please help!!!
    TIA,
    Nishant

    Can you please elaborate a little further.
    AFAIK the query plans are stored in the library cache and there will be latches on data structures. Won't it mandate serial execution? Please correct me if I am wrong.
    Thanks...
    Nishant

  • Workspace to parse SQL statements from multiple database schema's

    Hi ,
    When go through the following link of workspace admin user :
    Home>HTML DB Workspace Administration>Manage Services>Schema Reports>Workspace Schemas there I saw "Your workspace has the privilege to parse SQL statements using the following database schemas. Note that the terms database schema and database user can be used interchangeably.
    " at the right pane.
    So how can i make my workspace to parse SQL statements from multiple database schema's ?That must be listed there .But i have only one schema in view ? Can i make it multiple ?If then How ?
    Anybody have an idea ?
    ROSY

    Assign as many schemas to your workspace as you want using the administration app. Read about it in the doc.
    Scott

  • Column sort gives "failed to parse SQL query"

    Hi folks,
    I have a page with a chart and 5 reports. All report columns are sortable.
    When I first navigate to the page from a menu, the chart and all reports display correctly. Given certain query criteria, reports 2 and 4 correctly return no data, and show my polite 'no data found' message.
    If I sort report 1 or 3 or 5 by clicking a column heading, the chart and reports 1, 3 and 5 display correctly, but in report regions 2 and 4 I then get
    failed to parse SQL query:
    ORA-06502: PL/SQL: numeric or value error: NULL index table key valueThese errors can be cleared by navigating to the page again from a menu.
    What's wrong? How can I fix it?
    I'm at 1.6.0.00.87, db 10.1.0.3.0.
    All ideas gratefully received.
    Thanks
    John D

    OK, I now have a workspace.
    I recreated the problem using page 1 of the Sample Application (app 15027).
    1 - Copy region "My Top Orders" to "My Top Orders 2" on page 1 (same display point, column 2).
    2 - Edit the SQL of "My Top Orders 2" to remove the ORDER BY clause.
    3 - Edit the columns of "My Top Orders 2" to make all columns other than ORDER_ID sortable.
    4 - Copy region "My Top Orders 2" to "My Top Orders 3" on page 1 (same display point, column 2)..
    5 - Run page 1
    6 - Click a column heading on "My Top Orders 2" and I got "failed to parse..." on "My Top Orders 3".
    BUT it's intermittent. Navigate away from page 1 then return, and you may find the error doesn't recur.
    So, what's up Doc?
    Many thanks,
    John

  • Queries regarding SGA, PGA and parsed SQL Queries

    Hi
    I am new to Oracle server architecture.
    Please correct me if am wrong.
    As per my understanding, the data that we retrieve from a SQL query is stored in SGA in Database buffer cache.
    I have some queries:
    1. Does the database buffer cache store only data from SQL queries or anything else also? What is its size? Can we set the size?
    2. Where are the parsed SQL queries stored - SGA or PGA? And where exactly? I want to know if all the users connected in an Instance have access to each other's parsed SQL queries?
    3. SGA is shared by all users in an Oracle Instance? PGA and UGA are local to a specific user in an instance? Is it correct?
    Thanks
    Abhi

    AB312062 wrote:
    Hi
    I am new to Oracle server architecture.
    Please correct me if am wrong.
    As per my understanding, the data that we retrieve from a SQL query is stored in SGA in Database buffer cache.
    I have some queries:
    1. Does the database buffer cache store only data from SQL queries or anything else also? What is its size? Can we set the size?
    2. Where are the parsed SQL queries stored - SGA or PGA? And where exactly? I want to know if all the users connected in an Instance have access to each other's parsed SQL queries?
    3. SGA is shared by all users in an Oracle Instance? PGA and UGA are local to a specific user in an instance? Is it correct?
    Thanks
    AbhiThe questions you have are all good ones, but require far too much to be explained (properly) in a forum such as this.
    I would highly recommend picking up a book by Tom Kyte and reading through that.
    Cheers,

  • Fail to parse SQL query after report attributes changes on sample app

    This errors occurs in the sample application istalled in Workspace PMW on the http://htmldb.oracle.com web site. Goto home page, edit Page 1, Select "Top Orders" in Region, select report attributes, change max count from 5 to 5 in "Layout and Pagination", apply changes, run page and parse SQL error occurs. Select "debug" and the following is shown regarding the query.
    0.10: query could not be parsed:
    SELECT a.ORDER_ID, a.ORDER_TIMESTAMP, a.CUSTOMER_ID,
    b.cust_last_name || ', ' || b.cust_first_name cust_name, NVL(a.ORDER_TOTAL, 0)
    FROM demo_orders a, DEMO_CUSTOMERS b
    WHERE a.customer_id = b.customer_id
    ORDER BY NVL(a.ORDER_TOTAL, 0) DESC order by 5 desc,5 desc
    failed to parse SQL query:
    ORA-00933: SQL command not properly ended
    I can't see that I'm doing anything wrong but maybe someone can shed some light on this!
    Thanks

    this is sort of an oversight on our part. what's going on is that the sample app installs with that order by clause in the query. at the same time, the report attributes page for that region has a default sort sequence value of "1 desc" (even though column heading sorting isn't enabled). when you go to that page and try to apply any change, htmldb tries to set things up correctly for you...and you end up with that double order by. the best way to avoid the issue is to remove the order by clause from the query on the Region Definition page.
    hope this helps,
    raj

  • Oracle Parsing SQL Statement in ANSI or Oracle Format

    I have problem with a Query ..It seems to be Oracle Bugs .
    When I enter below simple Query (in Oracle Join format ), It works properly
    select * from (
    select dept.*,emp.ename from dept,emp
    where dept.deptno=emp.deptno(+)
    where deptno in
    select deptno a from
    select deptno,dname from dept where deptno=10
    UNION ALL
    select deptno,dname from dept where deptno=20
    But When I changed it and use it in ANSI Format ,it is not parsed and shows me ORA-00920: invalid relational operator error ......
    Below shows the changes that I have made to convert it to ANSI Format.
    select * from (
    select dept.*,emp.ename from dept
    left outer join emp on (emp.deptno=dept.deptno)
    where (deptno) in
    select deptno a from
    select deptno,dname from dept where deptno=10
    UNION ALL
    select deptno,dname from dept where deptno=20
    It seems to be Oracle bugs.I appreciate everybody to help me.
    ( Comments : I use Oracle 9i R2 on Windows and I can not change the SQL statement
    because it is created dynamically)
    Best regards

    This sort of technical question needs to be addressed to one of the technical forums. Products | Database | SQL and PL/SQL would seem to be appropriate here.
    Have you tried applying the latest patchset for your database? Seems to work for me on 9.2.0.5
    SCOTT @ HP92 Local> select * from (
      2  select dept.*,emp.ename from dept
      3  left outer join emp on (emp.deptno=dept.deptno)
      4  )
      5  where (deptno) in
      6  (
      7  select deptno a from
      8  (
      9  select deptno,dname from dept where deptno=10
    10  UNION ALL
    11  select deptno,dname from dept where deptno=20
    12  )
    13  )
    14  /
        DEPTNO DNAME          LOC           ENAME
            10 ACCOUNTING     NEW YORK      CLARK
            10 ACCOUNTING     NEW YORK      KING
            10 ACCOUNTING     NEW YORK      MILLER
            20 RESEARCH       DALLAS        SMITH
            20 RESEARCH       DALLAS        JONES
            20 RESEARCH       DALLAS        SCOTT
            20 RESEARCH       DALLAS        ADAMS
            20 RESEARCH       DALLAS        FORD
    8 rows selected.
    SCOTT @ HP92 Local> select * from v$version;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.5.0 - Production
    PL/SQL Release 9.2.0.5.0 - Production
    CORE    9.2.0.6.0       Production
    TNS for 32-bit Windows: Version 9.2.0.5.0 - Production
    NLSRTL Version 9.2.0.5.0 - ProductionJustin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • 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

Maybe you are looking for

  • Weird Kuler Extension Panels in PS and AI

    The Kuler panel on AI, "Unable to connect to the kuler website, The server is either busy or you are offline."   But it does work on INDD and PS I just can't see any of my saved color schemes I can only see the popular ones.  I have done research and

  • How do I set up hotmail account on MacBook Air - tried for 2 days now without success?

    I have been trying to add a hotmail account on my new MacBook Air without success - searched on the net for 2 evenings now and still no success!  Can anyone suggest what I might be doing wrong although I think it could be that I am not sure that the

  • My ipod touch screen is not working or responding at all, what can i do?

    I need help, my ipod touch screen is not working or responding! the buttons work but thee buttons do. i trieed reseting it and shut it down, nothing works HELP Erika

  • Import Scanner

    For some reason, I cannot use the following: import java.util.ScannerWhen I do, I get this error: "Cannot resolve symbol class Scanner" Any idea why?

  • Metadata keywords

    I use Bridge to append Metadata to the Keywords field. I would like the  script below to get a a total file count of the PDFs containing ONLY the keyword "correction" on selected folders & output that info to a text file. I'm having difficulties  wit