How to build where clause in this query
Hi all,
Version Details
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Solaris: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
Status_cid filter in the following query should be 3,86,25 for org_unit_sid 3001 and for other organizations it should be 5,86 .
Please let me know how this can be done .
SELECT *
FROM table_name pr
WHERE pr.status_cid IN /*pr.status_cid is number (2) data type * /
((CASE
WHEN pr.org_unit_sid = 3001
THEN (SELECT '5,86,25' -- this is not working
FROM DUAL)
ELSE (SELECT '5,25'
FROM DUAL)
END
I know this can be done using union as follows ..
SELECT *
FROM ((SELECT *
FROM temp pr
WHERE pr.org_uni_sid = 3001 AND pr.status_cid IN (5, 86, 25))
UNION
(SELECT *
FROM temp pr
WHERE pr.org_uni_sid <> 3001 AND pr.status_cid IN (5, 86)))
Any help in this regard is appreciated .............Thanks,
P Prakash
SELECT *
FROM table_name pr
WHERE ( (pr.status_cid IN (5,86) OR ( pr.org_unit_sid = 3001 AND pr.status_cid IN (25))
{code}
PS: Kindly mark the answers to your post as helpfull/correct if you are satisfied
Edited by: Himanshu Binjola on Apr 23, 2012 9:34 PM
Similar Messages
-
How to change where clause in VO query in bean
Hi experts
I have to modify vo object query where clause on run time .. is it possible??
if yes please suggest me,as mentioned by Timo, it is very much possible
see this following link -
Changing the WHERE clause or VO Query at runtime in Oracle ADF | Techartifact
Dynamically changing query in view object in Oracle ADF | Techartifact -
How to formulate where clause in select query at runtime..??
I am facing a problem..
I have to generate a select query during runtime..For Ex: when user selects a row in an alv report, particular date field is to be read and another report is to be opened for that data..
I know how to make drill down report but my problem is concatenating date field...
Plz tell a solution....Hi,
Try like this....
refresh : gt_tvarvc_temp[].
gt_tvarvc_temp[] = lt_tvarvc[].
loop at gt_tvarvc_temp into gs_tvarvc_temp
where name = 'CREDIT_MEMO_DOC_TYPE'.
r_blart-sign = gs_tvarvc_temp-sign.
r_blart-option = gs_tvarvc_temp-opti.
r_blart-low = gs_tvarvc_temp-low.
append r_blart.
clear r_blart.
endloop.
concatenate 'BLART IN ' 'r_blart' into lv_condition
separated by space.
if not lv_customer_cond is initial.
if lv_condition is initial.
concatenate lv_customer_cond lv_condition
into lv_condition separated by space.
else.
concatenate lv_condition 'AND' lv_customer_cond
into lv_condition separated by space.
endif.
endif.
select bukrs belnr gjahr appending corresponding fields
of table lt_potential_credits
from bsid
where (lv_condition).
Hope its helps -
How build where clause in select statement in FM for Virtual provider
Hi
I looking for example of FM for Virtual provider where I find code how assign to select statement "where" clause value from query variable.
In following code how build t_r_custtype range and how assign value to it.
CODE********************************
TYPE-POOLS: abap.
initialize
CLEAR: e_t_data, e_t_msg.
this is specific to infoprovider VIRTPROV
CHECK i_infoprov = 'VIRTPROV'.
FIELD-SYMBOLS: <l_s_sbook> TYPE sbook,
<l_s_data> TYPE ANY.
DATA: l_t_component TYPE abap_compdescr_tab,
l_t_sbook TYPE TABLE OF sbook.
initialize
CLEAR e_t_data.
Data selection / only Business Customer
SELECT * FROM sbook
INTO CORRESPONDING FIELDS OF TABLE l_t_sbook
WHERE custtype in t_r_custtype.
ENDCODE********************************
Thanks a lot
AdamHello,
Would you like fill the ranges in Customer exit for BEx..?
If Yes. please refer the attachment for the whole code...
"Sample code in Customer Exit in BEx"
IF i_step = 2.
CASE i_vnam.
WHEN 'ZDAY_CX'.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZDAY_IN'.
CLEAR: l_s_range.
ZT_DT1 = loc_var_range-low.
ZT_DT2 = loc_var_range-HIGH.
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_JAHRE = 0
ANZAHL_KALTAGE = 0
ANZAHL_MONATE = '-1'
ANZAHL_TAGE = 0
DATUM_EIN = ZT_DT1
DATUM_EIN_ULT = ' '
ULTIMO_SETZEN = ' '
IMPORTING
DATUM_AUS = ZFIDAY .
E_TT =
E_ULTKZ =
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_JAHRE = 0
ANZAHL_KALTAGE = 0
ANZAHL_MONATE = '-1'
ANZAHL_TAGE = 0
DATUM_EIN = ZT_DT2
DATUM_EIN_ULT = ' '
ULTIMO_SETZEN = ' '
IMPORTING
DATUM_AUS = ZLSDAY.
E_TT =
E_ULTKZ =
l_s_range-low = ZFIDAY .
l_s_range-high = ZLSDAY .
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
*****************************************End*************************************
**To get the From date (For Text Variable) as per the user input date interval range**
WHEN 'ZR_S'.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZDAY_IN'.
CLEAR: l_s_range.
ZT_DT1 = loc_var_range-low.
ZT_DT2 = loc_var_range-HIGH.
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_JAHRE = 0
ANZAHL_KALTAGE = 0
ANZAHL_MONATE = 0
ANZAHL_TAGE = 0
DATUM_EIN = ZT_DT1
DATUM_EIN_ULT = ' '
ULTIMO_SETZEN = ' '
IMPORTING
DATUM_AUS = ZFIDAY .
E_TT =
E_ULTKZ =
l_s_range-low0(2) = ZFIDAY6(2).
l_s_range-low+2(1) = '.'.
l_s_range-low3(2) = ZFIDAY4(2).
l_s_range-low+5(1) ='.'.
l_s_range-low6(4) = ZFIDAY0(4).
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
*****************************************End*************************************
Please let me know if any clarification required..
Rinku.. -
How do you use 3 Where Clauses in a query
Hi, i am trying to figure out how to use 3 Where Clauses in a Query where 2 of the Where Clauses uses a Sub query.
Display the OrderID of all orders that where placed after all orders placed by “Bottom-Dollar Markets”.
Order the result by OrderID in ascending order.
First WHERE clause checks for OrderDate and uses a sub query with ALL keyword.
Second WHERE clause use equals and sub query.
Third WHERE clause uses equal and company name.
This is what i have so far but i am pretty confused on how to do this.
My Code for NorthWind:
Select OrderID
From Orders o
Where o.OrderID IN (Select OrderDate From Orders Where Orders.OrderID > ALL
(Select CompanyName From Customers Where CompanyName = 'Bottom-Dollar Markets'));
The book shows how to use the ALL Keyword but not in a Sub query with Multiple Where Clauses.
Select VenderName, InvoiceNumber, InvoiceTotal
FROM Invoices JOIN Vendors ON Invoices.VendorID = Vendors.VendorID
WHERE InvoiceTotal > ALL (Select InvoiceTotal From Invoices Where VendorID = 34)
ORDER BY VendorName;>Where Orders.OrderDate
> ALL (Select
CompanyName
The comparison operator (>) requires compatible data types.
DATETIME is not compatible with VARCHAR string for comparison.
Here is your homework:
SELECT orderid
FROM orders o
WHERE o.orderdate > ALL (SELECT orderdate
FROM orders
WHERE shipvia = (SELECT Max(shipvia)
FROM orders o
INNER JOIN customers c
ON c.customerid =
o.customerid
WHERE
c.companyname = 'Bottom-Dollar Markets'));
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
How to dynamically build where clause in Linq
Hello everyone,
Oracle DB:11gR2
Oracle Client: 11.2.0.3.0 (ODP.NET)
Oracle Developer Tools for Visual Studio
VS 2010 (C#)
In a Windows Form, we need to query the data based on the values of dropdown listboxes, which user will select.
Let's say, two combox, one is for Department and one is for Salary
Department:
-1 All
10 Department 1
20 Department 2
30 Department 3
Salary:
-1 All
1 < 20000
2 20000 to 50000
3 50000 to 100000
4 > 100000
Here is C# code to query data:
using (var myEDMctx = new HREntities())
var LINQrslt = from emp in myEDMctx.EMPLOYEES
select emp;
The default values for both combox should be All.
How to write the dynamic where clause for this LINQ?
Thanks in advance!!!There is nothing Oracle-specific about dynamic LINQ queries. Dynamic LINQ queries are handled all the same way, no matter which data source you use. Microsoft describes how to use Dynamic LINQ here:
http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx
http://weblogs.asp.net/davidfowler/archive/2010/08/19/dynamic-linq-part-2-evolution.aspx -
How to modify the where clause in this to include other things
How do I modify the WHERE clause in this code:
$expected = array(first_name, last_name, level, language, 'city', 'state', 'zip', );
$query_search = 'SELECT * FROM french;
$where = false;
foreach ($expected as $var) {
if (isset($_GET[$var]) && !empty($_GET[$var])) {
if ($where) {
$query_search .= ' AND ';
} else {
$query_search .= ' WHERE ';
$where = true;
$query_search .= $var . ' = '. GetSQLValueString($_GET[$var], 'text');
to include things like searching multiple columns and IF NULL:
SELECT * from MyTable where (MyCol1 = %s or MyCol1 Is Null) AND (MyCol2 = %s or MyCol2 Is Null)
Where on earth does it go?
Thanks
BrianMy goal is to have a search form and results combination that:
1) allows the user to ignore any of the page’s existing search fields that
they don’t need, (to search with empty form fields);
2) to use whichever search form fields they choose to use even if the
Registrant for whom they are searching did not insert that information when
they registered, (they are filled in the search form but empty in the
database table);
3) and to permit some of the seach fields to search multiple columns, for
example the search form field ‘sonsName’ would look for that information in
three different database table colums, (sonsName1, sonsName2 etc.).
You’ve given me code that permits 1) above to work beautifully. You’ve also
sent along code that should let me accomplish the other two, and though I’ve
been able to recreate below what I want the multiple search column to do, I
can get neither the multiple column nor the IS NULL sections to work in the
code you sent most recently.
How do I take something like this:
$colname_rsSearch = "-1";
if (isset($_POST['first_name_now'])) {
$colname_rsSearch = $_POST['first_name_now'];
$colname2_rsSearch = "-1";
if (isset($_POST['last_name_now'])) {
$colname2_rsSearch = $_POST['last_name_now'];
$colname3_rsSearch = "-1";
if (isset($_POST['sonsName'])) {
$colname3_rsSearch = $_POST['sonsName'];
mysql_select_db($database_connStr_Milo_db, $connStr_Milo_db);
$query_rsSearch = sprintf("SELECT milo.first_name_now, milo.last_name_now,
milo.ws_number, milo.ws_number_3, milo.ws_number_4 FROM milo WHERE
milo.first_name_now = %s AND milo.last_name_now = %s AND (milo.sonsName1 =
%s) || (milo.sonsName2 = %s) || (milo.sonsName3 = %s)",
GetSQLValueString($colname_rsSearch,
"text"),GetSQLValueString($colname2_rsSearch,
"text"),GetSQLValueString($colname3_rsSearch,
"text"),GetSQLValueString($colname3_rsSearch,
"text"),GetSQLValueString($colname3_rsSearch, "text"));
$rsSearch = mysql_query($query_rsSearch, $connStr_Milo_db) or
die(mysql_error());
$row_rsSearch = mysql_fetch_assoc($rsSearch);
$totalRows_rsSearch = mysql_num_rows($rsSearch);
?> (I’ve excluded the IS NULL part from my example, but need it in the final
version)
…and make it work using your code below (which permits someone to search
with empty form fields, but does not yet enlighten me on what to group (with
parenthesis) to make the code execute the multiple column search and the IS
NULL parts of the search.
mysql_select_db($database_connStr_Milo_db, $connStr_Milo_db);
$expected = array('first_name_now', 'last_name_now', sonsName'
$query_search = 'SELECT milo.first_name_now, milo.last_name_now,
milo.ws_number, milo.ws_number_3, milo.ws_number_4 FROM milo';
$where = false;
foreach ($expected as $var) {
if (isset($_POST[$var]) && !empty($_POST[$var])) {
if ($where) {
$query_search .= ' AND ';
} else {
$query_search .= ' WHERE ';
$where = true;
$query_search .= '(' . $var . ' = '. GetSQLValueString($_POST[$var],
'text') .
' OR ' . $var . ' IS NULL)';
$search = mysql_query($query_search, $connStr_Milo_db) or
die(mysql_error());
$row_search = mysql_fetch_assoc($search);
$totalRows_search = mysql_num_rows($search);
As always, thank you. -
How to include OSTC.rate in this query
How to include OSTC.rate in this query,Im using it for crystal report.
DECLARE @sVAT NVARCHAR(max)
DECLARE @sCess NVARCHAR(max)
DECLARE @sCST NVARCHAR(max)
DECLARE @nDocentry INT
SET @sVAT='1' SET @sCess='7' SET @sCST ='4'
SELECT DocEntry
,DocDate,VehicleNo,Driver,NumAtCard
,Building,Block,Street,City,District,State,Country
,Series,DocNum
,BTinNo,BCstNo,BCeRegNo,BPanNo,BCeRange,BCeComRate,BCeDivision,BEccNo
,Type
,CardName,[Delivery Addr]
,ECCNo,CERange,CERegNo,CEDivis,CEComRate
,PAN,CST,STN
,[Deliver At]
,LineNum
,Dscription,HSNumber,Quantity,Rate,LineTotal,Discount,Vat [VAT],Cess [Cess],Total,GTotal
,TotalExpns
,MfgName
,MFGBuilding,MFGBlock,MFGStreet,MFGDistrict,MFGCity
,MCERegNo,MCERange,MCEDivis,MCEComRate,MPAN,MCST,MSTN
,SupName
,SUPBuilding,SUPBlock,SUPStreet,SUPDistrict,SUPCity
,SCERegNo,SCERange,SCEDivis,SCEComRate,SPAN,SCST,SSTN
, (select substring((select upper(name)+',' from OUBR where isnull(U_SeriesGrp,'')<>'' order by Code FOR XML PATH ('')),1,LEN((select upper(name)+',' from OUBR order by Code FOR XML PATH ('')))-1))[Branches]
FROM
SELECT
/*OBTN.DistNumber*/
INV1.DocEntry
,OINV.DocDate,OINV.U_VehicleNo VehicleNo,OINV.U_Driver Driver,OINV.NumAtCard
,CAST(OLCT.Building AS VARCHAR(255))Building,OLCT.Block,OLCT.Street,OLCT.City,OLCT.County+' - '+OLCT.ZipCode[District],OCST.Name State,OCRY.Name Country
, NNM1.SeriesName [Series], OINV.DocNum
,OLCT.TinNo [BTinNo],OLCT.CstNo [BCstNo],OLCT.CeRegNo [BCeRegNo],OLCT.PanNo [BPanNo],OLCT.CeRange [BCeRange]
,OLCT.CeComRate [BCeComRate],OLCT.CeDivision [BCeDivision],OLCT.EccNo [BEccNo]
,OBTN.U_InvType Type
,OINV.CardName,OINV.Address2[Delivery Addr]
,CE_CRD7.ECCNo,CE_CRD7.CERegNo,CE_CRD7.CERange,CE_CRD7.CEDivis,CE_CRD7.CEComRate
,CRD7.TaxId0[PAN],CRD7.TaxId1[CST],CRD7.TaxId11 [STN]
,OINV.U_Address [Deliver At]
,INV1.LineNum,INV1.ItemCode
,INV1.Dscription,OITM.SWW [HSNumber]
,INV1.Quantity,INV1.PriceBefDi Price,INV1.LineTotal,INV1.Price Rate,(INV1.PriceBefDi-INV1.Price)*INV1.Quantity Discount
,INV4.Vat
,INV4.Cess
,INV1.LineTotal+INV1.VatSum Total
,OINV.DocTotal GTotal
,OINV.TotalExpns
,OBTN.U_MfgName MfgName
,convert(nvarchar(250),MFG_CRD1.Building) MFGBuilding,MFG_CRD1.Block MFGBlock,MFG_CRD1.Street MFGStreet,MFG_CRD1.City MFGCity,MFG_CRD1.ZipCode[MFGDistrict]
,OBTN.U_MCERegNo MCERegNo,OBTN.U_MCERange MCERange,OBTN.U_MCEDivis MCEDivis,OBTN.U_MCEComRate MCEComRate
,OBTN.U_MPAN MPAN,OBTN.U_MCST MCST,OBTN.U_MSTN MSTN
,OBTN.U_SupName SupName
,convert(nvarchar(250),SUP_CRD1.Building) SUPBuilding,SUP_CRD1.Block SUPBlock,SUP_CRD1.Street SUPStreet,SUP_CRD1.City SUPCity,SUP_CRD1.ZipCode[SUPDistrict]
,OBTN.U_SCERegNo SCERegNo,OBTN.U_SCERange SCERange,OBTN.U_SCEDivis SCEDivis,OBTN.U_SCEComRate SCEComRate
,OBTN.U_SPAN SPAN,OBTN.U_SCST SCST,OBTN.U_SSTN SSTN
FROM
OINV
INNER JOIN INV1 ON OINV.DocEntry=INV1.DocEntry
INNER JOIN OITM ON INV1.ItemCode=OITM.ItemCode
INNER JOIN
select
INV4.DocEntry,INV4.LineNum
,CASE WHEN INV4.staType IN (@sVAT,@sCST) THEN sum(INV4.TaxSum) ELSE 0 END Vat
,CASE WHEN INV4.staType=@sCess THEN sum(INV4.TaxSum) ELSE 0 END Cess
from
INV4
where
INV4.DocEntry={?DocKey@} and INV4.RelateType=1
group by INV4.DocEntry,INV4.LineNum,INV4.staType
)INV4 ON INV1.DocEntry=INV4.DocEntry AND INV1.LineNum=INV4.LineNum
INNER JOIN OLCT ON INV1.LocCode=OLCT.Code
INNER JOIN OCST ON OLCT.State=OCST.Code
INNER JOIN OCRY ON OLCT.Country=OCRY.Code and OCST.Country=OCRY.Code
INNER JOIN INV12 ON OINV.DocEntry=INV12.DocEntry
INNER JOIN OITL ON INV1.BaseType=OITL.ApplyType AND INV1.BaseEntry=OITL.ApplyEntry AND INV1.BaseLine=OITL.ApplyLine
INNER JOIN ITL1 ON OITL.LogEntry=ITL1.LogEntry
INNER JOIN OBTN ON ITL1.MdAbsEntry=OBTN.AbsEntry and ITL1.SysNumber=OBTN.SysNumber and ITL1.ItemCode=OBTN.ItemCode
LEFT JOIN OCRD MFG_OCRD ON MFG_OCRD.CardCode=OBTN.U_MfgCode
LEFT JOIN CRD1 MFG_CRD1 ON MFG_OCRD.CardCode=MFG_CRD1.CardCode AND MFG_OCRD.BillToDef=MFG_CRD1.Address and MFG_CRD1.AdresType='B'
LEFT JOIN OCRD SUP_OCRD ON SUP_OCRD.CardCode=OBTN.U_SupCode
LEFT JOIN CRD1 SUP_CRD1 ON SUP_OCRD.CardCode=SUP_CRD1.CardCode AND SUP_OCRD.BillToDef=SUP_CRD1.Address and SUP_CRD1.AdresType='B'
LEFT JOIN NNM1 ON OINV.Series=NNM1.Series
LEFT JOIN CRD7 ON OINV.CardCode=CRD7.CardCode AND CRD7.Address='' AND CRD7.AddrType='S' --Tax Details
LEFT JOIN CRD7 CE_CRD7 ON OINV.CardCode=CE_CRD7.CardCode AND OINV.ShipToCode=CE_CRD7.Address AND CE_CRD7.AddrType='S' -- Central Excise Details
WHERE
INV1.DocEntry={?DocKey@}
)INVOICE
GROUP BY
DocEntry
,DocDate,VehicleNo,Driver,NumAtCard
,Building,Block,Street,City,District,State,Country
,Series,DocNum
,BTinNo,BCstNo,BCeRegNo,BPanNo,BCeRange,BCeComRate,BCeDivision,BEccNo
,Type
,CardName,[Delivery Addr]
,ECCNo,CERange,CERegNo,CEDivis,CEComRate
,PAN,CST,STN
,[Deliver At]
,LineNum
,Dscription,HSNumber,Quantity,Rate,LineTotal,Discount,Vat,Cess,Total,GTotal
,TotalExpns
,MfgName
,MFGBuilding,MFGBlock,MFGStreet,MFGDistrict,MFGCity
,MCERegNo,MCERange,MCEDivis,MCEComRate,MPAN,MCST,MSTN
,SupName
,SUPBuilding,SUPBlock,SUPStreet,SUPDistrict,SUPCity
,SCERegNo,SCERange,SCEDivis,SCEComRate,SPAN,SCST,SSTNYou're double posting ( how to change join condition in this query ) , stop doing that, since you'll only be distracting and diverting by doing so.
Take the time to read the SQL and PL/SQL FAQ @ https://forums.oracle.com/forums/ann.jspa?annID=1535, since you're not even mentioning a database version, while 9i {noformat} != {noformat} 10g {noformat} != {noformat}11g...
Have your DBA trace/tkprof the query, and so on, if you cannot do that yourself.
And then provide the feedback the volunteers, including Ace (Directors)' s need ( and you were very lucky, from that point of view, I think, from looking at both your posts ;) ) -
How to set Where clause in the View Object of the MessageChoice ?
Hi,
How to set Where clause in the View Object of the
MessageChoice ?
Example:
<bc4j:rootAppModuleDef name="EdEscolaCampusView1AppModule"
definition="ed00050.Ed00050Module"
releaseMode="stateful" >
<bc4j:viewObjectDef name="EdEscolaCampusView1" >
<bc4j:rowDef name="CreateEdEscolaCampusView1" autoCreate="true" >
<bc4j:propertyKey name="key" />
</bc4j:rowDef>
</bc4j:viewObjectDef>
<bc4j:viewObjectDef name="ListaTipLocalView1"
rangeSize="9999">
</bc4j:viewObjectDef>
</bc4j:rootAppModuleDef>
</bc4j:registryDef>
messageChoice declaration:
<bc4j:messageChoice name="SeqTipoLocalCampus"
attrName="SeqTipoLocalCampus"
prompt="Local do Campus">
<contents>
<bc4j:optionList attrName="SeqTipoBasico"
textAttrName="NomTipoBasico"
voName="ListaTipLocalView1"/>
</contents>
</bc4j:messageChoice>
I would like set where clause of ViewObject, with dinamic parameters (using attribute1 = :1), before populate messageChoice.
thanks...
DaniloHi Andy,
I try set a where clause using the message:
Set where Clause parameter using UIX , but my UIX Page have 2 messageChoice's of different ViewObject's, then I need implement this Java Class:
//Nome da Package da Tela Detail
package br.com.siadem.siaed.ed00050;
// Importa as Bibliotecas necessárias
import oracle.jbo.ViewObject;
import oracle.jbo.ApplicationModule;
import oracle.jbo.client.Configuration;
import oracle.cabo.servlet.BajaContext;
import oracle.cabo.servlet.Page;
import oracle.cabo.servlet.event.PageEvent;
import oracle.cabo.servlet.event.EventResult;
import oracle.cabo.data.jbo.servlet.bind.*;
import oracle.cabo.ui.data.BoundValue;
import oracle.cabo.ui.data.DataBoundValue;
import javax.servlet.http.HttpServletRequest;
import br.com.siadem.siaed.util.*;
import javax.servlet.http.Cookie;
import oracle.cabo.data.jbo.def.NestedAppModuleDef;
import oracle.cabo.data.jbo.def.ViewObjectDef;
import oracle.cabo.data.jbo.def.AppModuleDef;
// Classe que configura os parametros para a execução da Query,
// utilizando variáveis de Sessao
public class FunPreQueryLista
public static EventResult FunConfiguraQuery(BajaContext context, Page page, PageEvent event) throws Throwable
// TrataDadosSessao - Classe utilizada para retornar os valores das variáveis de sessão genéricas
// Ex: CodCliente, CodMunicipio etc...
TrataDadosSessao varDadosSessao = new TrataDadosSessao();
// 1o. Parametro Configurado - Através da classe TrataDadosSessao, utilizando um método Get
// <alterar>
String valor1 = varDadosSessao.getCodCliente();
String valor2 = varDadosSessao.getCodMunicipio();
//Cria o objeto que retorna o ApplicationModule
ApplicationModule am = ServletBindingUtils.getApplicationModule(context);
// Início das Configurações da Query da Lista
//Cria o objeto que retorna o view object da lista desejada
//alterar
ViewObject TipoLocal = am.findViewObject("ListaTipoLocalView1");
//Configuração dos parametros definidos na query do view Object
//alterar
TipoLocal.setWhereClauseParam(0,valor1);
TipoLocal.setWhereClauseParam(1,valor2);
// Executa a Query
TipoLocal.executeQuery();
// Fim das Configurações da Query da Lista
// Início das Configurações da Query da Lista
//Cria o objeto que retorna o view object da lista desejada
//alterar
ViewObject TipoDestLixo = am.findViewObject("ListaDestinoLixoView1");
//Configuração dos parametros definidos na query do view Object
//alterar
TipoDestLixo.setWhereClauseParam(0,valor1);
TipoDestLixo.setWhereClauseParam(1,valor2);
// Executa a Query
TipoDestLixo.executeQuery();
// Fim das Configurações da Query da Lista
// Retorna o Resultado para a Página
return new EventResult(page);
The code works very well...
And, I'm sorry for my two repost's in UIX Forum about this in a few time.
Thank very much...
Danilo -
Regarding dynamically assigning the where clause to select query
hi,
Please send the code regarding how to dynamically assign the where clause to select query.
thanks in advanceSELECT <fileds>
INTO TABLE itab
FROM dbase
WHERE condition. -
Please help me how to improve the performance of this query further.
Hi All,
Please help me how to improve the performance of this query further.
Thanks.Hi,
this is not your first SQL tuning request in this community -- you really should learn how to obtain performance diagnostics.
The information you posted is not nearly enough to even start troubleshooting the query -- you haven't specified elapsed time, I/O, or the actual number of rows the query returns.
The only piece of information we have is saying that your query executes within a second. If we believe this, then your query doesn't need tuning. If we don't, then we throw it away
and we're left with nothing.
Start by reading this blog post: Kyle Hailey &raquo; Power of DISPLAY_CURSOR
and applying this knowledge to your case.
Best regards,
Nikolay -
ADF dynamic where clause for VO query using BC
I'm hoping someone can help me out. I have a read only view object that I want to filter results based on some user choices. For example the user may want to see all results or they may only want to see a much smaller subset. This is for an error dashboard, the smaller subset maybe by application or maybe by application and by error severity. I think I can use a dynamic where clause but I'm not sure, Can someone get me started down the right path, or post an example that I can see.
Hi user,
You can use a dynamic where clause for this, but maybe there is a more practical option. Maybe you can have a fixed where clause, but using a bind parameter, like:
vo.application like :applicationParam. This makes an executeWithParams method available that you can call from your page, and use in the bindings. This parameter you can populate with the results of for example a poplist, with a default value of '%'.
When you do want to use a dynamic where clause, you will need to add a method to the java code of your application module, and make this method available for the client. In this method, you can use findViewObject to retrieve your VO, use VO.setWhereClause to set the whereclause to what you want, and then call VO.executeQuery. This method can then again be called from the page.
Success,
Jeroen van Veldhuizen -
How to write WHERE clause in dynamic record group in oracle forms
hi this is s.v.eswar,PLZ HELP ME
i am new to oracle forms
i want to write where clause in dynamic recordgroup
this is the code i have written
DECLARE
MGR_ITEM ITEM:=FIND_ITEM('MGR');
RG_ID_MGR RECORDGROUP:=NULL;
MGR_DUMMY NUMBER;
BEGIN
RG_ID_MGR:=FIND_GROUP('MGRNUMBER');
IF ID_NULL(RG_ID_MGR) THEN
RG_ID_MGR:=CREATE_GROUP_FROM_QUERY('MGRNUMBER','SELECT DISTINCT TO_CHAR(EMPNO),TO_CHAR(EMPNO) FROM EMP WHERE JOB='MANAGER''); --THIS IS THE LINE I AM GETTING ERROR
END IF;
IF NOT ID_NULL(RG_ID_MGR) THEN
MGR_DUMMY:=POPULATE_GROUP('MGRNUMBER');
IF MGR_DUMMY=0 THEN
POPULATE_LIST(MGR_ITEM,'MGRNUMBER');
END IF;
END IF;
END;
COMPILE TIME ERROR
1)I have written where clause like this WHERE JOB='MANAGER'
then oracle compiler has given error like
ENCOUNTERED THE SYMBOL 'MANAGER' WHEN EXPECTING ONE OF THE FOLLOWING .,().........etc
(FOR THE ABOVE ERROR I JUST REMOVED SINGLE CODES AND WRITE LIKE THIS ----->WHERE JOB=MANAHER)------>THEN COMPILED SUCESSFULLY)
AND I RUN THE FORM
RUN TIME ERROR
FRM-41072: CAN NOT CREATE GROUP 'MGRNUMBER'Hi there
pls have a look here
Dependent drop down lists in forms 6i
hope this helps...
regards,
Amatu Allah -
How to remove the OR clause in this query?
Hello Everyone,
I have this query where i have a lot of joins and in the where clause there is a ISNULL and conditions based on OR clause.
How to remove the use of the OR clause which may cause performance problems? Can anyone suggest a method to remove the OR clause?
select RS.PLANNEDSTART,
OD.ESTSHIPDATE
FROM TABLE1 RS(NOLOCK)
INNER JOIN TABLE2 SS(NOLOCK)
ON RS.ID1 = SS.ID1
INNER JOIN TABLE3 AM(NOLOCK)
ON AM.KEYID = SS.KEYID
INNER JOIN TABLE4 OD(NOLOCK)
ON SS.KEYID= OD.KEYID
INNER JOIN TABLE 8 DR
ON
WHERE (isnull(RS.DATE1,'1970-01-01 00:00:00.000') ='1970-01-01 00:00:00.000'
AND OD.DATE1 between @Beginning_Route_Date and @Ending_Route_Date)
OR
RS.DATE1!='1970-01-01 00:00:00.000'
AND RS.DATE1 BETWEEN @Beginning_Route_Date and @Ending_Route_Date)
Regards
Gautam S
Gautam Sthis is one way avoiding OR clause
WHERE CASE WHEN isnull(RS.DATE1,'1970-01-01 00:00:00.000') ='1970-01-01 00:00:00.000'
THEN OD.DATE1 ELSE RS.DATE1 END between @Beginning_Route_Date and @Ending_Route_Date)
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
VPD - How to make the where clause a correlated query
Hi,
My VPD function has the following where clause:
where_clause:= ' project_id in (select object_id from pa_project_classes p'||
' where p.class_category='||''''||l_cat||''''||
' and p.CLASS_CODE='||''''||l_class||''''||
' and p.OBJECT_TYPE=''PA_PROJECTS'''||
The problem is that the subquery is not using the unique key defined on the table pa_project_classes. What I need is something as follows:
where_clause:= ' project_id in (select object_id from pa_project_classes p'||
' where p.class_category='||''''||l_cat||''''||
' and p.CLASS_CODE='||''''||l_class||''''||
' and p.OBJECT_TYPE=''PA_PROJECTS'''||
' and p.object_id=mainquery.project_id ||
The problem is that since the table pa_project_classes also has a column project_id, I have to prefix the column name by the alias of the main query like 'mainquery.project_id'. However this seems impossible as main query is not unknown .
I would be grateful if you could suggest any workaround or solution.
ThanksJust have a look over these two statements if it solves your problem
one time where clause
Set_Block_Property('BLOCK_NAME',ONETIME_WHERE,your form item);
dynamic where clause
set_block_property('BLOCK_NAME'default_where, your form itme)
you can where clause at run time from any procedure or some triggers
Maybe you are looking for
-
Mail in Mountain Lion can no longer connect to Hotmail server
A couple of days ago I suddenly got the warning triangle next to my hotmail accounts in Mail on my Mac running Mountain Lion 10.8.1. Clicking on them or looking in the connection doctor just says that it can't connect to pop3.live.com, verify all acc
-
Simplest way to display a title or caption at the beginning of each scene?
I am editing a video to make an instructional dvd covering 23 separate lessons. Without some kind of text in the first few seconds of each scene, there is no way for the viewer to quickly and efficiently distinguish one scene from another as they jum
-
Safety stock Warning message ?
Hello Friends, Need some help in creating a new functionality,Currently our customers can order a large quantity for any given material. There is no check in place that warns the customer service rep (CSR) that this will stock us out or that this or
-
My iphone 3gs wont connect to the service it just says searching any ideas what to do
so hears th deal guys my 3gs wont connect to the sevice its not unlocked or jail broken and on top of that i was in the processes of restoring it and it wont let me connect to itunes the phone wont read the sim for some odd reason
-
Examples of pricing procedure related frieght and vat
hi friends i want to create pri proc with fright and vat please give some examples of pri proc related to frght vat waht r the pre confguration requ for frieght and vat