Dynamic SQL queries in HTMLDB application

How can i build a HTMLDB page only for dynamic sql queries like the features in the HTMLDB SQL-workshop.
I need a SQL interface for some power user running some ad-hoc queries.
Can i call this page directly from any other HTMLDB application?
Regards
Martin

Hello Martin,
I am a beginer in APEX but I have the same problem with you. What are your solution for dynamic sql query ? For report a solution is Pl Sql procedure which return a sql query. But for a form ?

Similar Messages

  • Erratic Report Region Behavior with Dynamic SQL Queries

    I'm running HTMLDB v 1.5.1.00.12 and I've noticed some odd behavior with report regions using dynamic SQL queries. Every so often, our testers will run a page containing a dynamic sql report region and get the following error, (despite the fact the query was working only moments ago and no other developer has touched it):
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    or sometimes
    failed to parse SQL query:ORA-01403: no data found
    The only solution I've found so far is to:
    1) Make a copy of the failed report region.
    2) Disable or delete the original failed report region.
    The new copy of the report region runs without issue.
    My search of the forums turned up the following two threads, but neither provided me with a clear explanation of the cause, and how to avoid it:
    ORA-06502:PL/SQL: numeric or value error: character string buffer too small
    Re: Import Export Error (ORA-06502)
    The columns being returned are below the 4000 character limit, and the rows being returned are far less than 32k in size.
    Could this have anything to do with the way HTMLDB is internally storing the PL/SQL used to generate the dynamic SQL Query? Is there any known issue related to this with that version of HTMLDB?
    This problem occurs without any discernable pattern or consistency, making it hard to determine where I should focus my efforts in tracking down the cause.

    Hi all,
    My report seems to be behaving correctly once i set it to "Use Generic Column Names (parse query at runtime only)" :)
    Cheers,
    Joel

  • PL/SQL Counter for HTMLDB - Application Express - Survey Counter

    I wonder if somebody could help me to clarify the HowTo on this Survey.
    Based on:
    http://www.oracle.com/technology/products/database/application_express/index.html
    http://www.oracle.com/technology/oramag/oracle/06-mar/o26browser.html
    I follow up however that is not exactly what I like to see in my Survey. I like to make something more elegant and flexible.
    On this example he put 10 questions/ page. I like to use 1 Question / Page.
    And I like to extend to more than 10 pages. for example 20.
    My question to the forums is:
    If I create an application with Only 3 pages [ Welcome, Survey, End ]
    And the main page for the Survey is the second page.
    How would programatically be the logic to:
    Start the Welcome page => Setup variable counter = 1
    Then using sessions with a button click on Start Survey.
    Survey Page check for the existence of counter variable if exist retrieve the Question from the Questions table and the properly Answer will be recorded.
    This answer could include comments, and the Rating could be an LOV.
    After the Question 1 is asnwered then the Next Button on the Page 2 Call the same page 2. If the Questions is the max number of questions [20] then go to the End or Summary Page. if not just increase the counter variable then retrieve the next question.
    Am I asking to much ???. I'm just starting on PL/SQL and HTMLDB I'm not sure how to manipulate those variables. I've been trying but I'm stuck.
    Thanks in Advance for your Help.
    Dino.
    http://htmldb.oracle.com/pls/otn/f?p=42721:1:4875344191023058749:::::
    PS -> As soon as have the answer will post it public in htmldb.oracle.com =)

    Move this over to :
    Oracle Application Express (APEX)

  • Running SQL Queries in PeopleSoft Application Designer

    Hi,
    I'd like to find out which peoplesoft tables contain two fields x and y. I have the sql query to do that, but I don't know where I can run that query from in application designer. Its quite possible that it will be done from "Query" window in Application Designer.
    Can someone tell me the steps to do this? I'm very new to PeopleSoft.
    thanks.
    Askar

    1. Open the QUERY tool from the AppDesigner.
    2. File/New
    3. Expand the record
    4. Click on PSRECFIELD
    5. Drag and drop to the right part of the window
    6. At the left window, drag and drop the fields RECNAME from the left (from the record PSRECFIELD) into the tab Field at the right
    7. At the left window, expend the record hierarchy of PSRECFIELD
    8. Expand PSRECDEN Record Definition
    9. Right click on PSRECFIELD Field definition, then "New join"
    10. Choose Standard join
    11. At the right, click on tab Criteria
    12. Drag and drop the FIELDNAME field from the first PSRECFIELD (A)
    13. Double click on Expression 2
    14. In the new window, enter one of the first column name you want to retrieve
    15. Drag and drop the FIELDNAME field from the second PSRECFIELD (C)
    16. Double click on Expression 2
    17. In the new window, enter one of the second column name you want to retrieve
    18. Double click on Logical column at the right until to have "AND"
    19. Click on tab Result
    20. Click on Run query (or File/Run current query)
    21. Enjoy with your results.
    Note, QUERY tool will query the Peoplesoft tables, on the other hands, the Peoplesoft metamodel. If you have built objects directly against the database without having used AppDesigner, you won't be able to retrieve the data.
    Nicolas.

  • Tracing SQL Queries from an Application.

    I read the info on here.
    http://www.psoug.org/reference/traceanalyzer.html_
    I have been able to use this guide to analyze traces.
    I installed DBMS_SUPPORT package on my XE database. I need to know, how can I run a trace from my front-end application and get it analyzed, using trace analyzer.
    I have got trace files, by using DBMS_SUpport. I have been successful in running tkprof on them.
    I need to trap the values of the bind variables that are being sent by the front-end application.
    Any suggestions would be welcome.
    Thanks.

    End to End Application Tracing can identify the source of an excessive workload, such as a high load SQL statement, by client identifier, service, module, action, session, instance, or an entire database. This isolates the problem to a specific user, service, session, or application component.
    Oracle provides the trcsess command-line utility that consolidates tracing information based on specific criteria.
    The SQL Trace facility and TKPROF are two basic performance diagnostic tools that can help you monitor applications running against the Oracle Server.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/sqltrace.htm#i19083

  • How to determine estimated cost of dynamic SQL queries before execution?

    Hi Performance Gurus,
    Does anybody need know of a function module or program which can give me an estimated cost for a given SQL query. SQL query is a dynamic query and we need to know the estimated cost before we execute it.
    Cheers
    Jiby
    Moderator message: subject corrected, in the future please use one that describes your problem better.
    Edited by: Thomas Zloch on Aug 24, 2010 12:56 PM

    Hi,
    The mentioned function module does not give you the cost but the plan.
    On DB2 e.g.
    U Explanation of query block number: 1   step: 1
    D Query block type is SELECT
    S Performance appears to be bad
    S No index is used. Sequential tablespace scan
    E Method:
    D           access new table.
    D           data pages are read in advance
    D           pure sequential prefetch is used
    D           new table:
    D                       SAPD8M.DD02L
    D                       table space locked in mode:  N
    D           Accesstype: sequential tablespace scan.
    I think there is some information that could be used as well (cost figure transformed to text)
    S Performance appears to be bad
    S No index is used. Sequential tablespace scan
    But as already said: the whole requirement is quite strange...
    I'm not aware of any other options, sorry.
    Kind regards,
    Hermann

  • Difference between Static SQL Query and Dynamic SQL Query.

    Hi,
    Please explain the basic difference between static and dynamic sql queries. Please explain with example.

    Static: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/static.htm
    Dynamic: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/dynamic.htm

  • ORA-06502:PL/SQL:numeric or value error. Dynamic SQL the only answer??

    ORA-06502: PL/SQL: numeric or value error: character string buffer too small.
    I have an HTMLDB report that errors with the above message. The query is over 7000 characters long so I'm guessing this is the cause. If I retrieve the query from a query table, replace the variables in the LONG query using PL/SQL and execute using dynamic SQL, are the HTMLDB reporting features the same as if I was using a simple SQL query? Is there a better way? I will need to 'drill-down' from this report so how do I create the links? The only HTMLDB PL/SQL package I can find mentioned in the User's Guide is HTMLDB_PLSQL_JOB.
    Cheers, Paul

    Hello All,
    I have the same problem.
    For me it started when i got about 500 rows in the table
    on which the LOV is based.
    With a lot of trying with substr I managed to find the size of the string which it still accepted, which was 51 characters.
    So I thought it was some glitch in the APEX insides, and since I had no time to resolve it further, I went on working.
    But I have to resolve it now, because the following mysterious behaviour is occurring:
    Every few records added to the base table, the problem occurs again, and I can resolve it by cutting down the string
    with one character.
    I have now reached 39 characters !?
    I am afraid that I will end up with 1 character or even null.
    If I switch to Popup list based on LOV there's no problem, and the complete strings are shown.
    The maximum length of the string in my basetable is 252, but the data in it now reaches 55 at most.
    Any idea welcome!
    I did already recreate the master-detail form from scratch, but there the same behaviour.
    greetings,
    Richard Kloostra

  • Logging sql queries without any changes in existing apps

    Hi!
    Is it possible to log all SQL queries send from application to database via JDBC without any (or really small) changes in code of existing applications?
    I'm new to JDBC so any suggestions/ideas/best practices are welcome ;)
    Best regards.
    Edited by: matthew_ on Mar 16, 2008 5:35 PM

    Is it possible to log all SQL queries send from application to database via JDBCFirst is an assumption that the driver does in fact sends SQL. It might send some other form.
    But excluding that and excluding that the driver explicitly sends it then you can create a proxy driver. You implement the driver to pass everything to the real driver. Along the way it collects the information.
    You will find that that is quite bit of work. However it impacts the actual code very little and requires nothing more than loading the driver and changing the connection string in the code where it is used.

  • BSP Application connection to SQL Express DB to execute SQL Queries

    Hi There everyone,
    I am not sure if I am posting this discussion in the correct section, but please try and help me out.
    I have been tasked to write a BSP Application in the ABAP Workbench.  The purpose of this application is to enable our Weighbridge operators to execute pre-defined SQL Queries by selecting certain criteria from the Application.  The application is based on an HTML frontend which includes the Web Form (Input Fields, Submit buttons).  We have 6 Weighbridges, each has its own HTML page in this application.
    What I need to achieve is the following;
    I need to know how I must setup the connection between the BSP Application and the SQL Express DB.  Each Weighbridge has its own dedicated SQL Express instance + DB.  These SQL Instances are not on the same host as where the BSP Application is located, I think the correct term is "External SQL Instances".  Everything is on the same domain though.
    What code would I need to add to the "OnInitialize" section in the BSP Application, to be able to establish the connection to the SQL Express database using Windows Authentication?
    And what code would I need to attach to my submit buttons in the "OnInputProcessing" in the BSP Application, to execute a SQL Query to that DB and display the results in .CSV format back to the user?
    I have attached 2 screenshots of what the BSP Application interface looks like.  (This is what the user sees)
    I am very new to creating BSP's, and I have never had to link to SQL from HTML / PHP before, so I basically have no knowledge of this.
    Any help will be greatly appreciated.

    Sorry for the late reply.
    Yes, database is always available and online, not involved in Log Shipping or other things.
    At the time of the connection failure I can find the following in the log of the application:
    ProcessID:2452 ,ThreadID:4768 : NI-I - 24/08/2012-15:12:20 - \PCV/src/ni/src/pcvnireceive.cpp - 4741 - Thread 4768 - Receive Thread Started for Remote Node 043SBTMS10DRSP: In Thread index 1:
    ProcessID:2452 ,ThreadID:4768 : NI-I - 24/08/2012-15:12:40 - \PCV/src/ni/src/pcvnireceive.cpp - 4968 - Thread 4768 - Receive Thread Ended for Remote Node 043SBTMS10DRSP: In Thread index 1:
    ProcessID:2452 ,ThreadID:4768 : NI-I - 24/08/2012-15:12:40 - \PCV/src/ni/src/pcvnireceive.cpp - 115 - Thread 4768 - Merge Memory Usage: KB Allocated = 2186, KB in use = 889
    ProcessID:2452 ,ThreadID:1408 : NiJ - E - 25/08/2012-19:35:29 - \PCV/src/ni/src/pcvnijournal.cpp - 2842 - PcvNiJournal::isRetrievePending() - DB Exception.Error: TCP Provider: The specified network name is no longer available.
    Communication link failureQuery timeout expired - State:08S01,Native:64,Origin:[Microsoft][SQL Server Native Client 10.0] State:08S01,Native:64,Origin:Microsoft][SQL Server Native Client 10.0]
    State:S1T00,Native:0,Origin:[Microsoft][SQL Server Native Client 10.0]

  • Developer Security with HTMLDB (Application Express)

    Hi folks. I would appreciate any help I could get with this problem - it's a fairly serious one and I'm hoping for some feedback.
    We are using HTMLDB 2.0 and are using Oracle Applications. We have a rogue developer who has a bit of a control problem - he likes to run UPDATE, DELETE, and INSERT statements against our production database. However, he does develop HTMLDB reports for us and does a good job with that. Is there any way we can limit his developer account in HTMLDB so that he can't run these kinds of queries in the SQL Editor in HTMLDB?
    Any suggestions on how we can limit what kinds of queries he runs?
    Thanks so much!
    Steve

    Are queries run in the SQL Editor logged?
    SQL> desc flows_020000.wwv_flow_sw_sql_cmds
    Name                                      Null?    Type
    ID                                        NOT NULL NUMBER
    COMMAND                                            CLOB
    PARSED_SCHEMA                                      VARCHAR2(30)
    CREATED_BY                                         VARCHAR2(255)
    CREATED_ON                                         DATE
    SECURITY_GROUP_ID                         NOT NULL NUMBERThe security_group_id maps to the workspace.
    To get the security group id for your workspace, run
    select provisioning_company_id,short_name
    from flows_020000.wwv_flow_companies
    where provisioning_company_id>10;Then you can keep an eye for
    select * from flows_020000.wwv_flow_sw_sql_cmds
    where security_group_id=<that long number>
    and lower(command) like '%update%'

  • Help with SQL queries following migration

    Hi there,
    I have just migrated from MS SQL Server database to Oracle 10g database using the Oracle SQL Developer.
    My application is using JDBC to access the database, and there are heaps of SQL statements that need to be verified and tested. I've found a number of SQL compatibility issues from my testing of the Oracle database and I hope you can help me the following.
    1. Case sensitivity
    Is it possible to not enforce case sensitivity (by default) when performing a select query?
    If this is not possible, all the SQL statements will need to be changed to evaluate column based on uppercase.
    2. Trailing white space
    Is it possible to not evaluate trailing white space (by default) when performing a select query?
    For example, suppose a table column studentNo has trailing spaces (after database migration), e.g. 'A182D '
    when performing query - select * from student where studentNo = 'A182D'
    no results can be found
    3. Issue with Where condition containing with '' = ''
    There are quite a number of SQL statements with Where condition containing '' = ''.
    For example, the following SQL query doesn't return any results even though there are matching suburb that starts with 'ST'. These types of queries are mostly used in dynamic generated queries.
    select * from Address where (suburb like 'ST%') and ('' = '' or country = '')
    Any help or advice will be greatly appreciated.
    Regards,
    Jason Gordon

    As justin mentioned setting those NLS parameters will make oracle not to use your regular index. for that you must create a function based index. See example below.
    SQL> create index t_idx on t (name)
      2  /
    Index created.
    SQL> exec dbms_stats.gather_table_stats(user,'T',cascade=>true)
    PL/SQL procedure successfully completed.
    SQL> explain plan for
      2  select * from t where name = 'karthick'
      3  /
    Explained.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 2946670127
    | Id  | Operation        | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |       |     1 |     9 |     1   (0)| 00:00:01 |
    |*  1 |  INDEX RANGE SCAN| T_IDX |     1 |     9 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - access("NAME"='karthick')
    13 rows selected.
    SQL> delete from plan_table
      2  /
    2 rows deleted.
    SQL> alter session set NLS_COMP=ANSI;
    Session altered.
    SQL> alter session set NLS_SORT=BINARY_CI;
    Session altered.
    SQL> explain plan for
      2  select * from t where name = 'karthick'
      3  /
    Explained.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 1601196873
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     9 |     5   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| T    |     1 |     9 |     5   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       1 - filter(NLSSORT("NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('6B61727
                  46869636B00') )
    14 rows selected.
    SQL> create index t_idx_1 on t(NLSSORT(name,'NLS_SORT=BINARY_CI'))
      2  /
    Index created.
    SQL> exec dbms_stats.gather_table_stats(user,'T',cascade=>true)
    PL/SQL procedure successfully completed.
    SQL> /
    create index t_idx_1 on t(NLSSORT(name,'NLS_SORT=BINARY_CI'))
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    SQL> delete from plan_table
      2  /
    2 rows deleted.
    SQL> explain plan for
      2  select * from t where name = 'karthick'
      3  /
    Explained.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 2580036035
    | Id  | Operation                   | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |         |     3 |    27 |     2   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T       |     3 |    27 |     2   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | T_IDX_1 |     3 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access(NLSSORT("NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('6B6172746869636B00') )Thanks,
    Karthick.

  • SQL queries inside html region

    Hi,
    I have html page in my application and i need to display result of the sql query inside this page. I would like to know if i can use the sql queries in html and if yes how can do that.
    My query is select count(*) from Quote Letter master where service = 'Premier Support'
    And i have similar queries like this which i would like to use in the html region.
    Thank you,
    rakesh

    rakesh119 wrote:
    Hi,
    I have html page in my application and i need to display result of the sql query inside this page. I would like to know if i can use the sql queries in html and if yes how can do that.You cannot/should not write sql queries in your html, but in APEX there are different ways to achieve this such as Page Items, PL/SQL Dynamic Content Region etc.
    My query is select count(*) from Quote Letter master where service = 'Premier Support'.For this you better use a page item and compute the items value using a page computation on on-load before header point. Then you can place the page items in a APEX region and also add any styling

  • NULL and dynamic SQL

    If table testrh2 has the following columns and data
    col1 --> NULL
    col2 --> 2
    and table testrh has the following columsn and data
    col1 --> NULL
    How could I write a dynamic SQL statement to join on the nulls? I've written the following block as a starting point.
    declare
    cursor c1 is select col1 from isis.testrh;
    lval varchar2(1000);
    lval2 varchar2(1000);
    begin
    for r1 in c1 loop
    lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
    execute immediate lval into lval2;
    dbms_output.put_line(lval2);
    end loop;
    end;

    You can't compare null values with '=' in Oracle SQL.
    Null can only be compared with <column> is null .
    You can see it when you try these two queries:
    select * from dual where null is null;  -- you will see one row
    select * from dual where null=null;  -- you will see no rowsThat's why you have to write something like
    (<column1>=<column1>   or   (<column1> is null and <column2> is null))This should also work with null:
    decode(<column1>,<column2>,1,0)=1By the way, why do you use dynamic sql?
    lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
    I think you could replace your two lines ( lval:= ... AND execute immediate) by this:
    begin
      select col2
      into lval
      from isis.testrh2
      where decode(col1,r1.col1,1,0)=1;
      dbms_output.put_line('lval='||lval);
    exception
    when no_data_found then
      dbms_output.put_line('no data found'); -- or whatever you want
    end;Edited by: hartmutm on 02.10.2010 23:54

  • Performance between SQL Statement and Dynamic SQL

    Select emp_id
    into id_val
    from emp
    where emp_id = 100
    EXECUTE IMMEDIATE
    'Select '|| t_emp_id ||
    'from emp '
    'where emp_id = 100'
    into id_valWill there be more impact in performance while using Dynamic SQL?

    CP wrote:
    Will there be more impact in performance while using Dynamic SQL?All SQLs are parsed and executed as SQL cursors.
    The 2 SQLs (dynamic and static) results in the exact same SQL cursor. So both methods will use an identical cursor. There are therefore no performance differences ito of how fast that SQL cursor will be.
    If an identical SQL cursor is not found (a soft parse), the SQL engine needs to compile the SQL source code supplied, into a SQL cursor (a hard parse).
    Hard parsing burns a lot of CPU cycles. Soft parsing burns less CPU cycles and is therefore better. However, no parsing at all is the best.
    To explain: if the code creates a cursor (e.g. INSERT INTO tab VALUES( :1, :2, :3 ) for inserting data), it can do it as follows:
    while More Data Found loop
      parse INSERT cursor
      bind variables to INSERT cursor
      execute INSERT cursor
      close INSERT cursor
    end loopIf that INSERT cursor does not yet exists, it will be hard parsed and a cursor created. Each subsequent loop iteration will result in a soft parse.
    However, the code will be far more optimal as follows:
    parse INSERT cursor
    while More Data Found loop
      bind variables to INSERT cursor
      execute INSERT cursor
    end loop
    close INSERT cursorWith this approach the cursor is parsed (hard or soft), once only. The cursor handle is then used again and again. And when the application is done inserting data, the cursor handle is released.
    With dynamic SQL in PL/SQL, you cannot really follow the optimal approach - unless you use DBMS_SQL (a complex cursor interface). With static SQL, the PL/SQL's optimiser can kick in and it can optimise its access to the cursors your code create and minimise parsing all together.
    This is however not the only consideration when using dynamic SQL. Dynamic SQL makes coding a lot more complex. The SQL code can now only be checked at execution time and not at development time. There is the issue of creating shareable SQL cursors using bind variables. There is the risk of SQL injection. Etc.
    So dynamic SQL is seldom a good idea. And IMO, the vast majority of people that post problems here relating to dynamic SQL, are using dynamic SQL unnecessary. For no justified and logical reasons. Creating unstable code, insecure code and non-performing code.

Maybe you are looking for

  • FP not working in IE 9 Windows 7 64-bit

    Hi! I noticed that my FP stoped working. I have tried to install the latest version without any result. I have also reinstalled latest version, same problem. I have updated my Intel HD grafics driver, updated java end tried to install an older versio

  • Maximum width

    Hi, I have mulitple dropdown menus that needs to be on the one line (horizontally). As the dropdown menus have pretty long "values" within them, i have to resize the dropdown menus so that they all sit on the one line (going horizontally across the p

  • Macbook pro + boot camp + Windows Media Center = can't logon

    I just finished installing Media Center on my macbook and the install seemed to go fine. However now when I get the XP logon screen it prompts me for a password and no matter what password I use it gives me the following error: "The system cannot log

  • I have a problem today every time i connect a usb mouse on the macbook pro turns off.

    I have a problem today every time i connect a usb mouse on the macbook pro the laptop turns off. What could i do to fix it?

  • Community Nugget 5-Mar-2007

    Type Definitions Let You See Your Application in a Different Way “THE ESSENCE OF TYPE DEFINITIONS IS THAT IF THE TYPE DEFINITION IS CHANGED ALL "MEMBERS" WILL CHANGE THE SAME WAY.” (Albert Geven LabVIEW Champion ) Type definitions are a wonderful yet