Run the query in accordance with condition
Oracle 10g version
Hi gurus
I have the following data
Examples of data
SELECT DeptNo FROM scott.emp
UNION ALL
SELECT EmpNo FROM scott.emp
;
Now what I want is I want to execute conditionally of those surveyed, something like below:
If list_item = 'I', then run below
SELECT DeptNo FROM scott.emp
otherwise run below
SELECT EmpNo FROM scott.emp
End if;
------
I want to keep the union all and run the query under the terms...
Set a long tank (max 4000)
L_WHERE_CLAUSE
Use it in your application as a substitution variable by prefixing with &
WHERE & L_WHERE_CLAUSE
Assign the value into a pl/sql block (trigger, formula column)
IF condition THEN
L_WHERE_CLAUSE: = '1 = 1';
ON THE OTHER
L_WHERE_CLAUSE: = '1 = 2';
END IF;
Now, among the options that have been suggested to you and the information you provided, I think the solution of Solomon should be easier. Just refer to the column list_item has a link within your query variable (assuming that this and the query where list_item belongs are related, for example, there is a join between them)
SELECT DeptNo FROM scott.emp, t
WHERE: list_item = 'l '.
UNION ALL
SELECT EmpNo FROM scott.emp, t
WHERE nvl(:list_item,'x')! = « l »
Tags: Database
Similar Questions
-
Run the query according to the transaction.
Hi all
I am able to run the query, but I want to run query award date.
I created the timer for shape and I want when user update the record for the same registration date must run, do not run the query from the previous day.
is this possible?
can someone help me?
SarahSee other thread
-
Is it possible to run a query of IdocScript with GET_SEARCH_RESULTS of Service?
Hi all
I need to run the query with GET_SEARCH_RESULTS service below.
xSubmissionDate "ArchivePackage" < AND > dDocType < match > < 8 October 13 11:03 ' < AND > xArchiveDocName < EQUALS > dDocName
Part of this query works fine, but when the part in BOLD is also used I get an error, reason be there there is nothing like < EQUALS > when you use the Query Builder
Instead it is possible to run the idocscript with any service below?
<$ (dDocType as "ArchivePackage") & xSubmissionDate < dateCurrent(-365) & (XArchiveDocname == dDocname) $>I tried with GET_SEARCH_RESULTS, but received erroneous results and no mistake.
Is this even possible or should I just change my approach?
Concerning
What about the GET_DATARESULTSET service?
required params:
dataSource = Documents
resultName =
whereClause = (revisions.dDocType = 'ArchivePackage' AND DocMeta.xArchiveDocName = Revisions.dDocName and...) / / pure SQL where clause
-
use F8 &; F10 keys on the keyboard to run the query and save a form
I created a screen. Here I can save by pressing CTRL + S (written a validation key trigger) or the button Save, I placed.
Now the user want to F10 to save & key F8 to run the query.
How can I do? Should what trigger I write the code...
I use oracle 10g and oracle developer suite 10 g.
I have fmrweb.res as follows:-
9: 0: 'Tab': 1: "then on the ground."
9: 2: "Ctrl + Tab": 1: "then on the ground."
9: 1: "Shift + Tab": 2: "previous field.
9: 3: 'Shift + Ctrl + Tab': 2: "previous field.
85: 2: "Ctrl + U": 3: "clear the field".
38: 0: 'Up': 6: 'Up '.
40: 0: 'Down': 7: "Down".
33: 0: 'PG': 12: "scroll to top".
34: 0: "PageDown": 13: "scroll."
69: 2: 'Ctrl + E': 22: 'Edit '.
10: 0: "Enter": 27: «Back»
120: 0: 'F9': 29: "list of values".
76: 2: "Ctrl + L": 29: "list of values".
81: 2: 'Ctrl + Q': 32: "Exit".
75: 2: "Ctrl + K": 35: 'display keys '.
112: 2: 'Ctrl + F1': 35: 'display keys '.
83: 2: 'Ctrl + S': 36: 'engage '.
121: 2: "F10": 36: 'engage '.
114: 1: 'SHIFT + F3': 61: 'next primary key '.
115: 1: "SHIFT + F4": 62: "delete folder".
117: 1: "SHIFT + F6": 63: 'delete folder '.
115: 0: "F4": 64: "Double registration".
117: 0: 'F6': 65: "insert record".
119: 1: "SHIFT + F8": 66: "a next Recordset.
1005: 0: 'Down': 67: "then save.
1004: 0: 'Up': 68: "history".
40: 1: 'Shift + down': 67: "then save.
38: 1: "shift + up": 68: "history".
116: 1: "Shift + F5": 69: 'clear the block '.
116: 0: 'F5': 70: "block the Menu."
34: 1: "shift + page down": 71: 'then block '.
33: 1: ' shift + Pg. Prev ': 72: "previous block.
34: 2: "Ctrl + PG. Next": 71: 'then block '.
33: 2: "Ctrl + PG. Prev': 72: "previous block.
114: 0: "F3": 73: "duplicate field '.
118: 1: "Shift + F7": 74: 'clear form '.
118: 0: "F7": 76: "enter the query."
119: 0: 'F8': 77: 'execute the query. "
122: 0: 'F11': 76: "enter the query."
122: 2: "Ctrl + F11": 77: 'execute the query. "
112: 1: "SHIFT + F1": 78: "error to display.
80: 2: 'Ctrl + P': 79: 'print '.
113: 1: "SHIFT + F2": 80: "request Count".
123: 0: "F12": 81: "update file".
121: 3: 'Shift + Ctrl + F10': 82: "function 0".
112: 3: 'Shift + Ctrl + F1': 83: «Function 1"»
113: 3: 'Shift + Ctrl + F2': 84: «Function 2"»
114: 3: 'Ctrl + Shift + F3': 85: «function 3"»
115: 3: 'Shift + Ctrl + F4': 86: «function 4"»
116: 3: 'Shift + Ctrl + F5': 87: «Function 5"»
117: 3: 'Shift + Ctrl + F6': 88: «function 6"»
118: 3: 'Shift + Ctrl + F7': 89: «Function 7"»
119: 3: 'Shift + Ctrl + F8': 90: «Function 8"»
120: 3: 'Shift + Ctrl + F9': 91: «Function 9"»
113: 0: 'F2': 95: "list of tab Pages.
72: 2: "Ctrl + H": 30: "Help".
112: 0: 'F1': 30: "Help".
Please suggest...Hello.
First of all check that you have set "term" among others in the variable 'otherparams' in formsweb.cfg
For example:
otherparams = expression = term %
Then make sure that you put the correct path for the keyboard mapping file in the variable "term" as I wrote in the previous post.
Things should work as I did several times.
Best regards.
-
Hello
I have a form based on the table that store only 1 card. I have created a form page, but may not know how to run the query and display the record in the table. If there is no record in the table, I want that the user can use this page to create a record.
Thanks in advance
NRIHello Nri,
What value does P18_SCHOOL_ID?
If you look at the State of Session (toolbar) developer. If that does not have a value, it's your problem.You can create a calculation before the process that gives the correct value. (In one case more often, you have a report and when you click on the link change that id is activated and you see the recording in your form)
Dimitri
-
Run the query with multiple parameters
Dear
Motion code below for the data is of per_all_people_f, who works for only one setting, when I pass 2 parameters, then is to take the last of them fail times two, could you pls advice how it both join in where clause.
================================================================================
--------------------------------control file ----------------------------------
================================================================================
' Public Sub processFormRequest (pageContext OAPageContext, OAWebBean webBean)
{
super.processFormRequest (pageContext, webBean);
Am = (OAApplicationModule) pageContext.getApplicationModule (webBean) OAApplicationModule;
OAApplicationModule am = pageContext.getRootApplicationModule ();
String model = pageContext.getParameter ("ALL");
String pempno = pageContext.getParameter ("paramEmpNo");
String phiredt = pageContext.getParameter ("paramHireDate");
System.out.println ("control controller exucution");
If (pageContext.getParameter ("GetData")! = null)
{
System.out.println ("controller exucution");
Boolean ExecuteQuery = BooleanUtils.getBoolean (false);
[Serializable] parameters = {pempno, phiredt, model, executeQuery};
Class [] paramTypes = {String.class, String.class, String.class, Boolean.class};
am.invokeMethod ("initSummary", parameters, paramTypes);
OAAdvancedTableBean = table
(OAAdvancedTableBean) webBean.findChildRecursive ("ResultsTable");
When a user of handling started looking, we always need to run
the query, so we move on 'false' to queryData().
table.queryData (pageContext, false);
}
}
================================================================================
-Request module file-
================================================================================
public void initSummary (string model,
String ParmEmpNum,
String ParmHireDt,
String created,
String showMyOrders,
Boolean ExecuteQuery)
{
xxEmployeeVOImpl vo = getxxEmployeeVO1();
If (vo is nothing)
{
Tokens [] MessageToken = {new MessageToken ("parameter", "xxEmployeeVO")};
throw new OAException ("AK", "FWK_TBX_OBJECT_NOT_FOUND", chips);
}
vo.initQuery (model, ParmEmpNum, ParmHireDt, executeQuery);
System.out.println ("calling vo...");
}
================================================================================
-xxEmployeeVOImpl-
================================================================================
public void initQuery (String, String ParamEmpNum, String ParmHireDt, Boolean executeQuery model)
{
StringBuffer whereClause = new StringBuffer (100);
Whole CheckWhere;
Vector of parameters = new Vector (3);
setWhereClause (null);
setWhereClauseParams (null);
Integer bindCount = 0;
String WhereClause = null;
If ((ParamEmpNum! = null) & & (!("".)) Equals (ParamEmpNum.Trim ()))
{
setWhereClause (null);
setWhereClauseParams (null);
setWhereClause ("EMPLOYEE_NUMBER =:" + CheckWhere);
setWhereClauseParam(0,ParamEmpNum);
System.out.println ("request" + this.getQuery ());
System.out.println ("ParamEmpNum" + ParamEmpNum);
CheckWhere = CheckWhere ++;
}
If ((ParmHireDt! = null) & & (!("".)) Equals (ParmHireDt.Trim ()))
{
CheckWhere = CheckWhere ++;
If (CheckWhere > 1)
{
setWhereClause (null);
setWhereClauseParams (null);
setWhereClause ("AND START_DATE =:" + CheckWhere);
setWhereClauseParam(0,ParmHireDt);
System.out.println ("request" + this.getQuery ());
}
on the other
{
{setWhereClause (null);
setWhereClauseParams (null);
setWhereClause ("START_DATE =:"+ CheckWhere ");
setWhereClauseParam(0,ParmHireDt);
System.out.println ("request" + this.getQuery ()) ;}
}
System.out.println ("ParamEmpNum" + ParmHireDt);
}
System.out.println ("request" + this.getQuery ());
executeQuery();
Try this:
public void initQuery(String dummy,String ParamEmpNum,String ParmHireDt, Boolean executeQuery) { System.out.println("ParamEmpNum: "+ ParamEmpNum); System.out.println("ParmHireDt : "+ ParmHireDt); setWhereClause(null); setWhereClauseParams(null); String WhereClause = null; int bindCount = 0; HashMap paramMap = new HashMap(); if ( (ParamEmpNum != null) && (!("".equals(ParamEmpNum.trim()))) ) { paramMap.put(bindCount,ParamEmpNum); WhereClause = "EMPLOYEE_NUMBER = :"+ (++bindCount) + " AND "; } if ( (ParmHireDt != null) && (!("".equals(ParmHireDt.trim()))) ) { paramMap.put(bindCount,ParmHireDt); WhereClause = WhereClause + ("START_DATE = :"+ (++bindCount) + " AND "); } if(bindCount > 0) { // Remove the AND at the end WhereClause = WhereClause.substring(0, WhereClause.length()-5); setWhereClause(WhereClause); for(int i = 0; i < bindCount; i ++) { setWhereClauseParam(i,paramMap.get(i)); } } System.out.println("Query "+ this.getQuery()); executeQuery(); }
You may need to change the START_DATE whereclause as below:
WhereClause = WhereClause + ("START_DATE = TO_DATE (:" + (++ bindCount) + ', "MON-DD-YYYY" ") AND" ' ");
Note:-need to specify the correct format.
See you soon
AJ
-
Query SQL Report with condition (multiple settings) at the point of the apex?
Hi all
I have a small problem and cannot find a solution.
I need to create reports based on a query, SQL or I.R. Nothing hard here.
I need to add the WHERE clause dynamically with javascript to an element of the Apex.
Even once is not very difficult. I set the agenda of the Summit, put my query like this "SELECT * FROM MYTAB WHERE COL1 =: P1_SEARCH" then I call the page by setting the P1_SEARCH value. For example, COL1 is rowid. It works very well.
But here's my problem. Consider that P1_SEARCH contains several ROWID, and I don't know the number of these values,
(no I don't create a large number of items and create a query with so much GOLD!), I would sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (: P1_SEARCH) with something like: ROWID1, ROWID2 in P1_SEARCH."
I also tried: 'ROWID1, ROWID2' and 'ROWID1', 'ROWID2 '.
but I can't get anything else than the mistake of filter. It works with a value, but as soon as there are two values or more, it seems that the Apex is unable to read the string.
How can I do it please?
Thanks for your help.
Maxmnoscars wrote:
But here's my problem. Consider that P1_SEARCH contains several ROWID, and I don't know the number of these values,
(no I don't create a large number of items and create a query with so much GOLD!), I would sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (: P1_SEARCH) with something like: ROWID1, ROWID2 in P1_SEARCH."I also tried: 'ROWID1, ROWID2' and 'ROWID1', 'ROWID2 '.
but I can't get anything else than the mistake of filter. It works with a value, but as soon as there are two values or more, it seems that the Apex is unable to read the string.For a standard report, see + {message identifier: = 9609120} +.
For an IR - and improve safety by avoiding the risk of SQL Injection, use a collection containing the values in a column instead of a CSV list:
{code}
SELECT * FROM MYTAB WHERE ROWID IN (SELECT c001 FROM apex_collections WHERE collection_name = "P1_SEARCH")
{code}
(Please close duplicate threads spawned by your original question.) -
NoAvailableServersException when you run the query in applications
I only run the UI applications connected to a carrier co-located in my distributed system. When I run a query of the applications I have a NoAvailableServersException. The trace of the full stack of the applications log is below. I can run the same query successfully in gfsh on the same machine, the I'm running the applications. I' wvv looked through the applications documentation but can't find problems with my setup. Please let me know if you need more information.
Tom
[06/02/2013 INFO 17:39:19.135 IS main] Manual applications path is C:\vmware\vfabric-gemfire\vFabric_GemFire_70_b38623\tools\DataBrowser\docs\index.html[06/02/2013 INFO 17:39:19.512 IS main] Start interviewing for the results link to JMX Manager operation.[17:39:19.692 JMXCallExecutorThread IS SERIOUS 2013/02/06] An exception occurred while connecting to the mark on the host: idcprdgflocator2.carecorenational.com and port: 1099: com.gemstone.gemfire.management.ManagementException: Locator has failed. It is normal if the index was arrested. If it wasn't not check his diary for exceptions.[06/02/2013 INFO 17:39:19.692 IS JMXCallExecutorThread] Try to connect to a JMX Manager on the host: idcprdgflocator2.carecorenational.com and port: 1099[06/02/2013 INFO 17:39:19.793 IS JMXCallExecutorThread] Connected to the Gemfire distributed system[06/02/2013 INFO 17:39:21.666 IS JMXCallExecutorThread] Added members: ccnscupadsgf01 (10552) < v14 >: 4709[06/02/2013 INFO 17:39:21.679 IS JMXCallExecutorThread] Updated the refreshInterval to 60000[06/02/2013 INFO 17:39:23.594 IS JMXCallExecutorThread] GemFire (7.0) Cache is created. Support PDX is available.[06/02/2013 INFO 17:39:23.710 IS JMXCallExecutorThread] GemFire jar in the classpath version: 7.0[06/02/2013 INFO 17:39:23.710 IS JMXCallExecutorThread] Is the system of GemFire version: 7.0[06/02/2013 INFO 17:39:23.710 IS JMXCallExecutorThread] The LIMIT clause is supported by this version of the GemFire system: false[06/02/2013 INFO 17:39:23.711 IS JMXCallExecutorThread] The user is connected successfully to JMX Manager to idcprdgflocator2.carecorenational.com: 1099[06/02/2013 INFO 17:40:01.633 IS query run] Pool preparation for members:[06/02/2013 SERIOUS, 17:40:04.692 IS run query] Error occurred during execution of the query: com.gemstone.gemfire.mgmt.DataBrowser.controller.QueryConfigurationPrms@5608a6fc com.gemstone.gemfire.mgmt.DataBrowser.query.QueryExecutionException: com.gemstone.gemfire.cache.client.NoAvailableServersExceptionat com.gemstone.gemfire.mgmt.DataBrowser.query.QueryUtil.executeQuery(QueryUtil.java:74)at com.gemstone.gemfire.mgmt.DataBrowser.connection.internal.GemFireClientConnectionImpl.executeQuery(GemFireClientConnectionImpl.java:122)to com.gemstone.gemfire.mgmt.DataBrowser.controller.internal.QueryExecutionHelper$ QueryExecutor.run (QueryExecutionHelper.java:169)at java.lang.Thread.run(Thread.java:662)Caused by: com.gemstone.gemfire.cache.client.NoAvailableServersExceptionat com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.borrowConnection(ConnectionManagerImpl.java:246)at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:135)at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:114)at com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:638)at com.gemstone.gemfire.cache.client.internal.QueryOp.execute(QueryOp.java:51)at com.gemstone.gemfire.cache.client.internal.ServerProxy.query(ServerProxy.java:81)at com.gemstone.gemfire.cache.query.internal.DefaultQuery.executeOnServer(DefaultQuery.java:282)at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:213)at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:195)at com.gemstone.gemfire.mgmt.DataBrowser.query.QueryUtil.executeQuery(QueryUtil.java:70)... 3 more[06/02/2013 SERIOUS, 17:40:04.694 IS query result processor] Error executing query: com.gemstone.gemfire.mgmt.DataBrowser.query.QueryExecutionException: com.gemstone.gemfire.cache.client.NoAvailableServersExceptionat com.gemstone.gemfire.mgmt.DataBrowser.query.QueryUtil.executeQuery(QueryUtil.java:74)at com.gemstone.gemfire.mgmt.DataBrowser.connection.internal.GemFireClientConnectionImpl.executeQuery(GemFireClientConnectionImpl.java:122)to com.gemstone.gemfire.mgmt.DataBrowser.controller.internal.QueryExecutionHelper$ QueryExecutor.run (QueryExecutionHelper.java:169)at java.lang.Thread.run(Thread.java:662)Caused by: com.gemstone.gemfire.cache.client.NoAvailableServersExceptionat com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.borrowConnection(ConnectionManagerImpl.java:246)at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:135)at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:114)at com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:638)at com.gemstone.gemfire.cache.client.internal.QueryOp.execute(QueryOp.java:51)at com.gemstone.gemfire.cache.client.internal.ServerProxy.query(ServerProxy.java:81)at com.gemstone.gemfire.cache.query.internal.DefaultQuery.executeOnServer(DefaultQuery.java:282)at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:213)at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:195)at com.gemstone.gemfire.mgmt.DataBrowser.query.QueryUtil.executeQuery(QueryUtil.java:70)... 3 moreIf you set the gemfire bind-address on the cache server, applications will be able to connect. If a bind-address is not defined in gemfire.properties for a server remote cache, applications unfortunately just silently by default is localhost. This is something that will have to solve. In the meantime, you can work around this by setting the property gemfire bind-address on the cache servers for either the IP address or host name.
-
How do I run the query by quarter
Hi all, I would like to run this query based on the users selection from the interface. For example if the user select year 2011 and quarter 1, then this code will be like this AND (B.DATELET >= TO_DATE ('2011-01-01', 'YYYY-MM-DD') AND B.DATELET <= TO_DATE ('2011-03-31', 'YYYY-MM-DD')) When the user select year 2011 and quarter 2 then this code will be like this AND (B.DATELET >= TO_DATE ('2011-04-01', 'YYYY-MM-DD') AND B.DATELET <= TO_DATE ('2011-06-30', 'YYYY-MM-DD')) Will this possible to change my code here or I need to code this in PL/SQL? any clue will be appreciated. SELECT DISTINCT COUNT (P.CPROJNUM) ProjectAwarded, SUM (MIN (c.calcbtot)) AwardedDollarAmount, SUM (COUNT (C.VENDOR)) NumberOfBidders, (SUM (COUNT (C.VENDOR)) / (COUNT (P.CPROJNUM))) AverageNumberOfBidder FROM BIDDERS C, BIDLET B, LETPROP L, PROPOSAL P WHERE C.LETTING = B.LETTING AND P.CONTID = L.LCONTID AND C.LETTING = L.LETTING AND C.CALL = L.CALL AND l.lcontid IN (SELECT lcontid FROM letprop c, PROPOSAL d WHERE datestat IS NOT NULL AND UPPER (letstat) <> 'R' AND UPPER (letstat) <> 'B' AND TRIM (UPPER (TIMELET)) = TRIM ('9:30 A.M.') AND c.LCONTID = d.CONTID) AND (B.DATELET >= TO_DATE ('2011-04-01', 'YYYY-MM-DD') AND B.DATELET <= TO_DATE ('2011-06-30', 'YYYY-MM-DD')) GROUP BY l.call
Hello
If: p_year and: p_quarter are variables NUMBERS, container of the year and the quarter you want, then you can do something like this:
WITH got_report_start_date AS ( SELECT ADD_MONTHS ( DATE '2000-01-01' , (12 * (:p_year - 2000)) + ( 3 * (:p_quarter - 1)) ) AS report_start_date FROM dual ) -- Everything above is NEW SELECT DISTINCT COUNT (P.CPROJNUM) ProjectAwarded, SUM (MIN (c.calcbtot)) AwardedDollarAmount, SUM (COUNT (C.VENDOR)) NumberOfBidders, (SUM (COUNT (C.VENDOR)) / (COUNT (P.CPROJNUM))) AverageNumberOfBidder FROM BIDDERS C, BIDLET B, LETPROP L, PROPOSAL P , got_report_start_date r -- NEW WHERE C.LETTING = B.LETTING AND P.CONTID = L.LCONTID AND C.LETTING = L.LETTING AND C.CALL = L.CALL AND l.lcontid IN (SELECT lcontid FROM letprop c, PROPOSAL d WHERE datestat IS NOT NULL AND UPPER (letstat) <> 'R' AND UPPER (letstat) 'B' AND TRIM (UPPER (TIMELET)) = TRIM ('9:30 A.M.') AND c.LCONTID = d.CONTID ) AND B.DATELET >= r.report_start_date -- CHANGED AND B.DATELET < ADD_MONTHS (r.report_start_date, 3) -- CHANGED
Look at the comments that say NEW or MODIFIED; the rest is just what you've posted.
Note that you must use < (not=""> <=) when="" testing="" the="" end="" of="" the="" date="" range,="" and="" the="" date="" after="" the="">=)> < sign="" is="" the="" first="" date=""> NOT be included in the results.
-
Slow index by using the query. Fast with full table Scan.
Salvation;
(Thanks for the links)
Here's my question correctly formatted.
The query:
Works on 32 seconds!SELECT count(1) from ehgeoconstru ec where ec.TYPE='BAR' AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') ) and deathdate is null and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText'
Same query, but with an extra where clause:
This is 400 seconds.SELECT count(1) from ehgeoconstru ec where ec.TYPE='BAR' and ( (ec.contextVersion = 'REALWORLD') --- ADDED HERE AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') ) ) and deathdate is null and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText'
It should return data from a table, given the conditions.
The database version is Oracle9i Release 9.2.0.7.0
These are the parameters relevant for the optimizer:
Here is the output of the PLAN to EXPLAIN for the first quick query:SQL> show parameter optimizer NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ optimizer_dynamic_sampling integer 1 optimizer_features_enable string 9.2.0 optimizer_index_caching integer 99 optimizer_index_cost_adj integer 10 optimizer_max_permutations integer 2000 optimizer_mode string CHOOSE SQL>
Here is the output of the EXPLAIN of PLAN for slow queries:PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | | 1 | SORT AGGREGATE | | | | | |* 2 | TABLE ACCESS FULL | EHCONS | | | | -------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- 2 - filter(SUBSTR("EC"."strgfd",1,8)<>'[CIMText' AND "EC"."DEATHDATE" IS NULL AND "EC"."BIRTHDATE"<=TO_DATE('2009-10-06 11:52:12', 'yyyy -mm-dd hh24:mi:ss') AND "EC"."TYPE"='BAR') Note: rule based optimization
The TKPROF output for this slow statement is:PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | | | 1 | SORT AGGREGATE | | | | | |* 2 | TABLE ACCESS BY INDEX ROWID| ehgeoconstru | | | | |* 3 | INDEX RANGE SCAN | ehgeoconstru_VSN | | | | PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter(SUBSTR("EC"."strgfd",1,8)<>'[CIMText' AND "EC"."DEATHDATE" IS NULL AND "EC"."TYPE"='BAR') PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- 3 - access("EC"."CONTEXTVERSION"='REALWORLD' AND "EC"."BIRTHDATE"<=TO_DATE('2 009-10-06 11:52:12', 'yyyy-mm-dd hh24:mi:ss')) filter("EC"."BIRTHDATE"<=TO_DATE('2009-10-06 11:52:12', 'yyyy-mm-dd hh24: mi:ss')) Note: rule based optimization
Published by: PauloSMO on November 17, 2009 04:21TKPROF: Release 9.2.0.7.0 - Production on Tue Nov 17 14:46:32 2009 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Trace file: gen_ora_3120.trc Sort options: prsela exeela fchela ******************************************************************************** count = number of times OCI procedure was executed cpu = cpu time in seconds executing elapsed = elapsed time in seconds executing disk = number of physical reads of buffers from disk query = number of buffers gotten for consistent read current = number of buffers gotten in current mode (usually for update) rows = number of rows processed by the fetch or execute call ******************************************************************************** SELECT count(1) from ehgeoconstru ec where ec.TYPE='BAR' and ( (ec.contextVersion = 'REALWORLD') AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') ) ) and deathdate is null and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText' call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.00 538.12 162221 1355323 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.00 538.12 162221 1355323 0 1 Misses in library cache during parse: 0 Optimizer goal: CHOOSE Parsing user id: 153 Rows Row Source Operation ------- --------------------------------------------------- 1 SORT AGGREGATE 27747 TABLE ACCESS BY INDEX ROWID OBJ#(73959) 2134955 INDEX RANGE SCAN OBJ#(73962) (object id 73962) ******************************************************************************** alter session set sql_trace=true call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 0 0.00 0.00 0 0 0 0 Execute 1 0.00 0.02 0 0 0 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 1 0.00 0.02 0 0 0 0 Misses in library cache during parse: 0 Misses in library cache during execute: 1 Optimizer goal: CHOOSE Parsing user id: 153 ******************************************************************************** OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 2 0.00 0.02 0 0 0 0 Fetch 2 0.00 538.12 162221 1355323 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 5 0.00 538.15 162221 1355323 0 1 Misses in library cache during parse: 0 Misses in library cache during execute: 1 OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 0 0.00 0.00 0 0 0 0 Execute 0 0.00 0.00 0 0 0 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 0 0.00 0.00 0 0 0 0 Misses in library cache during parse: 0 2 user SQL statements in session. 0 internal SQL statements in session. 2 SQL statements in session. ******************************************************************************** Trace file: gen_ora_3120.trc Trace file compatibility: 9.02.00 Sort options: prsela exeela fchela 2 sessions in tracefile. 2 user SQL statements in trace file. 0 internal SQL statements in trace file. 2 SQL statements in trace file. 2 unique SQL statements in trace file. 94 lines in trace file.
Published by: PauloSMO on November 17, 2009 07:07
Published by: PauloSMO on November 17, 2009 07:38 - title changed to be more correct.Although your optimizer_mode is choosing, it seems that there are no statistics collected on ehgeoconstru. The absence of estimated costs and estimated row counts of each of the stages of the plan and the "Note: optimization based on rules" at the end of these two plans would tend to confirm this.
Optimizer_mode choose means that if statistics are collected then it will use the CBO, but if no statistic is present in any of the tables in the query, the optimizer to rule will be used. The RBO tends to be happy in the best of the index case. I guess the index ehgeoconstru_VSN contextversion as the main column and also includes the date of birth.
You can either gather statistics on the table (if all other tables have statistics) using dbms_stats.gather_table_stats, or suggest the query to use a full scan instead of index. Another solution would be to apply a function or an operation against the contextversion to prevent the use of the index. something like this:
SELECT COUNT(*) FROM ehgeoconstru ec WHERE ec.type='BAR' and ec.contextVersion||'' = 'REALWORLD' ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') and deathdate is null and SUBSTR(ec.strgfd, 1, LENGTH('[CIMText')) <> '[CIMText'
or maybe UPPER (ec.contextVersion) so that would not change the rows returned.
John
-
Where to write the condition in the design of workflows with conditional step?
HelloAgain, I wish BP and workflow with contitional design stage.
I had designed BP and workflow.
As directed by the user for Udesigner guide, I had added trigger before the condition step.
But I do not understand where to set the Condition to test?
If I need to write the condition in triggering elemt itsel... How to proceed?
for example, I want to write the condition as cost of Tota > = 100000, it must follow a path and if fails to another path.
The conditions of triggers are specified in the workflow settings. After you have created a new configuration, open it and click on the settings tab. You will see a tree structure of the workflow with conditional branches. Click a conditional branch to set the parameters for the trigger for this route condition.
-
Data not to see the detail block on running the query
I have a dev - 6i form. It contains two revenge joined database. The form was working properly but now all of a sudden, as I F8 run query it gives two error messages and do not run the block of detail data.
FRM-40819: System Variable is not editable.
FRM-40735: trigger YOU POPULATE DETAILS raised unhandled exception ORA-06502.
What is the reason how to get rid of him?Hello
Unless changes occurred, you will not get error, maybe it occurred without your knowledge.
Cases - open your source fmb file, rename and delete the link and create the link - compiles now.
Run the form, and then paste the result here.
-------------
Gul says:
I have a dev - 6i form. It contains two revenge joined database. The form was working properly but now all of a sudden, as I F8 run query it gives two error messages and do not run the block of detail data.FRM-40819: System Variable is not editable.
FRM-40735: trigger YOU POPULATE DETAILS raised unhandled exception ORA-06502.
What is the reason how to get rid of him? -
If I press the button 2 times to run the query 2 times
Hello..
If I press the button 2 times to run query 2 times
I want to limit this problem, than a run time enough.
no need to rerun query when I press the button because it will make the erroneous data.
Please give me a solution
MahaHello Maha
did you use KEY-EXEQRY trigger and turn off the query button?
SET_ITEM_PROPERTY('BLOCK1.) REPRINT ', ENABLED, PROPERTY_FALSE);
Sorry not clear for me, but plu everything sounds good :)
Kind regards
Amatu Allah
-
Run the query qutomatically?
I have some static queries, where nothing changes, they just need to be re - run the first thing Monday morning.
I would like to know the best way to automate this? I'm on Oracle 11 G Enterprise and just an end user without administrator privileges.
I have SQL * Plus, Toad and SQL Developer available and I'm trying to figure out the best wa this simply. I thought that it
a way to store the SQL code on the side server, as with the function or Procs and just load the database when run the SQL.
So maybe instead of one email, maybe a follow-up table can be updated with the status of the update. So, if I have 3-6 different
SQL, the tracking table would have column 2, name of the Table and column DDL Date or anything that makes sense.
So my tracking table would be updated when you complete the SQL and tell me when it has finished running to be looking in the DDL Date column.
and then I could see what table he speaks, not sure... or what's the best way it is to do.
At this point, I'm in search mode, so some of my question may sound silly, but that's how I learned, thank you.Hello
You can use dbms_scheduler to run a procedure at regular intervals (for example, every Monday at 6:00).
http://download.Oracle.com/docs/CD/E11882_01/AppDev.112/e16760/d_sched.htm#CIHHBGGIThe easiest way to view the results is probably to have the procedure INSERT messages into a log table. I think that's what you mean by a "tracking table.
-
Hello world
I have 2 blocks where the first I used to enter the values I want to search by breaking and entering after that I entered the value when I tap on the last element of this block, I have a trigger of key_next_item which has execute_query and next_block inside, but sometimes some users make a mistake of choosing the wrong option of research so that they come back to my first block to find the option they want reach, but when they click on the class_id point, which is the one where I have the trigger that mentioned forms are trying to save the changes asking the user if he or she wants to save the changes and then my detail block erases all data. After that when the user enters the class he wants to search the master datablock brings information related to another user and not the one that was there before.
Can someone help me on this please?It is in the search block that the user gets the message "Save"? If so, in this case, you could add a trigger to Enter-Query level block with the following code:
BEGIN Clear_Block(NO_VALIDATE); Enter_Query; END;
Craig...
Maybe you are looking for
-
How to disable the restrictions for deleting call logs
Y at - he on an option to put the restriction to delete call log history journal calls or stops history in I cloud.
-
564 configuration cartridge black
When I buy the 564 Setup black cartridge, because it doesn't come in a package with other necessary ink cartridges for my HP Photosmart 7520, I can't tell which box has this cartridge inside. How will I know which box to store this cartridge? Thank
-
I had this problem since Friday night, but today late Sunday morning. I contacted McAfee several times, Toshiba and Microsoft. Toshiba told me to do a restore on my laptop, so it is like new. But I still can't go back to McAfee. Microsoft wants me to
-
(Based on activity lights), I noticed that the traffic between two ports of switches VLAN are sent to several ports on switch. Here is my scenario: Port 1 is a "mode access" switchport VLAN 100 (100 without label). Port 2 is a "mode access" switchpor
-
Highlight text on the added photos?
I wonder if I can highlight text on a jpeg image that I put first Pro and I have the text highlighted for a certain period of time.