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.
Thanks
Just 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
Similar Messages
-
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. -
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 edit the where clause of View object in search example dynamically
Hi,
I am new to OA Framework. Can anybody please tell me how can I assign the where clause dynamically. I want to search only those rows whose creation date is between a 'Date form' and 'Date to' inputs from the search page
Thanks
Anupamuser567342 ,
I will advice u again pls refer dev guide, there u can find code sample for ur requirement, which can be accomplished using stringbuffer.
--Mukul -
How to retrieve the 'Where Clause' text?
Hello all,
I have created a package to retrieve all the DML's executed against the database for the day, for a particular user. DBMS_LOGMNR package was used to retrieve DMLs. But the DMLs retrieved have their 'WHERE' clause text converted to ROWID's. I need to find out the 'WHERE' clause with the parameters.
I tried retrieving values from the v$sql views, but that information is cryptic and very volatile.
Is there a way to retrieve the 'Where' clause? If not, is there a way to retrieve the 'WHERE' clause information using a trigger against the corresponding table.
I am desparately lookin'for a solution. Hope someone out there can help me out.
Regards,
Prabu Raghav.Hi Andrew,
Thanks for the suggestion.
I am using Oracle 8i not 9i.FGA using DBMS_RLS let's me add policies and retrieve all other information about a user except the SQL statement that's executed by the user.
I want to retrieve the Current sql statement executed against the table by a particular user and record it.
Any suggestions?
Regards,
Prabu Raghav. -
How to construct the where clause for a nested xml target file
Post Author: jlpete72
CA Forum: Data Integration
I'm having some problems getting the desired results creating a multi-level nested xml file. Specifically, it does not seem that the where clause in the child schemas respects values from parent schemas. I'm sure I'm constructing something incorrectly, but am running out of ideas.
I am working with the classic company/order/line hierarchy and there are three levels of output schemas in my target xml file, one for company, order header and order line information.
For testing, I have hardcoded a restriction at the order header line to deal with only one order. But unless I hardcode values into the where clause at the order line level of the schema, all values are returned for orders belonging to the company defined in the company level.
I'm trying a where clause at the order line level similar to:
order_line.customer = order_header.customer and order_line.order_num = order_header.order_num
If the customer has more than one order in the data file, then all orders for that customer are placed in the detail for the order header. Only if I hard code the order number in the where clause do I get only the lines for the order specified in the header section. Not very practical.
What am I missing?An External Parsed Entity could be used to reference a schema.
In your DTD:
<!ENTITY datamodules SYSTEM "file:///c:/Datamodules/Datamodules.xsd">
Refer the external entity in xml document:
<datamodules>&datamodules;</datamodules> -
Help: how to make this WHERE CLAUSE?
Hi,
SELECT * FROM TAB_A
WHERE
FLG IN (DECODE(C_FLG, 0, 'C', 1, '''A'', ''I'''));
What I really want to achieve is:
If C_FLG is 0 then the where clause becomes
WHERE FLG IN ('C')
If C_FLG is 1 then the where clause becomes
WHERE FLG IN ('A', 'I')
Any suggestions?
Thank you in advance.
JimmyHow about:
WHERE (C_FLG = 0 AND FLG = 'C') OR (C_FLG = 1 AND FLG IN ('A','I')) -
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 -
How to set the where clause of a value set on the basis of a form field
I am using a DFF(Descriptive FlexField), which needs to display the value of a certain column(say columnA) on the basis of the value of another column(say columnB).
So i have created a value set which points to the table which has both these columns, and the DFF uses this value set. However, the problem is that I have not put any where clause in the value set, because of which i cannot handle the exact fetch returns more than one rows error.
The query has to be as follows:
select ColumnA from tbl where ColumnB = [ a form value ];
What I want to know is how can i get the value of a certain field of a certain block of the form in the above query.
Edited by: 981615 on Jan 14, 2013 12:48 AM
Edited by: 981615 on Jan 14, 2013 12:48 AMJust 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 -
Hi ,
i needed to write a select query in which the search criteria is
a part of a string .
eg.
select * from DBTABLE where DESCRIPTION = 'abc'.
here abc is a part of any string.
Is the way of writing the select query correct,
If not what is the correct way?>
Harshit Rungta wrote:
> Hi ,
>
> i needed to write a select query in which the search criteria is
> a part of a string .
>
> eg.
> select * from DBTABLE where DESCRIPTION = 'abc'.
>
>
>
> here abc is a part of any string.
>
> Is the way of writing the select query correct,
> If not what is the correct way?
Hi,
select * from dbtable into table i_dbtable where description = 'ABC'.
note : whenever you are checking a condition the string should be in capital letters within quotes. -
How to override the where clause (Bind Variables) in Backing Bean.
HI
I am using bind variables in VO and using exeutewithparam to pass the values to bind. Which is working fine.
But what i want now to override the values pro grammatically from backing_bean of that page.
How can i pass the values to bind variables from bean.
M Niaz.Hi
Try this if it works. this is from 10g
1)create value binding in the backing bean on any action
FacesContext ctx=FacesContext.getCurrentInstance();
ValueBinding vb= ctx.getApplication().createValueBinding("#{bindings['account_name1'].inputValue}");
2) and then set the value for binding
vb.setValue(ctx,(String)accountInput.getValue());
Now execute the method with method binding and execute it
ctx.getApplication().createMethodBinding("#{bindings.ExecuteWithParams.execute}",null).invoke(ctx,null);
Regards
Rohit -
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 -
Case or Decode in the Where clause
Dear all,
My requirement is:
If user select other then "ALL"option from the LOV the following condition should be part of the where clause.
current_req_status = :block1.req_statusIf user select "ALL" from the lov no need to append the above condition in the where clause.
Please give me the sample code
select request_id,doc_name,doc_code,part_id,current_req_status from test_table
where req_type = 'I'
and doc_code = :BLOCK1.doc_code
and -- Here is the condition is changed based on
the :BLOCK1.req_status(LOV).
-- If user select other then "All" option from
this LOV the query append the below condition
current_req_status = :block1.req_status
-- Else no need append the above condition
in the query where clause.Edited by: roots on Apr 10, 2012 9:31 AM
Edited by: roots on Apr 10, 2012 9:38 AMHi InoL,
In the database column not having "ALL" value inside. so the match does not return any values.
My LOV has "A1,A2,A3,A4,....ALL" . the database column having "A1,A2,A3,A4.......". here no "ALL" value.
So if user select "ALL" option from this LOV, that means select all vaules from the database (A1,A2,A3,A4......)..
If user select A1 from the lov the select query include only the matched
column values.from example,
select....
where nvl(database_column,'X')= nvl(:Block1.LOV_value)If user select "ALL" option then no need for above condition in the where clause so that query returns all the rows from the database column.
hope I've clearly explain my requirement.
Thanks lot,
Roots. -
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 -
Query Builder won't apply chosen date to the where clause
Does anybody know why when I chose a date field, in the where clause, when using Query Builder, it won't actually write the chosen date to the actual query?
If I select the "View Query" tab, no date shows up. Also if I press the "Run Report" button in the "View Result" tab, I get this error:
"An error was encountered performing requested operation: ORA-00936: missing expression"
This is because actual date data is missing.
After I hit the "Apply" button, I have to manually type the date data.
I thought this was a bug of the previous version, but I just installed version 1.5.4 and I have no different result.
Thanks.I just wanted to add my name to the list of people having this issue.
Oracle Techies, please help.
Maybe you are looking for
-
hello experts, i want to display the following format in the end of the list of the ALV. the report actually has a grid structure and a list header , and now i want to add the following to the end of the list.
-
Using iPhoto '08 Library w/ Adobe Bridge?
How can import my iPhoto '08 Library into Adobe Bridge?
-
Bought my iPhone 5 about a month ago. Was very happy with it until updated to 6.1.2. Worst mistake ever. Since I have to charge at list twise a day. Today I restore it and all the new pictures don't show up in my photos . I can find them anywhere. T
-
hi. do you have 64 bit pci express sound card?
-
Multiple GPU support in Speedgrade in the future?
Hi: I got a couple questions. -Could Speedgrade support multiple GPUs in the future versions? -Which "cards" are supported in SG Creative Cloud? Matrox, BlueFish, Blackmagic? Could both systems (Mac&Win) works with the same cards? (except for Nvidia