Problems with Bind Variables
SELECT co.ref_num, co.forename, co.surname, co.dob, a.address, a.postcode,
co.ni_num
FROM address a, contact co
WHERE co.ref_num = a.ref_num
AND (:1 IS NULL OR co.forename = :2)
AND (:3 IS NULL OR co.surname = :4)
AND (:5 IS NULL OR a.postcode = :6)
AND (:7 IS NULL OR a.address = :8)
AND (:9 IS NULL OR co.dob = :10)
AND (:11 IS NULL OR co.ni_num = :12)
With a jdbc connection, we use a web front end for a new management system. The SQL above runs since a search screen. We meet a few serious problems with bind variable and execution plans. When the above query is sent by the database 'AND' clauses could evaluate as follows:AND ('Tim' IS NULL OR co.forename = 'Tim')
AND ('Clarke' IS NULL OR co.surname = 'Clarke')
AND ('' IS NULL OR a.postcode = '')
AND ('' IS NULL OR a.address = '')
AND ('25051981' IS NULL OR co.dob = '25051981')
AND ('' IS NULL OR co.ni_num = '')
We cannot dynamically assign 'AND' conditions so they are sent through to the database. This translates FTS 99% of the time as the execution plan never prescribed any of the available indices.Someone has suggestions on how to better 'control' bind variables?
Hello
Don't you think that 'OR' Conditions are necessary to check for Null, where the binding variable is NULL or not.
I think that rather than running the query from the front to FB, try to convey the values of some MS and run this query in the procedure, the extraction from the point of view Design coding application. Never fire the query of the frontal part.
To come to the problem.
SELECT co.ref_num, co.forename, co.surname, co.dob, a.address, a.postcode,
Co.ni_num
ADDRESS, contact co
WHERE co.ref_num = a.ref_num
AND (: 1 co.forename IS NULL or =: 2)
AND (: 3 co.surname IS NULL or =: 4)
AND (: 5 a.postcode IS NULL or =: 6)
AND (: 7 a.address IS NULL or =: 8)
AND (: 9 co.dob IS NULL or =: 10)
AND (: 11 co.ni_num IS NULL or =: 12)
Use the procedure.
Fact exits of the indexes on the tables and stats are updated...?
Try to predict explain it. ??
-Pavan Kumar N
Tags: Database
Similar Questions
-
problem with bind variables in the SQL query view object
Hi all
I use JDev 11.1.2.4.0.
I have a problem with bind variables in the SQL query view object.
This is my original SQL
SELECT sum(t.TIME) , t.legertype_id FROM LEDGER t WHERE t.nctuser_id = '20022' AND to_char(t.insertdate,'YYYYMMDD') in ('20130930','20130929') group by t.legertype_id
In my view .xml object query tab, I am writing this
SELECT sum(t.TIME) , t.legertype_id FROM LEDGER t WHERE t.nctuser_id = '20022' AND to_char(t.insertdate,'YYYYMMDD') in :dddd group by t.legertype_id
Davis here is a variable of Type liaison: String, updatable and necessary.
I try to deal with Davis as ('20130930 ', ' 20130929') hoping the view object, run as my original SQL.
But failed. The view object retrieves 0 line after that I run.
Why?
Thank you! ('2original SQL0130930', '20130929') ('20130930 ', ' 20130929')
A variable binding cannot be used as this is why you must use years table. Check decompilation binary ADF: using oracle.jbo.domain.Array with ViewCriteria to see a solution.
Timo
-
Problem with Bind variable cannot be changed.
Hi all
I use Jdev 11.1.2.3.0. In my VO, I created a Bind Variable and set it NOT UPDATABLE. Then, I created a display with some other Variables Bind criterion.
I use this criterion to display on a search page, but when running, I see also an inpunt for the defined variable NOT UPDATABLE text and I can't change its value.
Of course, if I try to change the value, and I do research, I get an error.
It is the source of the VO:
< variable
Name = "UlssVar".
Type = "where".
Type = "Java.lang.String"
IsUpdateable = "false" >
< TransientExpression > <! [CDATA [adf.context.current.sessionScope.get ('ulss')]] > < / TransientExpression >
< / variable >
Is this a bug of the ADF?
I thank in advance.Hello
try selecting the variable binding and open the property inspector, under the guidance of the user interface, set the flag of 'view' to hide. This should hide it (no bug for this reason)
Frank
-
Problem with bind variable and as operator usage
Hi all
I use JDeveloper Version - 11.1.2.4.39.64.36.1 .
While implementing the search functionality in the hierarchical Viewer, I created a link in the underlying t variable, created to find, due east of the request-
SELECT XxamAnkitObjects.ID,
XxamAnkitObjects.OBJECT_NAME,
XxamAnkitObjects.OBJECT_TYPE,
XxamAnkitObjects.PARENT,
XxamAnkitObjects.PARENT_ID,
XxamAnkitObjects.PARENT_TYPE
OF XXAM_ANKIT_OBJECTS XxamAnkitObjects
WHERE object_name like ' %: o_name ".
What I'm trying to accomplish here, it is that the input provided by the user in the search box must match with the object_name in the table.
During execution, I met the following error (from newspapers WLS)-
< QueryCollection > < buildResultSet > [598] java.sql.SQLException: try to set a parameter name that does not intervene in the SQL: o_name
at oracle.jdbc.driver.OraclePreparedStatement.setNullAtName(OraclePreparedStatement.java:5384)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setNullAtName(OraclePreparedStatementWrapper.java:1451)
The following query has been generated during the operation of a research-
< ViewObjectImpl > < buildQuery > [593] SELECT XxamAnkitObjects.ID, XxamAnkitObjects.OBJECT_NAME, XxamAnkitObjects.OBJECT_TYPE, XxamAnkitObjects.PARENT, XxamAnkitObjects.PARENT_ID, XxamAnkitObjects.PARENT_TYPE XXAM_ANKIT_OBJECTS XxamAnkitObjects WHERE object_name like ' %: o_name ".
< ViewObjectImpl > < bindParametersForCollection > [594] params for ViewObject Bind: [model.vo.ObjectNameSearch] AppModule.ObjectNameSearch1
Advice kindly the way ahead.
Best regards
Ankit Gupta
The problem is that you used quotes around the variable binding. Try
SELECT XxamAnkitObjects.ID, XxamAnkitObjects.OBJECT_NAME, XxamAnkitObjects.OBJECT_TYPE, XxamAnkitObjects.PARENT, XxamAnkitObjects.PARENT_ID, XxamAnkitObjects.PARENT_TYPE FROM XXAM_ANKIT_OBJECTS XxamAnkitObjects WHERE object_name like '%' || :o_name || '%'
A note: this type of query will do a full table scan, as the searches with wildcards to the left cannot use a regular index. If you have multiple lines, this will impact on the research persormance hughe!
Timo
-
I will execute bind_test.sql with the following parameters to sql-plus. The script runs without error. However, it does not insert a row in the table.
bind_test. 20100912 1 1001 SQL;
bind_test. SQL
----------------------------------------------------------
Set serveroutput on
declare
X VARCHAR2 (31);
NUMBER OF Y;
NUMBER OF Z;
Start
dbms_output. Enable (10000);
X: = "& 1";
Y: = & 2;
Z: = & 3;
Insert in the test
values (TO_DATE (X, 'YYYYMMDD'), Y, Z, null, null, null);
commit;
dbms_output.put_line ('var1 = "|") X | "var2 =" | THERE | "var3 = ' |" (Z);
end;
/
----------------------------------
Output:
10 old: X: = "& 1";
10 new: X: = '20100912';
old 11: Y: = & 2;
11 new: Y: = 1;
12 old: Z: = & 3;
12 News: Z: = 1001;
var1 = 20100912 var2 = 1 var3 = 1001
PL/SQL procedure successfully completed.
---------------------------------------
Select * from test;
no selected line
Why it is not insert a line? What could be the reason?
Thanks in advance.
Amituser5922214 wrote:
I have a big script with multiple INSERT and DELETE statements. I have been asked by DBA to use bind variables rather than direct assignment parameter values in which the condition.
Impossible.
Use of variable bind from a client means:
(1) customer create a unique SQL cursor with bind variable, for example INSERT INTO FOOTABLE VALUES (: 1,: 2: 3)
(2) customer from a loop of data read
2.1) reading the customer data (from file, network, device, whatever)
customer liaison variables 2.2) cursor (assigning values to 1 to 3 SQL cursor variables)
2.3) client running the cursor
line insertions 2.4) database
loop repetitions of 2.5) client for all data
(3) customer closed the SQL cursorThis can be done using a SQL script - as a SQL script is not a loop where a single insertion cursor is used. It's a unique script with 100 or 1000 of SQL insert statements. Where each insert statement will result in a cursor SQL must be created.
SQL * also does not support the approach of customer liaison above variable. It is a command line interface very PRIMITIVE and unsuitable for running scripts from loading/data entry.
In your case - the right approach would be to have the data into a CSV file, and then load this file using SQL * Loader... where this software will use customer approach above (in fact he still does better because it uses in bulk link and link not row as described above).
-
Query report back "No data found" with bind variables
I put a simple query in the report query:
Select "bluefish". 'name' as 'name',
"bluefish". "" primary_flag "as"primary_flag. "
"bluefish". "" status "than"status. "
"bluefish". ' ' ID ' as 'ID' of "bluefish" "bluefish" where "bluefish". "" ID "=: P3_XPRINTID
When I test the query, the data is returned. However, when I try to run the query using the "Test report" button, I get an error 01403 no data found. If I replace the link with an explicit value variable, the report runs.
Anyone have any ideas as to what is causing this problem? I use the generic report layout, with different types of output. I'M editting the query and set the binding variable before test report (otherwise, the query is not executed).
CharlesIn fact the report would go - unlike other products of Oracle who complain about a missing binding variable, Apex is not complaining but interprets as a null value. So if you hurt typed the name of your variable, you are never alerted to it.
Check the Session window to make sure that it is a value - the most common questions are that you named the wrong variable in the query or your item has no value in session state again.
-
Need help with Bind variable in AF LOV query
Hello
I have a problem with the binding variable, if I use bind variable in the VO LOV query then my result does not come, if he has do not bind variable it works fine and if I use the variable binding in the LOV search option then it works fine but if I hide the bind variable and set the value in the prepareSesstion AM method the LOV does not return any value. I try to return the values that also all values are also coming, but these values are not the attribute query AF setting.
Query is:
Select substr(d.description,0,40) description
cm_system_users has
b cm_user_responsibilities,
cm_responsibility_processes c,
cm_processes d
where a.nt_login =: B_NT_LOGIN
and a.user_id = b.user_id
and trunc (sysdate) between b.eff_date and nvl (b.exp_date, sysdate + 1)
and b.RESPONSIBILITY_ID = c.RESPONSIBILITY_ID
and c.process_type = d.process_type
and d.enabled_flag = 'Y' order of d.arguments_flag
FOLLOW the method:
CmProcessViewImpl vo = getCmProcessView();
String nt_login = getUserPrincipalName();
vo.setNamedWhereClauseParam ("B_NT_LOGIN", nt_login.toUpperCase ());
vo.executeQuery ();
Can someone help me with this. It is urgent for me.It's a bit underdescribed. IIUC, the purpose of the notice is used as a target for a correct view accessor? (Otherwise, you will have to be more explicit about what you mean by "LOV query".
If I'm right, there are two possibilities:
(1) you use an instance of VO in a module shared application instance. If so, make sure that your code is in the prepareSession() for the class of application that module if it is dependent on session (as seems to be below), you must make sure that the module of the application instance is shared in the session scope.
(2) you have based the view accessor directly on the definition of the VO. This creates an anonymous instance of VO; I don't think there is a way to use prepareSession() to set a variable of liaison on such a forum (which will not be created until the accessor is first used). Pourriez be able to shoot with to put a similar code in the view object create() method class, but I've not tested this.If your code is in your module class application primary (as opposed to the class for a shared of AOS instance), the problem here is that getCmProcessView() returns the instance of VO data module of this application instance design-time model, which is never used by accessors of the view.
Also, why do you need to do this in prepareSession() rather than at the level of the accessor to view? I believe you can get the user name (for the view accessor) with the groovy expression
viewObject.DBTransaction.session.userPrincipalName
or maybe just
DBTransaction.session.userPrincipalName
(despite this DBTransaction involving, it returns the username web app, not the DB user name).
It is a declarative 100% solution, if you don't count the Groovy expression as not declarative.
If you are afraid of a user who is running the LOV (somehow) before the value of the bind variable is preparing, just make sure that the binding variable is marked "required."
-
Estimates of cardinality for index range scan with bind variables
Oracle 11.2.0.4
I am struggling to explain that the cardinality estimates for a scan of the index systematic range when using the bind variable.
Consider the following query:
SELECT /*+ INDEX(t1) */ * FROM t1 WHERE source_id <= ?;
Cardinalities for the INDEX RANGE SCAN and ACCESS of the TABLE are the same for different literal predicates, for example, source_id < = 5:
------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 50 | 350 | 12 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID| T1 | 50 | 350 | 12 (0)| 00:00:01 | |* 2 | INDEX RANGE SCAN | IX1 | 50 | | 2 (0)| 00:00:01 | ------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("SOURCE_ID"<=5)
If a variable binding is used instead of a literal, the overall selectivity is 5%. However, why the optimizer based on CSSTidy gives a cardinality estimated 11 for the scan of the index systematic range? As with the predicates literal, surely the cardinalities of the index range scan and access table should be the same?
------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 50 | 350 | 5 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID| T1 | 50 | 350 | 5 (0)| 00:00:01 | |* 2 | INDEX RANGE SCAN | IX1 | 11 | | 2 (0)| 00:00:01 | ------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("SOURCE_ID"<=TO_NUMBER(:A))
Unit test code:
CREATE TABLE t1 ( id NUMBER , source_id NUMBER ); CREATE INDEX ix1 ON t1 (source_id); INSERT INTO t1 SELECT level , ora_hash(level,99)+1 FROM dual CONNECT BY level <= 1000; exec DBMS_STATS.GATHER_TABLE_STATS(user,'T1') EXPLAIN PLAN FOR SELECT /*+ INDEX(t1) */ * FROM t1 WHERE source_id <= 5; SELECT * FROM TABLE(dbms_xplan.display); EXPLAIN PLAN FOR SELECT /*+ INDEX(t1) */ * FROM t1 WHERE source_id <= :a; SELECT * FROM TABLE(dbms_xplan.display);
There are various places where the optimizer uses an assumption, and lie unpeekable (and of Villa "unknowable value") introduced guess.
For unpeekable binds the conjecture for column<= {unknown}="" is="" 5%="" for="" table="" access="" (hence="" 50="" rows="" out="" of="" 1,000),="" but="" it's="" 0.009="" for="" index_column="">=><= {unknown},="" which="" means="" i="" was="" expecting="" to="" see="" 9="" as="" the="" row="" estimate="" on="" the="" index="" range="">=>
I just ran some quick tests, and EXPLAIN the PLAN seems to just use 0.011 selectivity in this case (in different versions of Oracle) although if we do the bind variable unpeekable at run time (and sample dynamic block etc.) optimization for execution is 0.009%.
Concerning
Jonathan Lewis
Update: and this is a very old reference to the 0.009 (and 0.0045 for ' between the ' when it is applied to a clue: cost based Oracle - access Chapter 4 single B-tree )
-
R12 Extension with bind variables-how VO EO
Hello
I extended an APInvDistAllVO view object by adding two fields which are functions. Basically, in the invoice approval screen, I want to add two fields where the distribution of the invoice is shown.
the SQL contained in jdeveloper when you extend the VO object is different from the query, what I see in the invoice approval page by clicking on the APInvDistAllVO link. There are two bind variable: 1 = invoice_id and: 2 = line_number being added dynamically.
After the extension of the view object, the invoice distribution line is displayed as no record found. In my opinion, it is due to not having bind variables does not correct parameters being passed, and under this point of view object is an object depending on the invoice header record.
Will be very grateful if someone can provide the way forward in dealing with this situation.
Rgds
Fahad
User, please ask your question in the forum OA Framework .
Timo
-
EO base extension VO with bind variables and display - How To link
Hello
I extended an APInvDistAllVO view object by adding two fields which are functions. Basically, in the invoice approval screen, I want to add two fields where the distribution of the invoice is shown.
The SQL contained in jdeveloper when you extend the VO object is different from the query, what I see in the invoice approval page by clicking on the APInvDistAllVO link. There are two bind variable: 1 = invoice_id and: 2 = line_number being added dynamically. After the extension of the view object, the invoice distribution line is displayed as no record found.
In my opinion, it is due to not having bind variables does not correct parameters being passed, and under this point of view object is an object depending on the invoice header record. There is a link to the original View object as well. Will be very grateful if someone can provide the way forward in dealing with this situation.
Rgds Fahad
Hi AJ
He worked after changing the style of bind.
Thank you very much.
Rgds
Fahad
-
Hi all
I have a view object with a query that uses a variable binding. I drag the data on my .jsf page control to create a table. I create a query method on a bean in sight. The query method uses the content of one of the attributes of the bean to set the link for the query variable:
vo.setNamedWhereClauseParam ("CraIdBindVar", sessionBean.getCraId ());
I put a button on the page that calls the method of the request and it fills the table. That's fine, but I don't want the user to have to click the "query" button when browsing this page. I found forums dealing with create an AMImpl.jave method, create a link on the page, create an executable file for the link. It works that the method is executed until the page appears. However, the AMImpl method cannot call sessionBean.getCraid () to obtain the data required to complete the binding variable.
Is it possible to run my method of view range bean before the page is displayed? Or maybe a way for the AMImpl.java method to access the range of view variable?
Thank you, SteveSteve,
You can drag a call method on the workflow activity. Select the new method call activity, and open the property inspector. Here you choose your bean method in the method property. Now, first of all, you go to this activity of method call, then the page.Timo
-
Create the collection of query with bind variable
Apex 4.0.2
By Joel the apex_collection.create_collection_from_query_b supports queries containing references to the bind variables (: P1_X) but I don't know how to use this feature, the documentation is not an example, just the API signature for the overloaded version has changed.
If the query contains 2 bind session state variable references (: P1_X and: P1_Y), can someone please show an example of what to spend for the parameters p_names and p_values to the API?
Thank you
procedure create_collection_from_query_b( -- -- Create a named collection from the supplied query using bulk operations. The query will -- be parsed as the application owner. If a collection exists with the same name for the current -- user in the same session for the current Flow ID, an application error will be raised. -- -- This procedure uses bulk dynamic SQL to perform the fetch and insert operations into the named -- collection. Two limitations are imposed by this procedure: -- -- 1) The MD5 checksum for the member data will not be computed -- 2) No column value in query p_query can exceed 2,000 bytes -- -- -- Arguments: -- p_collection_name = Name of collection. Maximum length can be -- 255 bytes. Note that collection_names are case-insensitive, -- as the collection name will be converted to upper case -- p_query = Query to be executed which will populate the members of the -- collection. If p_query is numeric, it is assumed to be -- a DBMS_SQL cursor. -- example(s): -- l_query := 'select make, model, caliber from firearms'; -- apex_collection.create_collection_from_query_b( p_collection_name => 'Firearm', p_query => l_query ); -- p_collection_name in varchar2, p_query in varchar2, p_names in wwv_flow_global.vc_arr2, p_values in wwv_flow_global.vc_arr2, p_max_row_count in number default null) ;
HELEN wrote:
Apex 4.0.2By Joel Re: Collection with variable binding the apex_collection.create_collection_from_query_b supports queries containing references to the bind variables (: P1_X) but I don't know how to use this feature, the documentation is not an example, just the API signature for the overloaded version has changed.
If the query contains 2 bind session state variable references (: P1_X and: P1_Y), can someone please show an example of what to spend for the parameters p_names and p_values to the API?
Not tried, but guess something like
apex_collection.create_collection_from_query_b( p_collection_name => 'foobar' , p_query => 'select f.foo_id, b.bar_id, b.baz from foo f, bar b where f.foo_id = b.foo_id and f.x = to_number(:p1_x) and b.y = :p1_y' , p_names => apex_util.string_to_table('p1_x:p1_y') , p_values => apex_util.string_to_table(v('p1_x') || ':' || v('p1_y')))
-
Problem using bind variables in shared components report queries
Greetings,
I use APEX 4.0.1.00.03 and BI Publisher 10.1.3.4.1.
In the APEX, I try to create a report query that uses bind variables in the where clause. I have a page that contains a button and a text element (P1_ID). The button is used to call the report. I went the shared components and created a new report query. Here is the text of the code.
I also have Session State to enabled and have added the P1_ID in the area of 'State of Session' under the query.select violation_date , violation_type , nvl(:P1_ID,'zzz') from edd_procard_violations where upper(card_holder_id) = upper(:P1_ID)
When I change the query, and click on the 'Set Bind Variables' button, I get a field where I can enter a value for: P1_ID I enter a value that should return lines, but when I click on the button "Test query", I get no rows returned. If I comment on where clause and test the query, even once, I get all rows in the table. You'll notice in my query I have included nvl(:P1_ID,'zzz'). When I run the query, without where clause, the returned value is always "zzz" indicating that: P1_ID is null.
No idea what I am doing wrong?
Thank you very much.
LarryHello Larry,.
Looks like the wizard to create a report query in the shared components has a bug related to bind variables. I was able to reproduce your problem. Just create the query using the link variable, check the box to include session state, add the item and create the query. When you use the report query to download the report, where the your clause will work fine.
Thank you
Machaan -
IN construction in the clause WHERE of VO with bind variable
Hello
With the help of JDev 11.1.1.3.0.
I have a SQL according to VO following where clause ' WHERE some_nbr IN: inSomeNbrStr'
-l' some_nbr attribute is of type oracle.jbo.domain.Number.
-variable binding inSomeNbrStr is of type String.
I'm assuming that this variable linking parameter to for example. "101, 102' or '(101, 102) ' before the execution of the query might work.
"However, I get ' ORA-01722: invalid number." Other than the substitution of executeQueryForCollection() and manipulate by program the
query is - anyone know a more declarative way to achieve this?
Thank you
KennethHello
You "MOUNT" the binding variable to get the values separated by commas.
See this article (Search Using Comma-Separated bind string for the Variable in the list) on how to achieve this.
It has been developed over 10g. But I think it will hold good for 11g as well.
Arun-
-
Hi all
It could be more a matter of sql pl but I am trying to create a collection in the apex where the query uses a connection variable. I can't get this application to work.
It works
p_query = > 'select je_batch_id in the gl_je_batches where default_period_name = "MAY-10" ',
but I can't make it work with a variable binding.
p_query = > ' select je_batch_id in the gl_je_batches where default_period_name =: P14_EPSB_ARGYLL_PERIODS: ',
any help would be greatly appreciated.
Thank youHello
Try
APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY_B( p_collection_name => 'MY_COLLECTION', p_query => 'select je_batch_id from gl_je_batches where default_period_name = v(''P14_EPSB_ARGYLL_PERIODS'')' );
BR, Jari
Maybe you are looking for
-
I prefer NOT to send eMails immediately I touched the button 'SEND', but having to drop a menu down to 'send later' is a pain Can I configure Thunderbird to always send later or add a button "Send later" to my toolbar? Thank you
-
How can I fix? iPhone and iPad are visible to each other in parachute drop but they does not see my Macbook Pro.
-
from f/fox I have AVG request if it can change computer, its boring.
using F/fx as my search engine on the opening he asks me if he can change the settings of the computer
-
I need to access older versions of FireFox and checksum for these files.
For each version below, I need to download installation file and checksum md5/shaXXX of Mozilla for each download. WindowsOS: Firefox v3.5, v3.6 Solaris 10 x 86: Firefox v3.5, v3.6 Solaris sparc: v3.6.17 Firefox filename: firefox-3.6.17.en-US.solaris
-
Hello I recently bought a new Satellite U400-15e and assumed he had installed bluetooth. After turning the switch of communication, I put my phoneto search for devices, but he found nothing. I tried to get several times with the same result. So I gue