Oracle ADF View Object Expert Mode setWhereClause can't execute parameter from wrapped query - where-clause

I have a query which is expert mode query. Also I have viewCriteria and whereClause.
When I use whereClause like under and execute; viewObject can't take any row from database. But when I put the same query in toad, i can see the result. Can you help me...
viewObject getQuery result
SELECT *
FROM (SELECT CO.CUST_ORD_ID,
PA.ACTORID_ AS WRK_GRP_ID,
CO.CUST_ID,
cam_pkg.getCustomerFullName (CO.CUST_ID) AS CUST_NAME,
WG.NAME AS WRK_GRP_NAME,
TI.CREATE_ AS ACTOIN_DATE,
WT.WFLW_TASK_ID,
WT.NAME AS WFLW_TASK_NAME,
TI.NAME_ AS TASK_SHRT_CODE,
CO.ORD_ST_ID,
ORS.NAME AS ORD_ST_NAME,
TI.PROCINST_ AS PROC_INSC_ID,
TI.ID_ AS TASK_ID
FROM cust_ord co,
JBPM_TASKINSTANCE TI,
jbpm_pooledactor PA,
jbpm_taskactorpool TAP,
wrk_grp WG,
ord_st ORS,
WFLW_TASK wt
WHERE CO.CUST_ORD_ID =
jbpm_pkg.get_subLong_jbpm_var_insc (TI.PROCINST_,
'CustOrderId')
AND TI.ISOPEN_ = 1
AND TI.END_ IS NULL) QRSLT
WHERE (TASK_ID IN
(1128732,
1129513))

which version of jdeveloper? and how exactly are you applying the view criteria? Are you sure you query is getting formed as you are expecting? Try to enable logging by putting
-Djbo.debugoutput=console in the run/debug properties of your view control project (make sure to bounce the server)

Related

Want to create user-accessible form in Axapta that uses SQL with a substring function

I have some sqlserver sql that due to data can't be modified, which I currently run from Sqlserver. It uses a substring function. I want to stop running it from Sqlserver and create a user-accessible form in which the user enters a date and the script goes off and does it's thing and returns row data to the user.
Not overly familar with X++. I've looked at reports, querys, jobs, statement classes, not sure what's the correct path.
Below is the sql code.
'
select a.description,b.itemid, c.phantom,a.createddatetime,a.createdby
from sysdatabaselog A
inner join
bomversion B
on substring(a.description,1,11) = b.bomid
inner join
inventtable C
on b.itemid = c.itemid
where (table_ = 18 and logtype=1)
and a.CREATEDDATETIME > '2018-03-01' <-------- this would be user-supplied on the form
and c.phantom=1
'
What you're trying to accomplish is actually pretty high-level in AX and requires a several different dev techniques to accomplish it. I'm not going to do the entire thing for you, but I'll get you started and tell you what you need to do. These screenshots are from AX2012.
To accomplish the SUBSTRING() you need an AX View + String computed column.
For your view, you'll want an AX Query object to contain your joins OR you can just do a simple view on the BOMVersion table and then work against that.
Here's an example View and String computed column and the method for the computed column. I just used SalesTable and SalesId as the sample.
public static server str compSubStrSalesName()
{
str result;
result = strFmt("SUBSTRING(%1, 1, 5)",
SysComputedColumn::returnField(identifierStr(SubStringExample), // The name of your view
identifierStr(SalesTable_1), // The name of your view's datasource
identifierStr(SalesId) // The name of the field
)
);
return result;
}

Like Clause over an 'Element' - ORACLE APEX

I encounter some problems that i don't understand with APEX.... Well, let's be specific.
I ve got a select element retrieving a top 50 of most liked url (P11_URL). This is populate by a table view, TOp_Domains.
I create an element called "Context" that have to print all text containing the URL selected by the user from the element select. Those Texts come from another table, let's say "twitter_post".
I create a dynamic action (show only) with this sql/statement:
Select TXT, NB_RT, RANK
from myschema.twitter_post
where TXT like '%:P11_URL%'
group by TXT, NB_RT, RANK
.... and it doesn't work... I think APEX don't like like clause... But i don't know how to do. Let's keep in min an url could have been shared by multiple Tweets, that's why this element "context" is important for me.
I tried to bypass the problem by building a State (in french Statique) and a dynamic action that will refresh the state but it doesn't work neither... bouhououououou
TriX
Right click on the 'P11_URL' and create DA. Event :change, Item:P11_URL. As the true action of the DA, select 'Set Value'. Write your query in the sql stmt area. In the page items to submit, select 'P11_URL' . In the 'Affected Items': select 'Context'.
Query should be :
Select TXT, NB_RT, RANK
from myschema.twitter_post
where TXT like '%' || :P11_URL || '%'
group by TXT, NB_RT, RANK
So
Thanks to #Madona... Their example made me realised my mistake. I wrote the answer here for futher help if somebody encouter the same porblem.
A list select element get as arguments a display value (the one you want to be shown in your screen.... if you want so....^^ ) and a return value (in order, I think to linked dynamic actions). So to solved my problem i had to shape my sql statement as:
select hashtags d, hastags r
from my table
order by 1
[let s say that now in Apex it s an object called P1_HASHTAGS]
First step problem solving.
In fact, the ranking as second value, as i put into my sql statement was making some mitsakens into my 'Where like' clause search... well... Newbie am i!
Second step was to correctly formate the sql statement receiving the datas from my select lov (P1_HASHTAGS) into my interactive report. As shown here:
Select Id, hashtags
from my table
where txt like '%'||:P1_HASHTAGS||'%'
And it works!
Thank you Madona your example helped me figure my mistakes!

Syntax error on WITH clause

I am working on a web app and there are some long winded stored procedures and just trying to figure something out, I have extracted this part of the stored proc, but cant get it to work. The guy who did this is creating alias after alias.. and I just want to get a section to work it out. Its complaining about the ending but all the curly brackets seem to match. Thanks in advance..
FInputs is another stored procedure.. the whole thing is referred to as BASE.. the result of this was being put in a temp table where its all referred to as U. I am trying to break it down into separate sections.
;WITH Base AS
(
SELECT
*
FROM F_Inputs(1,1,100021)
),
U AS
(
SELECT
ISNULL(q.CoverPK,r.CoverPK) AS CoverPK,
OneLine,
InputPK,
ISNULL(q.InputName,r.InputName) AS InputName,
InputOrdinal,
InputType,
ParentPK,
InputTriggerFK,
ISNULL(q.InputString,r.InputString) AS InputString,
PageNo,
r.RatePK,
RateName,
Rate,
Threshold,
ISNULL(q.Excess,r.Excess) AS Excess,
RateLabel,
RateTip,
Refer,
DivBy,
RateOrdinal,
RateBW,
ngRequired,
ISNULL(q.RateValue,r.RateValue) AS RateValue,
ngClass,
ngPattern,
UnitType,
TableChildren,
TableFirstColumn,
parentRatePK,
listRatePK,
NewParentBW,
NewChildBW,
ISNULL(q.SumInsured,0) AS SumInsured,
ISNULL(q.NoItems,0) AS NoItems,
DisplayBW,
ReturnBW,
StringBW,
r.lblSumInsured,
lblNumber,
SubRateHeading,
TrigSubHeadings,
ISNULL(q.RateTypeFK,r.RateTypeFK) AS RateTypeFK,
0 AS ListNo,
0 AS ListOrdinal,
InputSelectedPK,
InputVis,
CASE
WHEN ISNULL(NewChildBW,0) = 0
THEN 1
WHEN q.RatePK is NOT null
THEN 1
ELSE RateVis
END AS RateVis,
RateStatus,
DiscountFirstRate,
DiscountSubsequentRate,
CoverCalcFK,
TradeFilter,
ngDisabled,
RateGroup,
SectionNo
FROM BASE R
LEFT JOIN QuoteInputs Q
ON q.RatePK = r.RatePK
AND q.ListNo = 0
AND q.QuoteId = 100021 )
Well, I explained the issue in the comments section already. I'm doing it here again, so future readers find the answer more easily.
A WITH clause is part of a query. It creates a view on-the-fly, e.g.:
with toys as (select * from products where type = 'toys') select * from toys;
Without the query at the end, the statement is invalid (and would not make much sense anyhow; if one wanted a permanent view for later use, one would use CREATE VIEW instead).

My SCCM 2007 SQL Web Report is not displaying results

I created an SCCM SQL report using SQL Management Studio. I then created the following prompts for my Asset Management Office to use on the web report: Publisher, Display Name, and Version.
The Display Name and the Version prompts are both optional.
I receive no syntax errors or anything, but I receive absolutely no results whatsoever when I click on the Display button to produce the web report.
Here is my SQL code:
==================================================================================
SELECT dbo.v_R_System.Netbios_Name0, dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0, dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0,
dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0
FROM dbo.v_R_System INNER JOIN
dbo.v_GS_ADD_REMOVE_PROGRAMS ON dbo.v_R_System.ResourceID = dbo.v_GS_ADD_REMOVE_PROGRAMS.ResourceID
WHERE dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 = #DisplayName AND dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0 = #Version AND dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0 = #Publisher
Order by dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 ASC
==================================================================================
I run my report and in the Publisher prompt, I type in something like %Autodesk% and then I click the Display button, and absolutely nothing is displayed. I can go to another report and look up Autodesk products, but not this one. I am not a well versed SQL guy, so if anyone can help me that would be great.
Thanks
% signs often mean wildcards. They are used with the like keyword. You have equal signs. In other words,
where DisplayName like '%fred%'
will return fred, freddie, frederick, etc. However,
where DisplayName = '%fred%'
will only return %fred%
AHHHH I see what you were talking about Dan.
Disregard my last statement/inquiry everyone, I got my code working now. My Prompt #variables' SQL code was not configured properly to work with the "Like" constant so I modified my main SQL code to be this:
==================================================================================
Select Distinct dbo.v_R_System.Netbios_Name0, dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0, dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0, dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0
FROM dbo.v_R_System
Join dbo.v_GS_ADD_REMOVE_PROGRAMS On dbo.v_R_System.ResourceID = dbo.v_GS_ADD_REMOVE_PROGRAMS.ResourceID
Where dbo.v_GS_ADD_REMOVE_PROGRAMS.Publisher0 Like #Publisher Or dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 Like #DisplayName Or dbo.v_GS_ADD_REMOVE_PROGRAMS.Version0 Like #VersionOrder by dbo.v_GS_ADD_REMOVE_PROGRAMS.DisplayName0 ASC
==================================================================================
Then I had to modify my Prompt SQL code to use the Begin, If, Else, and End statements. I will pick just my #Publisher variable Prompt SQL code since all of my Prompt #variables' SQL code are basically identical.
Here is the SQL code for my Publisher (#Publisher) Prompt:
==================================================================================
Begin
If(#__filterwildcard = '')
Select Distinct Publisher0
From v_Add_Remove_Programs Order By Publisher0
Else
Select Distinct Publisher0
From v_Add_Remove_Programs
Where Publisher0 Like #__filterwildcard
Order By Publisher0
End
==================================================================================
The code I used before for my Prompt #variables was like this which did not work with the "Like" constant in my main SQL code:
==================================================================================
Select Distinct Publisher0
From v_Add_Remove_Programs Order By Publisher0
Where Publisher0 Like #__filterwildcard
Order By Publisher0
==================================================================================
So, apparently using the Begin, If, Else, and End statements allowed for more logic in this query process, therefore allowing me to use the "Like" constant in my main SQL code for the report.

SQL Update on joined tables with calculated fields

First of all, I know there are already questions and answers about it, this thread being the one that is closest to what I need:
SQL Update to the SUM of its joined values
However, I get a syntax error (operator missing) that seems to occur close to the FROM clause. However I can't see it. Does it not like the FROM itself ? I am not used to using FROM in an update statement but it seems like it's valid from the QA I just linked :|
Any idea why there would be a syntax error there ?
I am using Access 2007 SP3.
Edit:
Wow, I forgot to post the query...
UPDATE r
SET
r.tempsmoy_requete_min = tmm.moy_mob_requete
FROM
rapports AS r INNER JOIN
(SELECT
id_fichier,
Round(Sum(temps_requete_min)/3,0) As moy_mob_requete,
Round(Sum(temps_analyse_min)/3,0) As moy_mob_analyse,
Round(Sum(temps_maj_min)/3,0) As moy_mob_maj,
Round(Sum(temps_rap_min)/3,0) As moy_mob_rap,
Round(Sum(temps_ddc_min)/3,0) As moy_mob_ddc
FROM maintenances
WHERE
periode In (10,9,8) And
annee=2011
GROUP BY id_fichier) AS tmm ON rapports.id_rapport = tmm.id_fichier
WHERE
1=0
The WHERE 1=0 part is because I want to test further the subquery before running it.
Edit: This is some simpler query I am trying. I get a different error this time. It now tells me that tempsmoy_requete_min (and probably all other left operands) are not part of an aggregate function... which is the point of my query. Any idea ?
UPDATE
rapports INNER JOIN maintenances ON rapports.id_rapport = maintenances.id_fichier
SET
rapports.tempsmoy_requete_min = Round(Sum(temps_requete_min)/3,0),
rapports.tempsmoy_analyse_min = Round(Sum(temps_analyse_min)/3,0),
rapports.tempsmoy_maj_min = Round(Sum(temps_maj_min)/3,0),
rapports.tempsmoy_rap_min = Round(Sum(temps_rap_min)/3,0),
rapports.tempsmoy_ddc_min = Round(Sum(temps_ddc_min)/3,0)
WHERE
maintenances.periode In (10,9,8) And
maintenances.annee=2011 AND
1=0
I tried adapting your first query sample, and was able to make your error go away. However then I encountered a different error ('Operation must use an updateable query').
It may be possible to overcome that error, too. However, I found it easier to use a domain function instead of a join to retrieve the replacement value.
UPDATE rapports
SET tempsmoy_requete_min = Round(DSum("temps_requete_min",
"maintenances",
"periode In (10,9,8) AND annee=2011 "
& "AND id_fichier='" & id_rapport
& "'")/3, 0);
If this suggestion works for tempsmoy_requete_min with your data, you will have to extend it to the other fields you want to replace. That won't be pretty. You could make it less ugly with a saved query which you then use as the "Domain" parameter for DSum() ... that could allow you to use a simpler "Criteria" parameter.
UPDATE r
should be
UPDATE rapports
You can't reliably use an alias in the update target.