OAF apending un-necessary where clause
Hi all,
Following is actual VO query
SELECT * FROM (SELECT flkp.MEANING AS CATEGORY,
flkp.LOOKUP_CODE AS CATEGORY_CODE,
flkp.LOOKUP_TYPE AS CATEGORY_TYPE,
flkp.DESCRIPTION,
flkp.START_DATE_ACTIVE AS ACTIVE_FROM,
flkp.END_DATE_ACTIVE AS ACTIVE_TILL
FROM FND_LOOKUPS flkp
WHERE flkp.LOOKUP_TYPE = :1)
but OAF creates following WERE clause unnecessarly
QRSLT WHERE (( UPPER(CATEGORY_CODE) like :2 AND (CATEGORY_CODE like :3 OR CATEGORY_CODE like :4 OR CATEGORY_CODE like :5 OR CATEGORY_CODE like :6)))
May 10, 2007 12:58:15 AM oracle.jbo.common.ADFLoggerDiagnosticImpl print
FINE: [339] Bind params for ViewObject: M4UItemCategoriesVO1
May 10, 2007 12:58:15 AM oracle.jbo.common.ADFLoggerDiagnosticImpl print
FINE: [340] Binding param "1": M4U_GPC_CODES
May 10, 2007 12:58:15 AM oracle.jbo.common.ADFLoggerDiagnosticImpl print
FINE: [341] Binding param "2": M4U_%
May 10, 2007 12:58:15 AM oracle.jbo.common.ADFLoggerDiagnosticImpl print
FINE: [342] Binding param "3": M4%
May 10, 2007 12:58:15 AM oracle.jbo.common.ADFLoggerDiagnosticImpl print
FINE: [343] Binding param "4": m4%
May 10, 2007 12:58:15 AM oracle.jbo.common.ADFLoggerDiagnosticImpl print
FINE: [344] Binding param "5": M4%
May 10, 2007 12:58:15 AM oracle.jbo.common.ADFLoggerDiagnosticImpl print
FINE: [345] Binding param "6": m4%
Hi,
Can you clarify what you mean by "OAF" ? Do you mean Oracle ADF ?
Also, your where clause looks to me like you are using named view criteria. Are you?
Similar Messages
-
Need help in clearing string buffer during dynamic VO where clause in oaf
Hi All,
I am dynamically setting where clause in OAF using string buffer, but the issue is when i am executing the vo multiple times so the old data in the string buffer it is not clearing .so every time my where clause adding to the query and it is erroring out, please help me how to clear string buffer class in oaf.
ThnaksHi,
Could you please share the code segment for reference. Then we can tell the solution.
Regards,
Tarun -
Issue with dynamically setting where clause in OAF
Hi All,
I have a View object having the query below:
SELECT rownum LINENUM,
B.line_id LINE_ID,
B.INVENTORY_ITEM_ID INVITMID ,
B.QUANTITY_DELIVERED PICKQTY
from MTL_TXN_REQUEST_HEADERS A,
MTL_TXN_REQUEST_LINES B
WHERE A.HEADER_ID=B.HEADER_ID
AND A.MOVE_ORDER_TYPE=2
AND 'on'=:1
AND B.TO_SUBINVENTORY_CODE=NVL(:4,B.TO_SUBINVENTORY_CODE)
AND A.request_number=NVL(:5,A.REQUEST_NUMBER)
UNION ALL
SELECT rownum LINENUM,
a.wip_entity_id LINE_ID,
a.INVENTORY_ITEM_ID INVITMID,
a.QUANTITY_ISSUED PICKQTY
FROM WIP_REQUIREMENT_OPERATIONS a,
eam_work_orders_v b
WHERE a.wip_entity_id=b.wip_entity_id
AND 'on'=:2
AND a.ATTRIBUTE2=NVL(:4,a.ATTRIBUTE2)
and b.wip_entity_name=NVL(:6,b.wip_entity_name)
I need to pass dynamically a condition to my where clause that i can handle it by defining two bind parameters in the vo query and can pass it but the problem is the bind variable contains a string like 1311,13112,14445 that i need to pass for a field such as B.line_id in the first query and b.wip_entity_id in the second query so when i am trying by passing the string as one value it is working fine but for value separetd by comma it is giving prob.
so i tried by passing dynamic where clause but it is everytime executing for first clause only how i can pass dynamically both the queries.
vo.setWhereClause("LINE_ID in "+wherclause);
please help me out
Thnaks
DebHi Gaurav,
Thnaks for the reply i tried belwo way u suggested but the query is executing multiple times and i am not getting the correct data as expected.
public void processPOData (String wherclause)
OAViewObject vo = this.getXXDPECONTAINLINESVO1();
String query =vo.getQuery();
String newwhereclause ="LINE_ID = "+wherclause;
StringBuffer stringbuffer = new StringBuffer();
stringbuffer.append("SELECT * FROM (");
stringbuffer.append(query);
stringbuffer.append(") where ");
stringbuffer.append(newwhereclause);
ViewDefImpl viewdefimpl = getXXDPECONTAINLINESVO1().getViewDefinition();
viewdefimpl.setQuery(stringbuffer.toString());
vo.reset();
vo.clearCache();
vo.executeQuery();
System.out.println("where clause:"+wherclause);
in my log file the query is forming like below:
SELECT * FROM (SELECT * FROM (SELECT * FROM (SELECT * FROM ( SELECT * FROM ( SELECT rownum LINENUM,
B.line_id LINE_ID,
B.INVENTORY_ITEM_ID INVITMID ,
B.QUANTITY_DELIVERED PICKQTY ,
B.TO_SUBINVENTORY_CODE UNLOADINGPNT,
A.REQUEST_NUMBER RRNUM,
NULL WORKORDNUM,
NULL DTRNUM,
A.description,
A.FROM_SUBINVENTORY_CODE FROM_SUB,
A.TO_SUBINVENTORY_CODE TO_SUB,
NULL SOURCE
from MTL_TXN_REQUEST_HEADERS A,
MTL_TXN_REQUEST_LINES B
WHERE A.HEADER_ID=B.HEADER_ID
AND A.MOVE_ORDER_TYPE=2
UNION ALL
SELECT rownum LINENUM,
a.wip_entity_id LINE_ID,
a.INVENTORY_ITEM_ID INVITMID,
a.QUANTITY_ISSUED PICKQTY,
a.ATTRIBUTE2 UNLOADINGPNT,
NULL RRNUM,
b.WIP_ENTITY_NAME WORKORDNUM,
NULL DTRNUM,
b.description,
NULL FROM_SUB,
NULL TO_SUB,
b.source SOURCE
FROM WIP_REQUIREMENT_OPERATIONS a,
eam_work_orders_v b
WHERE a.wip_entity_id=b.wip_entity_id ) )) where LINE_ID = 30026) where LINE_ID = 30026) where LINE_ID = 30026
But in my page i am getting all the data instead of only for line 30026, please help me out -
Performance - composite index with 'OR' in 'WHERE' clause
I have a problem with the performance of the following query:
select /*+ index_asc(omschact oma_index1) */ knr, projnr, actnr from omschact where ((knr = 100 and actnr > 30) or knr > 100)
and rownum = 1;
(rownum used only for test purpose)
index:
create index on omschact (knr, projnr);
Execution plan:
Id Operation
0 SELECT STATEMENT
1 COUNT STOPKEY
2 TABLE ACCESS BY INDEX ROWID
3 INDEX FULL SCAN
If I'm correct, the 'OR' in the 'WHERE' clause is responsible for the INDEX FULL SCAN, what makes the query slow.
A solution would be then to separate the 'WHERE' clause in 2 separate select's (1 with 'knr = 100 and actnr > 30' and 1 with 'knr > 100' and combine the results with a UNION ALL.
Since it's necessary to have all rows in ascending order (oma_index1) I still have to use an ORDER BY to make sure the order of the rows is correct. This results again in a (too) low performance.
Another solution that does the trick is to create an index with the 2 fields (knr, projnr) concatenated and to use the same in the 'WHERE' clause:
create index oma_index2 on omschact (knr || projnr);
select /*+ index_asc(omschact oma_index2) */ knr, projnr, actnr from omschact where (knr || projnr) > 10030;
I just can't believe this work-around is the only solution, so I was hoping that someone here knows of a better way to solve this.padders,
I'll give the real data instead of the example. The index I really use consists of 4 fields. In this table the fields are just numbers, but in other tables I need to use char-fields in indexes, so that's why I concatenate instead of using formula's (allthough I would prefer the latter).
SQL> desc omschact
Name Null? Type
KNR NOT NULL NUMBER(8)
PROJNR NOT NULL NUMBER(8)
ACTNR NOT NULL NUMBER(8)
REGELNR NOT NULL NUMBER(3)
REGEL CHAR(60)
first methode:
SQL> create index oma_key_001(knr,projnr,actnr,regelnr);
Index created.
SQL> select /*+ index_asc(omschact oma_key_001) */ * from omschact where
2 (knr > 100 or
3 (knr = 100 and projnr > 30) or
4 (knr = 100 and projnr = 30 and actnr > 100000) or
5 (knr = 100 and projnr = 30 and actnr = 100000 and regelnr >= 0));
Execution Plan
Plan hash value: 1117430516
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 11M| 822M| 192K (1)| 00:38:26 |
| 1 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 11M| 822M| 192K (1)| 00:38:26 |
|* 2 | INDEX FULL SCAN | OMA_KEY_001 | 11M| | 34030 (1)| 00:06:49 |
Predicate Information (identified by operation id):
2 - filter("KNR">100 OR "KNR"=100 AND "PROJNR">30 OR "KNR"=100 AND "PROJNR"=30
AND "ACTNR">100000 OR "ACTNR"=100000 AND "KNR"=100 AND "PROJNR"=30 AND
"REGELNR">=0)
second method (same index):
SQL> select * from (
2 select /*+ index_asc(omschact oma_key_001) */ * from omschact where knr > 100
3 union all
4 select /*+ index_asc(omschact oma_key_001) */ * from omschact where knr = 100 and projnr > 30
5 union all
6 select /*+ index_asc(omschact oma_key_001) */ * from omschact where knr = 100 and projnr = 30 and actnr > 100000
7 union all
8 select /*+ index_asc(omschact oma_key_001) */ * from omschact where knr = 100 and projnr = 30 and actnr = 100000 and regelnr > 0)
9 order by knr, projnr, actnr, regelnr;
Execution Plan
Plan hash value: 292918786
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 11M| 1203M| | 477K (1)| 01:35:31 |
| 1 | SORT ORDER BY | | 11M| 1203M| 2745M| 477K (1)| 01:35:31 |
| 2 | VIEW | | 11M| 1203M| | 192K (1)| 00:38:29 |
| 3 | UNION-ALL | | | | | | |
| 4 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 11M| 822M| | 192K (1)| 00:38:26 |
|* 5 | INDEX RANGE SCAN | OMA_KEY_001 | 11M| | | 33966 (1)| 00:06:48 |
| 6 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 16705 | 1272K| | 294 (1)| 00:00:04 |
|* 7 | INDEX RANGE SCAN | OMA_KEY_001 | 16705 | | | 54 (0)| 00:00:01 |
| 8 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 47 | 3666 | | 4 (0)| 00:00:01 |
|* 9 | INDEX RANGE SCAN | OMA_KEY_001 | 47 | | | 3 (0)| 00:00:01 |
| 10 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 1 | 78 | | 4 (0)| 00:00:01 |
|* 11 | INDEX RANGE SCAN | OMA_KEY_001 | 1 | | | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
5 - access("KNR">100)
7 - access("KNR"=100 AND "PROJNR">30)
9 - access("KNR"=100 AND "PROJNR"=30 AND "ACTNR">100000)
11 - access("KNR"=100 AND "PROJNR"=30 AND "ACTNR"=100000 AND "REGELNR">0)
third method:
SQL> create index oma_test(to_char(knr,'00000000')||to_char(projnr,'00000000')||to_char(actnr,'00000000')||to_char(regelnr,'000'));
Index created.
SQL> select /*+ index_asc(omschact oma_test) */ * from omschact where
2 (to_char(knr,'00000000')||to_char(projnr,'00000000')||
3 to_char(actnr,'00000000')||to_char(regelnr,'000')) >=
4 (to_char(100,'00000000')||to_char(30,'00000000')||
5* to_char(100000,'00000000')||to_char(0,'000'))
Execution Plan
Plan hash value: 424961364
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 553K| 55M| 1712 (1)| 00:00:21 |
| 1 | TABLE ACCESS BY INDEX ROWID| OMSCHACT | 553K| 55M| 1712 (1)| 00:00:21 |
|* 2 | INDEX RANGE SCAN | OMA_TEST | 99543 | | 605 (1)| 00:00:08 |
Predicate Information (identified by operation id):
2 - access(TO_CHAR("KNR",'00000000')||TO_CHAR("PROJNR",'00000000')||TO_CHAR("
ACTNR",'00000000')||TO_CHAR("REGELNR",'000')>=TO_CHAR(100,'00000000')||TO_CHAR(3
0,'00000000')||TO_CHAR(100000,'00000000')||TO_CHAR(0,'000')) -
PL/SQL Evaluation problem of where clause in case of NUMBER column type
I found the following problem in Oracle® Database 2 Day Developer's Guide 11g Release 1 (11.1) B28843-04:
The sole parameter of function eval_frequency is employee_id IN employees.employee_id%TYPE.
An ORA-01422 exception occurs when the execution reaches the following select command
SELECT e.hire_date
INTO hire_date
FROM employees e
WHERE employee_id= e.employee_id;
A possible cause of the error is that the type of employee_id is NUMBER while the employees.employee_id is NUMBER(6,0) . The result of the selection is the same as there were no WHERE clause at all.
Everything worked fine, when I declared a temporary variable of NUMBER(6,0) for storing the actual parameter of function and used this variable in the where clause, but I consider this "solution" as being no solution.
It is pointless to use %TYPE parameter of a function for flexibility if I must degrade this flexibility by a fixed declaration of a temporary variable of the same type as the column in question.
What is wrong?
The Developer'Guide I used, the Oracle Sql Developer I used or the PL/SQL version ?Hi,
Welcome to the forum!
user8949829 wrote:
A possible cause of the error is that the type of employee_id is NUMBER while the employees.employee_id is NUMBER(6,0) . The result of the selection is the same as there I don't think so. The variable employee_id is defined as having the exact same type as the eponymous column. Even if it didn't, I believe Oracle will always implicity convert between datatypes when possible, rounding if necessary. That may cause errors, but it isn't causing this error.
No, the error has nothing to do with the data type. It has to do with the ambiguity of employee_id: is it a column, or is it a variable?
The default is that it means the column name, so
WHERE employee_id = e.employee_idis equivalent to saying
WHERE e.employee_id = e.employee_idwhich isn't quite the same thing as not having a WHERE clause; rows with NULL employee_id would still be excluded, if there were any.
I think it's best not to use variable names that are the same as column names. You could call the variable v_employee_id, or, since it's an IN-argument, in_employee_id.
If you must use a variable that can be mistaken for a column, then qulaify it with the name of the procedure, like this:
WHERE eval_frequency.employee_id = e.employee_id
Everything worked fine, when I declared a temporary variable of NUMBER(6,0) for storing the actual parameter of function That makes sens. You probably gave that variable a name that couldn't be mistaken for a column in the table.
Edited by: Frank Kulash on Jan 12, 2011 8:27 PM -
Appending a dynamic where clause in VO
Hi All
I am trying append a where clause dnamically to a VO
The query is
SELECT DISTINCT
pvsa.org_id AS OrgId,
GECMPoVendorsEO.VENDOR_ID AS SupplierId,
GECMPoVendorsEO.VENDOR_NAME AS SupplierName,
GECMPoVendorsEO.STANDARD_INDUSTRY_CLASS AS StdIndustryClass,
GECMPoVendorsEO.END_DATE_ACTIVE AS SupplierInactiveDate,
GECMPoVendorsEO.SEGMENT1 AS SupplierNumber
FROM PO.PO_VENDORS GECMPoVendorsEO,
po_vendor_sites_all pvsa
WHERE GECMPoVendorsEO.vendor_id = pvsa.vendor_id
AND DECODE('Y','Y', NVL(GECMPoVendorsEO.end_date_active,SYSDATE+1), SYSDATE+1) >= SYSDATE
AND DECODE('Y','Y', NVL(pvsa.inactive_date,SYSDATE+1), SYSDATE+1) >= SYSDATE
When the query is executed by OA Framework
it changes it into
SELECT * FROM (
SELECT DISTINCT
pvsa.org_id AS OrgId,
GECMPoVendorsEO.VENDOR_ID AS SupplierId,
GECMPoVendorsEO.VENDOR_NAME AS SupplierName,
GECMPoVendorsEO.STANDARD_INDUSTRY_CLASS AS StdIndustryClass,
GECMPoVendorsEO.END_DATE_ACTIVE AS SupplierInactiveDate,
GECMPoVendorsEO.SEGMENT1 AS SupplierNumber
FROM PO.PO_VENDORS GECMPoVendorsEO,
po_vendor_sites_all pvsa
WHERE GECMPoVendorsEO.vendor_id = pvsa.vendor_id
AND DECODE('Y','Y', NVL(GECMPoVendorsEO.end_date_active,SYSDATE+1), SYSDATE+1) >= SYSDATE
AND DECODE('Y','Y', NVL(pvsa.inactive_date,SYSDATE+1), SYSDATE+1) >= SYSDATE
) QRSLT
WHERE UPPER(SupplierName) like '%DEL%' AND OrgId = 468
and i need to append something like
WHERE UPPER(SupplierName) like '%DEL%' AND OrgId = 468
This clause when appended executes fine
however when i try to append
UPPER(pvsa.ATTRIBUTE12) like 'CBSI' AND OrgId = 468
then it gives me error that pvsa.ATTRIBUTE12 is invalid identifier
I need to select the value in select clause to use it outside in the where clause
but i cant select it in query since it gives me multiple values that i dont want
Have anyone faced similar issue
Is there any workaround possible for this?
Please help me out
Thanks
HusainI have come across this issue many times.
OAF framework aliases the design time query like a result set (QRSLT, consider it like a temp table). In SQL terms, the query after appending the where clause becomes like
SELECT * from QRSLT WHERE UPPER(pvsa.ATTRIBUTE12) like 'CBSI' AND OrgId = 468.
But the ATTRIBUTE12 (also pvsa alias) are not defined in the above query and the query gives an error.
One work around I have used is to use Bind Variables with the query at design time.
Hope this helps'
Srini -
I have a selection screen like:
Table Field
EKKO EKORG
EKKO EKGRP
EKKO LIFNR
ESSR EBELN
ESSR EBELP
ESSR LBLNE
ESSR FRGZU
ESSR ERDAT
ESSR LOEKZ
Due to further complexities in the program i am joining 3 tables EKKO, EKPO and ESSR together. I can write the select stmt in 2 ways. I want to understand which one is better in terms of performance and is there exactly a rule here that i should follow before i write the where clause in this join.
SELECT aebeln bebelp alifnr aekorg aekgrp bpackno c~lblni
clblne cerdat cpackno cloekz cfrgsx cfrgkl c~frgzu
INTO TABLE gt_test
FROM ekko AS a INNER JOIN ekpo AS b
ON aebeln = bebeln
INNER JOIN essr AS c
ON aebeln = cebeln
AND bebeln = cebeln
AND bebelp = cebelp
WHERE a~lifnr IN so_lifnr
AND a~ekorg IN so_ekorg
AND a~ekgrp IN so_ekgrp
AND c~lblne IN so_lblne
AND c~ebeln IN so_ebeln
AND c~ebelp IN so_ebelp
AND c~erdat IN so_erdat.
SELECT aebeln bebelp alifnr aekorg aekgrp bpackno c~lblni
clblne cerdat cpackno cloekz cfrgsx cfrgkl c~frgzu
INTO TABLE gt_test
FROM ekko AS a INNER JOIN ekpo AS b
ON aebeln = bebeln
INNER JOIN essr AS c
ON aebeln = cebeln
AND bebeln = cebeln
AND bebelp = cebelp
WHERE a~ebeln IN so_ebeln
AND a~lifnr IN so_lifnr
AND a~ekorg IN so_ekorg
AND a~ekgrp IN so_ekgrp
AND b~ebelp IN so_ebelp
AND c~lblne IN so_lblne
AND c~erdat IN so_erdat.
AND c~erdat IN so_erdat.Hi,
This part is not necessary:
... a~ebeln = c~ebeln ...
Modify:
AND c~ebeln IN so_ebeln
AND c~ebelp IN so_ebelp
by
AND a~ebeln IN so_ebeln
AND b~ebelp IN so_ebelp
The best option will be:
if not so_ebeln[] is initial.
select ... where a~ebeln IN so_ebeln ... (2nd select)
else.
select ... where a~lifnr IN so_lifnr ... (1st select)
endif.
Also, you can try only the 2nd select, because it has WHERE clause to ebeln and lifnr. Depending on your database, you can check (via ST04) if the right index is selected (eg. if you inform so_ebeln the database must do the selection using ebeln index. if you inform so_lifnr the database must do the selection using lifnr index, etc..)
Best regards,
Leandro Mengue -
Hi All,
I am trying to combine a subquery in where clause but could not get it to work. Does anyone have better idea how can i achieve this?
>
select l.olic_id, l.olic_key, o.trading_name , p.name, l.olic_term, l.expire_date, l.status
from table1 l, table2 o, table3 p, table4 a
where l.cop_id=o.cop_id
and o.par_id=p.par_id
and l.olic_id=a.olic_id and ( select scripts from tb_scripts where dst_id=66)
>
Sub query in the where clause return -
AB is not null or BC is not null or AC is not null or CA is not null or DE is not nullThe region I want to use subquery because it contains more than 60 columns for each dst_id.
Please give me some suggestion. I hope this make sense.
Regards,
TajuddinHere is my table structure -
CREATE TABLE TB_SCRIPTS
DST_ID NUMBER,
SCRIPTS VARCHAR2(500 BYTE)
)Sample data for TB_SCRIPTS table -
dst_id scripts
66 AB is not null or BC is not null or AC is not null or CA is not null or DE is not null
65 AB is not null or CA is not null or DE is not null
67 CA is not null or DE is not nulltable structure for TABLE4 -
CREATE TABLE TABLE4
PK_ID NUMBER,
OLIC_ID NUMBER,
AB VARCHAR2(200),
BC VARCHAR2(200),
AC VARCHAR2(200),
CA VARCHAR2(200),
DE VARCHAR2(200),
EF VARCHAR2(200)
)OLIC_ID is the foreign key in this table referencing table1.
sample data for TABLE4 -
pk_id olic_id AB BC AC CA DE EF
1 123 6 2 8
2 23 9 2 0 1
3 123 0 2 1 7
4 44 7
5 12 8 1 8Table1 structure -
CREATE TABLE TABLE1
OLIC_ID NUMBER,
OLIC_KEY VARCHAR2(20),
OLIC_TERM VARCHAR2(20),
EXPIRE_DATE DATE,
STATUS VARCHAR2(60)
)Some sample data -
OLIC_ID OLIC_KEY OLIC_TERM EXPIRE_DATE STATUS
123 TR42332 1 Year 12/06/2010 Current
154 TR43232 2 Years 24/08/2011 Current
122 TR32422 2 Months 23/01/2009 ExpiredOther tables are not necessary to include here. Basically TABLE1 and TABLE4 joining to retrieve data here. Hope this make sense.
Regards,
M Tajuddin -
Hi, I have run the following command successfully without the WHERE clause on the last line. However, when I try to use a parameter, it fails. Is there anything wrong with it?
CREATE TABLE #DateList
Dates DateTime NOT NULL PRIMARY KEY
DECLARE locDate DateTime;
DECLARE BEG DateTime;
DECLARE FIN DateTime;
DECLARE N DOUBLE PRECISION;
//-- Sets the 1st date in the table.
SET BEG=TIMESTAMP '2000-01-01 00:00:00';
//-- Sets the Last date in the Table.
SET FIN=TIMESTAMP '2008-12-31 00:00:00';
//-- Fills all the dates in between...
SET locDate = BEG;
WHILE locDate <= FIN DO
INSERT INTO #DateList
(Dates)
SELECT locDate AS Dates FROM #dummy;
/* This should work, but it looks like Nexus haven't written the code yet to
actually add dates, the slack dogs.
SET locDate=locDate + INTERVAL '1' DAY;
SET N = CAST(locDate AS DOUBLE PRECISION) + 1;
SET locDate = CAST(N AS TIMESTAMP);
END WHILE;
SELECT *
FROM #DateList;
DROP TABLE #DateList;
SELECT "WeatherDetail"."RainFall", "WeatherStation"."Name", "WeatherDetail"."Date"
FROM "WeatherDetail" "WeatherDetail" INNER JOIN "WeatherStation" "WeatherStation" ON "WeatherDetail"."WeatherStationID"="WeatherStation"."WeatherStationID"
WHERE "WeatherStation"."Name" = {?Station}Please remember to give all necessary information, such as the error message. This will help users identify the cause of your issue.
-
Is iot possible to use a dynamic where clause in a loop? If so how to you code this?
i.e. Loop at itab in wa where (dynamic_where_clause)...
endloop...
Moderator message: please read ABAP documentation for your SAP release.
Edited by: Thomas Zloch on Mar 29, 2011 3:20 PMYou should be aware that a LOOP AT ... WHERE is not an optimized access .
+ because on a standard table there is not sort order,
so the loop goes over the whole table and does
something when the condition is fulfilled
+ it is optimzed for sorted tables, but only for one key!
=> so your idea must have bad performance!
If this is not a problem, then you can solve the problem
in the following way:
loop at table
if ( dynamic condition )
endif.
endloop.
But maybe is dynamic condition is not necessary, but
a some fixed if-conditions are also o.k.
Siegfried -
i am passing dynamic where clause to a detail block from the main control block by pressing a button, the problem is different types of criterias are not comming together, like i may choose any value of machine or if its null it should bring all the machines combined with status which can be either opened,closed,inspected and i added them as elements of list and if the selected item has status with value All it shoud bring all the status for all the machines.but the problem is its not satisfying the criteria properly and when i choose all nothing is displayed in the detail block.
{code}
declare
cnt number;
var varchar2(32000);
VAAL VARCHAR2(32500);
begin
cnt := Get_List_Element_Count('IP_REP_INFO.T_LIST_IN');
if cnt >= 1
then
var := null;
for i in 1..cnt loop
var := var||','||''''||Get_List_Element_Value('IP_REP_INFO.T_LIST_IN',i)||'''';
end loop;
Set_Block_Property('OV_JOB_MAINT', DEFAULT_WHERE,
'WHERE (1=1 AND JOB_MACH IS NULL) OR (1=0 OR JOB_MACH in ('||substr(var, 2)||')) AND (1 = 1 and :ORDER_STATUS IN ('||'''ALL'''||') AND
STATUS IN (''OPENED'',''CLOSED'',''INSPECTION'') ) or ( 1=0 OR STATUS = :ORDER_STATUS)');
GO_BLOCK('OV_JOB_MAINT');
EXECUTE_QUERY;
GO_ITEM('JOB_DT');
end;
{\code}First, when setting the DEFAULT_WHERE property of a block, I like to assign the dynamic where clause to a variable so I can output it to the screen or look at the value through the Forms Debugger to ensure it is formatted correctly.
Second, have you perfected your WHERE clause in SQLPlus or SQL Developer to ensure it is returning exaclty what you want? To me, this is a critical first step that should be completed first before trying to create the dynamic where clause through code.
Third, it is not necessary to include the 'WHERE' keyword in your code because Forms will automatically do this for you. Will it work? Yes, but your query ends up looking like this when Forms executes the query.
SELECT {...list of your columns here...}
WHERE ( WHERE 'Your Dynamic Where Clause' )
See my comments in your code sample...
Set_Block_Property('OV_JOB_MAINT', DEFAULT_WHERE,
'WHERE (1=1 -- This is not needed, just evaluate JOB_MACH IS NULL
AND JOB_MACH IS NULL)
OR (1=0 -- I don't understand why you want a FALSE test here...
OR JOB_MACH in ('||substr(var, 2)||')
-- Have you outputted the value of VAR to the screen to ensure
-- it is formatted correctly?
AND (1 = 1 -- Again, this is not needed
and :ORDER_STATUS IN ('||'''ALL'''||')
AND STATUS IN (''OPENED'',''CLOSED'',''INSPECTION'') )
or ( 1=0 -- Again, why do you need a FALSE test here?
OR STATUS = :ORDER_STATUS)'
Regarding...
if the selected item has status with value All it shoud bring all the status for all the machines.but the problem is its not satisfying the criteria properly and when i choose all nothing is displayed in the detail block.
Do you have an Order Status with the value of "ALL" in your table?
My guess is that you don't because each record would have to record its actual status as well as the ALL status. Based on this assumption, I recommend you alter your SQL so that it looks for the actual status as well as perform an IN comparison.
'AND status IN ('||DECODE(:ORDER_STATUS,'ALL','''OPENED'',''CLOSED'',''INSPECTION'' ',''''||:ORDER_STATUS)||''')'
The addition of the DECODE enables you to query on all statuses when the :ORDER_STATUS = ALL or it returns the status listed in the :ORDER_STATUS field.
Hope this helps.
Craig... -
How to pass LOV Where clause params from Page CO
Dear Members,
I have an OAF Page for which I defined a CO.
I also have an LOV for which I have two parameters in where clause.
Now my requirement is to pass the two values to the where clause parameters of LOV from the CO of the respective page.
Can any one please guide me in achieving this requirement.
Best Regards,
Arun ReddyHi Arun
as gyan, suggested try attching a new controller to lov , or extend its existing controller.
In the page CO
store the parameter that needs to be passed to lov in pageContext.putSessionValue(paramName,paramValue)
In the CO of Lov page , in processrequest
retrive the stored values using pageContext.getSessionValue(paramName)
Regards
Ravi -
Hi All,
I have two valuesets Valueset1 & Valueset2, Both are independent valuesets and both has set of values. here valuset2 has been attached to one KFF structure's segment. (Valueset1 & Valueset2 will have same set of values).
I want to restrict the valuset2 value based on valuset1 values... Valueset2 LOV should have only one value which is the user selecting from valuset1. I don't want to default the value to valuset2 based on valuset1... I want to restrict valuset2 LOV based on the value the user selecting from Valuset1.
I am using these valusets in Forms & OAF Page.
Can i set any where clause using PL/SQL ? So that i can call that PL/SQL package from Forms / OAF.
I hope this is not possible.. But still, if somebody came across this situation and having alternate approach please share with me...
Thanks in Advance.Dependent value sets will fit the bill.
Here is one link that explains how to set it up
http://wiki.oracle.com/page/HOW+TO+make+flexfield+fields+dependent+on+another
Hope this answers your question,
Sandeep Gandhi -
Mutilple Filter Objects - Changing where clause and or
Is it possible to have a query as below using filter commands.
(obj1 = 'value11' and obj2 = 'value21')
or
(obj1 = 'value12' and obj2 = 'value22')
or
The objective is to manipulate the where clause and , or .
Thanks in Advance
Bhanu MohantyHi Bhanu,
to reach what you want it's necessary to build a virtual characteristic.
The new characteristic will be populated via coding during runtime of your query. Another possibility (as mentioned before in this forum by Siegfried Szameitat) is to create a new characteristic in your cube that contains field1 and field2 concatenated. With the first scenario, you dont need a reloading of your cube, with second one this is necessary.
Hope this helps.
Bye,
Roberto -
How to create dynamic where clause instead of pragmatically
Hi,
I'm using Jdev 11.1.2.2.0 and my requirement to create a two fields with search button to fetch data as adf table. User need to enter either of the field value and click search button to see his data.
So I created a sql query based view object with 2 bind variables (which are input params) & 2 view criteria (to create dynamically where clause) and then drag on to the page by ExecuteWithParams operation from data controls but couldnt work.
If anyone have idea to build dynamically please let me know.
AmarUser need to enter either of the field value and click search button to see his data.User need to enter either of the field value and click search button to see his data.
Hi Amar,
Is your requirement, creating a query panel with table??
Drag and drop the view criteria(Application Navigator>DataControls> AppModule >NamedCriteria> ViewCriteriaName ) onto the page.
In the context menu, select Query->ADFQueryPanel With Table.. That brings your necessary two columns and Search field with data represented as a table.
Harsha
Edited by: Harsha049 on Nov 28, 2012 3:51 PM
Maybe you are looking for
-
How does one read the Unity transaction logs on Exchange?
I'm trying to find out who placed a call to whom on a particular day and time. A subscriber receives a blank email periodically with no "from" statement, just a timestamp. They don't have unified messaging. I want to see if the transaction logs (lo
-
Daisy-Chaining Firewire External Drive Tips Needed here!
H, I have three cases with drives in them I want to connect to my iMac for various duty: 1) fw/400/800/esata/usb case (externally-powered) 2) fw/400/usb case (externally-powered) 3) fw/400/esata/usb case (bus-powered) My current setup is to chain 1 &
-
Adding Java Script RSS Feed to Library Item
Can anybody help me I have been trying to add a java script for a rss feed to a library item page. That way a rss feed shows in the library page field. I have 3 sites from 1000 to 10000 pages. They all use a library item. I want the current news to s
-
I cannot load Gmail in Firefox (but I can in Safari). When I try to access my Gmail account in Firefox, I am able to sign in on the log in page, but once I actually try to log in, Firefox tries to load Gmail but constantly loops between "waiting for
-
Where'd my site go??
Hello, I recently had to reinstall the OS on my Mac Pro. When I go to my website online, it's still there, but when I retrieved the 'domain' file from my time capsule, I found that it says 'iWeb can't open file' whenever I try to open it. So my site'