How to reduce different versions of SQL with bind variables

There is an application, developed on Java.
Application executes SQL following types:
select * from t where id in (:1)
select * from t where id in (:1, :2)
select * from t where id in (:1, :2, :3)
select * from t where id in (:1, :2, :3, :4)
...And as a result very many versions (thousands) of similar SQL.
Do you know a method to reduce number of such SQLs?
I see one method: use one form of SQL with large number of prepared bid variables.
Like as
select * from t where id in (:1, :2, :3, :4, :5, :6, :7, :8, ...);And if query will be executed with one variable, the others will be equal to null.
Is there another method?

Cannot you insert those values into a temporary table and work within a subquery against that table ? That will make the code more secure, especially if the number of values is high.
Nicolas.

Similar Messages

  • How to use ApplicationModuleImpl.createViewObject for VO with bind variable

    I need to implement a AM method to create VO instance from a generic VODef with bind variables.
    The createViewObject() will trigger the executeQuery of the VO before I can set up the bind variables for the query.
    What is the proper way to create view object instance with bind variables?

    I am using JDeveloper 11.1.1.2.
    I have a ViewObjectA declared with some bind variables which determine what business data to be retrieved at runtime via a service method of the ApplicationModule.
    As the ViewObjectA is only referenced internally within ApplicationModule and I need more than one instance of the ViewObjectA for different conditions at runtime,
    I use ApplicationModuleImpl.createViewObject() to create an instance of ViewObjectA instead of adding ViewObjectA to the data model of the ApplicationModule.
    Currently, when the ViewObjectA is instantiated, it also trigger an executeQuery() which will not retrieve correct data until I set up the bind variables.
    However, the createViewObject() method doesn't let me pass in the values of the binding variables.
    Currenlty, I just call the createViewObject() and then set the binding variables values and call executeQuery() again.
    Just checking if there is a better way to do so...

  • Default form value using sql with bind variable

    I wish to create a form based upon a table with a foreign key. I wish to add a field to the form that is an uneditable text field with a default value using sql of 'select name from other_table where other_table_id = ?' where ? is a bind variable defined by a hidden field which is the value of the foreign key identified at runtime. How can this be done?
    null

    I don't think that will work. I have multiple people accessing the Portal at the same time with the same login (or lack of as public will be the most common user). I could set it easily enough as the value is passed to the form by a link object, so I could add it to the before page plsql block and set the value. But I am uncertain how it will behave in a multi-user mutlitasking environment.
    Maybe I should describe what I am looking to accomplish. I want to create a display above a form that will list static details from other tables (i.e. when editing a user's phone number, which is in one table, you want the user to see the person's name, which is in another table, and the form is based upon the phone table) ...
    Just as I am thinking about it, I thought of an idea. I could put some specific code in the before displaying page plsql section to query the database and use htp to output the information for data not in the table the form is based upon. I will try this and see how it works. It would have been nice to have just created a field that is not editable and had a default value, but this should work as well.
    Let me know if you see any problem with this or if you have any better suggestions.
    Thanks for the fast response.

  • Forms: sql with bind variable as default value to form field?

    I am using a form as a way to show details of already entered rows in a table. A report passes an id parameter to the form to get it to show the right data. No insert or update is possible. (I am using a form rather than a report because I need to display BLOBs, something reports can't do.)
    I need to execute sql statements based on the passed id to fill certain fields in the form with data from other tables. For example: The table the form is based on includes a category_id, whereas I want to display the category name which resides in another table.
    How would I best achieve this?

    Hi,
    You do this in the additional plsql code section of the form by getting the value of the category_id from the session variables and then getting its name from the cateogory table and assigning it to the category name column.
    Sample Code
    declare
    catid number;
    catnm varchar2(30);
    blk varchar2(10) := 'DEFAULT';
    begin
    catid := p_session.get_value_as_varchar2(
    p_block_name => blk,
    p_attribute_name => 'A_CATEGORY_ID');
    select category_name
    into catnm
    from cat_table
    where category_id = cat_id;
    p_session.set_value(
    p_block_name => blk,
    p_attribute_name => 'A_CATEGORY_NAME',
    p_value => catnm
    end;
    Thanks,
    Sharmila

  • Problem with Bind Variable in 11.2

    Hi
    I have a slow statement with bind Variables. With literals it works fine. Is there a way to replace the bind by literal in advanced ? I use Release 11.2.0.2.3
    Thank you

    904062 wrote:
    I have a slow statement with bind Variables. With literals it works fine. Is there a way to replace the bind by literal in advanced ? I use Release 11.2.0.2.3This specific scenario is very much an exception to the rule - and you need to back your statement up with execution plans of the SQL with bind variables and with literals, and run stats that show the difference between these two execution plans.
    See the {message:id=9360003} from the {forum:id=75} forum's FAQ for details on how to post a SQL performance tuning question.

  • ODT Query Window. Query with binding variable?

    I have the ODT 11.1.0.7.20 installed.
    In "Query Window", I execute an SQL with binding variables. But I only get ORA-01008 errors. How do I do that?
    I want to double click an SQL and load it in "Query Window". How do I do that?
    I want to right click an SQL and select "Open with Query Window". How do I do that?
    In Query Window I want to load an SQL either by drag and drop or by select a function "Open SQL". How do I do that?
    Why none of these functionalities work as you could expect?
    Thanks,
    Tobias

    Finally i found the problem..
    The problem was that i had to remove one line from the properties of my table departments, the property: selectedrowkeys, because it only passed the last selected row.
    Still, i apreciate the help and i had to replace some code in the bean.java , because of the exception error and you didn't had to do that. Maybe i did some configuration in the wrong way and it went wrong.
    Thanks for the help.
    Regards,
    Frederico.

  • Non supported version of SQL with new install of SCOM 2012 SP1

    I have SQL 2012 SP1 running on Server 2012.  I have tried the SCOM installation with and without CU2 (to fix the 1618 installation error)
    SC VMM installed cleanly and appears to work.
    The install for SCOM produces an error that says, "The installed version of SQL Server is not supported".  I have not been able to find any log from the install that has that error in it.
    Also, I have not been able to determine the true requirements of the SQL server for SCOM.  (I found dock SCOM 2012 RTM and SQL 2008 R2, but noting for 2012 SP1.
    Can someone point me to the correct place for the install log with (hopefully more information) and/or the requrements for the SQL installation?
    Roy

    The log is not created yet because it has not started the install.
    The firewall is the most common issue indeed. Temporarily Disable the firewall and see whether you can continue.
    Are you using a developers edition? The only 2 editions supported are standard and Enterprise.
    The true requirements for SCOM 2012 sp1:
    We recommend that you check for updates and hotfixes for SQL Server. Note the following database considerations for Operations Manager:
    SQL Server 2008 R2 and SQL Server 2012 are available in both Standard and Enterprise editions. Operations Manager will function with both editions.
    Operations Manager does not support hosting its databases or SQL Server Reporting Services on a 32-bit edition of SQL Server.
    Using a different version of SQL Server for different Operations Manager features is not supported. The same version should be used for all features.
    SQL Server collation settings for all databases must be one of the following: SQL_Latin1_General_CP1_CI_AS, French_CI_AS, Cyrillic_General_CI_AS, Chinese_PRC_CI_AS, Japanese_CI_AS, Traditional_Spanish_CI_AS, or Latin1_General_CI_AS.  No other collation
    settings are supported.
    The SQL Server Agent service must be started, and the startup type must be set to automatic.
    Side-by-side installation of System Center Operations Manager 2007 R2 reporting and System Center 2012 Service Pack 1 (SP1), Operations Manager reporting on the same server is not supported.
    The db_owner role for the operational database must be a domain account. If you set the SQL Server Authentication to Mixed mode, and then try to add a local SQL Server login on the operational database, the Data Access service will not be able to start.
    For information about how to resolve the issue, see System Center Data Access Service Start Up Failure Due to SQL Configuration Change
    If you plan to use the Network Monitoring features of System Center 2012 – Operations Manager, you should move the tempdb database to a separate disk that has multiple spindles. For more information, see
    tempdb Database.
    Found here:
    http://technet.microsoft.com/en-us/library/jj656654.aspx#BKMK_RBF_OperationsDatabase
    It's doing common things uncommonly well that brings succes.

  • How to activate evaluation version of SQL server

    How to activate evaluation version of SQL server 2012 with open license.
    in the VLS portal it is saying no product key is require. but my problem is i already installed evaluation version of SQL server 2012 and configure many things to it. after that i got open license from Microsoft,

    Hi,
    If you want to upgrade ( i Guess this is what you want) evaluation edition to enterprise or standard you need to run Ent/ standard edition from setup.exe installation window will pop up on that select maintenance on left side and then select edition
    upgrade.
    Take help of below link
    http://blogs.technet.com/b/sqlman/archive/2010/03/16/sql-server-2008-upgrading-to-standard-enterprise-edition-from-evaluation-edition.aspx
    revert if any issue.
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • Replacing Firefox 3.6.16 containing my history, bookmarks etc by version 4.0, I find that it will not open on my Mac Power PC G4 running on OS 10.4.11. Is there is a compatibility problem and how do I retrieve version 3.6 with my bookmarks etc

    Replacing Firefox 3.6.16 containing my history, bookmarks etc by version 4.0, I find that it will not open on my Mac Power PC G4 running on OS 10.4.11. Is there is a compatibility problem and how do I retrieve version 3.6 with my bookmarks etc.

    Firefox 4 requires at least OS X 10.5 and an Intel Mac. There is a third party version of Firefox 4 that runs on OS X 10.4/10.5 and PPC Macs, for details see http://www.floodgap.com/software/tenfourfox
    If you prefer, you can get the latest version of Firefox 3.6 from http://www.mozilla.com/en-US/firefox/all-older.html
    When you install one of the above it will use your existing bookmarks etc

  • How to maintain different versions of XI mapping in TPZ file ?

    How to maintain different versions of TPZ file ? Does any one have any idea ? Do we create a new software component for an upgraded version of mapping  or just creating a new namespace in the earlier software component would suffice ?
    Thanks,
    Nivedita

    please visit the blog
    /people/sap.india5/blog/2005/11/09/xi-software-logistics-ii-overview

  • Needs help to know the different versions of forms with their compatibility

    Needs help to know the different versions of forms with their compatibility with different databases and operating systems.
    Kindly give the details or any suitable link for the same.
    please consider it as on urgent basis.
    regards,
    rajesh

    Rajesh,
    the certification matrix is available on metalink.oracle.com. You need a support contract to access this information.
    Frank

  • SQL query with Bind variable with slower execution plan

    I have a 'normal' sql select-insert statement (not using bind variable) and it yields the following execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=7 Card=1 Bytes=148)
    1 0 HASH JOIN (Cost=7 Card=1 Bytes=148)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=4 Card=1 Bytes=100)
    3 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=3 Card=1)
    4 1 INDEX (FAST FULL SCAN) OF 'TABLEB_IDX_003' (NON-UNIQUE)
    (Cost=2 Card=135 Bytes=6480)
    Statistics
    0 recursive calls
    18 db block gets
    15558 consistent gets
    47 physical reads
    9896 redo size
    423 bytes sent via SQL*Net to client
    1095 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    I have the same query but instead running using bind variable (I test it with both oracle form and SQL*plus), it takes considerably longer with a different execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=407 Card=1 Bytes=148)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=3 Card=1 Bytes=100)
    2 1 NESTED LOOPS (Cost=407 Card=1 Bytes=148)
    3 2 INDEX (FAST FULL SCAN) OF TABLEB_IDX_003' (NON-UNIQUE) (Cost=2 Card=135 Bytes=6480)
    4 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=2 Card=1)
    Statistics
    0 recursive calls
    12 db block gets
    3003199 consistent gets
    54 physical reads
    9448 redo size
    423 bytes sent via SQL*Net to client
    1258 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    TABLEA has around 3million record while TABLEB has 300 records. Is there anyway I can improve the speed of the sql query with bind variable? I have DBA Access to the database
    Regards
    Ivan

    Many thanks for your reply.
    I have run the statistic already for the both tableA and tableB as well all the indexes associated with both table (using dbms_stats, I am on 9i db ) but not the indexed columns.
    for table I use:-
    begin
    dbms_stats.gather_table_stats(ownname=> 'IVAN', tabname=> 'TABLEA', partname=> NULL);
    end;
    for index I use:-
    begin
    dbms_stats.gather_index_stats(ownname=> 'IVAN', indname=> 'TABLEB_IDX_003', partname=> NULL);
    end;
    Is it possible to show me a sample of how to collect statisc for INDEX columns stats?
    regards
    Ivan

  • All sqls executed by an user with a timeframe with bind variables.

    10.2.0.4 Version.
    Is there a way to get list of all the sqls executed by an user between time t1 and t2 with bind variables along with the stats from v$sql.
    I am able to get binds from v$sql_bind_capture for an user but not able to restrict to the time frame I want.
    Thanks for help in advance.

    Enable 10046 trace (level=12) for the sessions in question.
    Make sure you have enough free space available as this could result in a huge file depending on session's activity.
    Asif Momen
    http://momendba.blogspot.com

  • Query with bind variable, how can use it in managed bean ?

    Hi
    I create query with bind variable (BindControlTextValue), this query return description of value that i set in BindControlTextValue variable, how can i use this query in managed bean? I need to set this value in String parameter in managed bean.
    Thanks

    Put the query in a VO and execute it the usual way.
    If you need to, you can write a parameterized method in VOImpl that executes the VO query with the parameter and then call that method from the UI (as a methodAction binding) either through the managed bean or via a direct button click on the page.

  • How to querie with bind variable in findMode?

    Hallo,
    is it possible to use a querie with bind variable in findMode? And when how is it possible to initialize the bind variable?
    Any help is appreciated.

    Hi,
    bind variables can be linked from teh ADF binding to e.g. a managed bean, the sessionScope or other binding attributes via EL. So when you go into findMode and execute the query, the EL will grab the bindVariable values automatically.
    Frank

Maybe you are looking for