NamedQuery with parameter in IN clause
Hi
I need to execute a query like that returns all the files from the types specified in parameter:
select o from file o where o.id in (:ids)
tried this :
Query query = em.createNamedQuery("File.findByFileIds");
query.setParameter("ids", idlist);
idlist is of list type.
but no success.
thanks for the help.
Hi,
A statement like:
select o from file o where o.id in (:ids) cannot take a value of List<Long> for :ids.
To pass in multiple values for ids, it would have to be something like this:
select o from file o where o.id in (:id1,:id2,:id3).
You can use native query fetaure in JPA to build the query on fly and pass the individual parameter for an item of collection and execute the query.
Regards,
Vinay
Similar Messages
-
Cardinality estimator 2014 is off with OR in where clause
Here is my test setup on SQL Server 2014.
-- Create big table
CREATE TABLE [dbo].[Store](
Id int IDENTITY(1,1) NOT NULL,
City int NOT NULL,
Size int NOT NULL,
Name varchar(max) NULL,
CONSTRAINT [PK_Store] PRIMARY KEY CLUSTERED ([Id] ASC)
GO
CREATE NONCLUSTERED INDEX [IX_Store] ON [dbo].[Store] (City ASC, Size ASC)
GO
-- Fill with 100k rows
INSERT Store
SELECT i % 101, i % 11, 'Store ' + CAST(i AS VARCHAR)
FROM
(SELECT TOP 100000 ROW_NUMBER() OVER (ORDER BY s1.[object_id]) AS i
FROM sys.all_objects s1, sys.all_objects s2) numbers
GO
-- Create small table
CREATE TABLE #StoreRequest (City int NOT NULL, Size int NOT NULL)
GO
INSERT #StoreRequest values (55, 1)
INSERT #StoreRequest values (66, 2)
Now I execute the following query (I force the index to show statistics estimates)
SELECT s.City
FROM #StoreRequest AS r
INNER JOIN Store AS s WITH(INDEX(IX_Store), FORCESEEK)
ON s.City = r.City AND s.Size = r.Size
WHERE s.Size <> 1 OR r.City <> 55
Here are the estimates that I get (I'm not allowed to upload pictures):
Index Seek IX_Store
Actual Number of Rows: 90
Estimated Number of Rows: 50000
Fixing WHERE clause to use one table not two makes the estimate perfect:
SELECT s.City
FROM #StoreRequest AS r
INNER JOIN Store AS s WITH(INDEX(IX_Store), FORCESEEK)
ON s.City = r.City AND s.Size = r.Size
WHERE s.Size <> 1 OR s.City <> 55
Index Seek IX_Store
Actual Number of Rows: 90
Estimated Number of Rows: 89.74
Switching to 2012 compatibility mode gives estimate of 1 in both cases:
Index Seek IX_Store
Actual Number of Rows: 90
Estimated Number of Rows: 1
Could anyone explain the first result? I'm a bit worried about it. The fix in this case is trivial, but this problem gave us quite some headache in more complex real life queries with multiple joins.
Thank you!But not full statistics on a field basis, just sometimes some default stats like total row count that some plans will build. Even your StoreRequest table only has one two-field index that will have a full histogram.
But I've seen SQL Server make massively bad plans on two-field indexes.
I've seen SQL Server go wrong one-column indexes, so that is not a very relevant point.
Temp tables or not, the estimate here is clearly incorrect. SQL Server knows the density of Size and City. It knows the cardinality of the temp table. The density information gives how many rows the the join will produce. The WHERE clause will then remove
a certain number of rows. With no statistics for the temp table, it does not now how many, but it will apply some standard guess.
50000 is a completely bogus number, because the join cannot produce that many rows, and SQL Server is able to compute the join with out the WHERE clause decently. (Well, it estimates 90, when the number is 180.) No, this is obviously a case of the cardinality
estimator giving up completely.
It is worth noting that both these WHERE clauses gives reasonable estimates:
WHERE r.Size <> 11 OR r.City <> 550
WHERE s.Size <> 11 OR s.City <> 550
Whereas these two gives the spooky 50000:
WHERE s.Size <> 11 OR r.City <> 550
WHERE r.Size <> 11 OR s.City <> 550
Erland Sommarskog, SQL Server MVP, [email protected] -
ORDS Template with parameter does not work
Hello everybody,
I can not get working a RESTful Service using the ORDS_SERVICES -API (ORDS version 3.0.0.343.07.58), same Query without parameter (hardcoded product_id) works fine.
declare
l_module_id number;
l_template_id number;
l_handler_id number;
l_parameter_id number;
begin
ORDS_SERVICES.delete_module(p_name => 'test_parameter');
l_module_id := ORDS_SERVICES.create_module(p_name => 'test_parameter',
p_uri_prefix => '/test_parameter',
p_items_per_page => 10,
p_status => 'PUBLISHED',
p_comments => null);
l_template_id := ORDS_SERVICES.add_template(p_module_id => l_module_id,
p_uri_template => '/demo_product_info_10/',
p_priority => 0,
p_etag_type => 'HASH',
p_etag_query => null,
p_comments => null);
l_handler_id := ORDS_SERVICES.add_handler(p_template_id => l_template_id,
p_source_type => 'MEDIA', -- source_type IN ('COLLECTION_FEED', 'COLLECTION_ITEM', 'FEED', 'MEDIA', 'PLSQL', 'QUERY', 'QUERY_1_ROW')
p_source => 'select mimetype, product_image from demo_product_info where product_id = 2',
p_format => 'DEFAULT',
p_method => 'GET',
p_items_per_page => null,
p_mimes_allowed => null,
p_comments => null);
/* now same result but with parameter */
l_template_id := ORDS_SERVICES.add_template(p_module_id => l_module_id,
p_uri_template => '/demo_product_info/{product_id}',
p_priority => 0,
p_etag_type => 'HASH',
p_etag_query => null,
p_comments => null);
l_handler_id := ORDS_SERVICES.add_handler(p_template_id => l_template_id,
p_source_type => 'MEDIA', -- source_type IN ('COLLECTION_FEED', 'COLLECTION_ITEM', 'FEED', 'MEDIA', 'PLSQL', 'QUERY', 'QUERY_1_ROW')
p_source => 'select mimetype, product_image from demo_product_info where product_id = :product_id',
p_format => 'DEFAULT',
p_method => 'GET',
p_items_per_page => null,
p_mimes_allowed => null,
p_comments => null);
l_parameter_id := ORDS_SERVICES.add_parameter(p_handler_id => l_handler_id,
p_name => 'product_id',
p_bind_variable_name => 'product_id',
p_source_type => 'URI',
p_param_type => 'INT',
p_access_method => 'IN',
p_comments => null);
commit;
end;
The first template works fine:
http://localhost:8080/ords/xxx/test_parameter/demo_product_info_10/
shows a jpeg image of a wallet.
The second template does not work:
http://localhost:8080/ords/xxx/test_parameter/demo_product_info/10/
fails with error:
mapped request using: BasePathMapper [basePath=/xxx/] to: SCHEMA:apex|XXX
Choosing: oracle.dbtools.http.dispatch.DispatchMetaData as current candidate with score: MetaDataScore [score=0, matchedMethod= GET: {10299, false}
common: CommonMetaData [accepts=[], cors=null, documentation=null, frameOptions=null, pageSize=10, pagination=NONE, requiresPrivilege=null, transport=null]
, matchedPattern= /test_parameter/demo_product_info/{product_id}
common: CommonMetaData [accepts=[], cors=null, documentation=null, frameOptions=null, pageSize=null, pagination=null, requiresPrivilege=null, transport=null]
methods:
GET: {10299, false}
common: CommonMetaData [accepts=[], cors=null, documentation=null, frameOptions=null, pageSize=10, pagination=NONE, requiresPrivilege=null, transport=null]
stack trace:
oracle.dbtools.http.errors.InternalServerException: java.lang.IllegalArgumentException: INT
at oracle.dbtools.http.errors.ErrorPageFilter.internalError(ErrorPageFilter.java:165)
at oracle.dbtools.http.errors.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
at oracle.dbtools.http.filters.HttpFilter.doFilter(HttpFilter.java:44)
at oracle.dbtools.http.filters.FilterChainImpl.doFilter(FilterChainImpl.java:51)
at oracle.dbtools.http.cors.CORSFilter.doFilter(CORSFilter.java:35)
at oracle.dbtools.http.filters.HttpFilter.doFilter(HttpFilter.java:44)
I changed the add_parameter-call p_param_type => 'INT' to be p_param_type => 'STRING'
then error remains the same and strack trace says
oracle.dbtools.http.errors.InternalServerException: java.lang.IllegalArgumentException: STRING
at oracle.dbtools.http.errors.ErrorPageFilter.internalError(ErrorPageFilter.java:165)
at oracle.dbtools.http.errors.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
Could you please confirm and fix,
kind regards,
TomThis is a guess, but I suspect that ords_services.add_parameter() is not required at all.
Also, your URL /demo_product_info/10/ should not have the trailing slash (according to your template URI).
For more information, I suggest you look here:
ords.3.0.0.343.07.58.zip\ords.war\scripts\migrate\core\ords_migrate.plb
The migration package will show what is usually done for templates that already exist within APEX 4.2. I checked my templates and the ones with URI variables {in-curly-brackets} contain no records in apex_040200.wwv_flow_rt$parameters.
-Kris -
Hi Experts,
I am a BW consultant and new to webdynpro. Not sure how to run RSO_METADATA_REPOSITORY multiple times and by passing different parameter values each time(either taken from an a standard BW table or user provided - anything is fine) and build web pages with parameter name. Need help with direction on where to start.
Let me step back and explain my requirement:
In BW we have an object called transformation.
One way of generating documentation for transformation is highlight transformation and press F1. Then its documentation will be opened as a local web page.
I need these web pages for all transformations. This is my requirment.
I came to know that RSO_METADATA_REPOSITORY is beeing used to generate this web page.
The web link is something like below:
http://ubw05.xxx.com:8005/SAP/BW/DOC/METADATA/?page=BW_O_D&SystemID=BWPCLNT100&ClassID=TRFN&ID=0KHR6J65AIIUTCJZEC093K6XDFV909PB&objectVersion=A&sap-language=EN&sap-client=100
When i run this link seperately(not by selecting transformation and pressing F1) i need to enter login credentials to BW system.
My challenges is how do i pass login credentials and multiple transformation IDs to generate multipe web pages with each page named by transformation ID?
WHere to start? First of all is RSO_METADATA_REPOSITORY Webdynpro JAVA or webdynpro ABAP or can i use anything?
Since it is beeing opened as local webpages i assume it is webdynpro JAVa is that correct?
Thanks,
Raghuhello,
might be a problem with the version you are using.
regards,
the oracle reports team -
Is it possible to create a spatial view with paramete?
Is it possible to create a view with parameter like following:
SELECT GEOM FROM INTERSTATES WHERE MDSYS.SDO_FILTER(GEOM, MDSYS.SDO_GEOMETRY(2003, 8307, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3), MDSYS.SDO_ORDINATE_ARRAY(?, ?, ?, ?)), 'querytype=WINDOW') = 'TRUE'
so that I can specify ???? at run time.
If not, is there a way to create a view that perform variable window query?You may want to look at application contexts, that way you may have code something like this:
create or replace context gis_ctx using gis_params ;
create or replace package gis_params
as
procedure set_bounds( minx in number, miny in number, maxx in number,maxy in number );
end;
create or replace package body gis_params
as
procedure set_bounds( minx in number, miny in number, maxx in number,maxy in number )
is
begin
dbms_session.set_context( 'gis_ctx', 'minx', minx);
dbms_session.set_context( 'gis_ctx', 'miny', miny);
dbms_session.set_context( 'gis_ctx', 'maxx', maxx);
dbms_session.set_context( 'gis_ctx', 'maxy', maxy);
end ;
end ;
To use this method you´ll have to execute
gis_params.set_bounds(-3,40,-2.9,40.1) ;
before doing the select.
SELECT GEOM
FROM INTERSTATES
WHERE MDSYS.SDO_FILTER(GEOM,
MDSYS.SDO_GEOMETRY(2003,
8307,
NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3),
MDSYS.SDO_ORDINATE_ARRAY(sys_context ('gis_ctx', 'minx'),
sys_context ('gis_ctx', 'miny'),
sys_context ('gis_ctx', 'maxx'),
sys_context ('gis_ctx', 'maxy'))),
'querytype=WINDOW') = 'TRUE' ;
I f you are in a web environment, read about GLOBAL CONTEXT ACCESSED GLOBALLY .
Regards, Nico. -
Dear All,
I am getting a below error while doing ehp6 installation on sybase (high availbility )
can any one help me on this..?
An error occurred while processing option SAP Business Suite 7i 2011 > Enhancement Package 6 for SAP ERP 6.0 > SAP Application Server ABAP > SAP ASE > High-Availability System > Database Instance( Last error reported by the step: System call failed. Error 2 (The system cannot find the file specified. ) in execution of system call 'CreateProcessAsUser' with parameter ( , NULL, Program Files/sapinst_instdir/BS2011/ERP606/AS-ABAP/SYB/HA/DB, &StartupInfo, &ProcessInfo), line (646) in file (d:\depot\bas\720_rel\bc_720-2_rel\gen\optu\ntamd64\ins\sapinst\impl\src\syslib\synxcchapp.cpp), stack trace: d:\depot\bas\720_rel\bc_720-2_rel\gen\optu\ntamd64\ins\sapinst\impl\src\ejs\ejscontroller.cpp: 181: EJSControllerImpl::executeScript() d:\depot\bas\720_rel\bc_720-2_rel\gen\optu\ntamd64\ins\sapinst\impl\src\ejs\jsextension.hpp: 1059: CallFunctionBase::call() d:\depot\bas\720_rel\bc_720-2_rel\gen\optu\ntamd64\ins\sapinst\impl\src\osmod\iaxxbprocess.cpp: 423: CIaOsProcess::start_impl() d:\depot\bas\720_rel\bc_720-2_rel\gen\optu\ntamd64\ins\sapinst\impl\src\syslib\synxcchapp.cpp: 238: CSyChildApplicationImpl::start(false) d:\depot\bas\720_rel\bc_720-2_rel\gen\optu\ntamd64\ins\sapinst\impl\src\syslib\synxcchapp.cpp: 262: CSyChildApplicationImpl::doStart() .). You can no
Regards,
Letz..Hello Mauricio.
Thanks
Two Thinks:
1.- This error appears precisely in the process of creating SAP users including you mention sidadm:
A.- Execute sapinst
B.- Installation option is chosen
SAP NetWeaver CE Production Edition
Installation Options
High-Availability System
Central Service Instance (SCS)
c.- System ID, Next and appear message error
2.- However, the user manually create sidadm, I gave the permissions you indicate, and the error message is the same
Thanks -
Oracle WebADI: How to Download the WebADI Excel File with Parameter
Hello Friends,
How to Download the Oracle WebADI Excel File with Parameter??
For Ex: How to download the Employees for Specific Department from Oracle WebADI.
And After to change the specific changes on Employee Data to Upload.
Thanks in Advance.Hi Team.
Any Advise on it!! -
Does BOXI support crystal reports with parameter references in formulas?
I am designing a report in Crystal Reports XI Developer that contains parameters, which are passed to a stored procedure and are also used within formulas ( in Crystal Syntax ie. {?FORMAT_ID} ) in the report itself.
I can run the report successfully in CRXI Developer. The formulas use the correct values from the parameters entered during execution and everything looks good.
I then deploy the report to Business Objects Enterprise XI. I do all of the things necessary to manage the report including setting up the proper database connection information and default parameter values.
When I run the report using the Crystal Report Viewer, I get the following error message:
Error in File Forecasting.rpt:
Error in formula <Report Format>.
'if (not isNull({?FORMAT_ID} ) ) then
This field name is not known.
Details: errorKind
This happens when I press the "Preview" button in the Manage Object dialog from Crystal or when I run the report using InfoView.
I have changed the formulas and it doesn't seem to matter what the specific content of the formula is; other than the existence of a parameter reference in the formula. If I comment out the parameter and replace it with a hard-coded value, it gets through the formula fine.
Does Business Objects Enterprise XI support crystal reports with parameter references in the formulas?
Thanks,
Tim H.Hi,
In Crystal Reports under File -> Report Options >check convert Null Values to default > Verify on first refresh > Verify stored procedures on first refresh.
This corrected the issue by allowing the query engine time to locate those columns and map them to the query being sent by the report.
The convert null values was added because those field were being used in the record selection and grouping.
Regards,
Vinay -
Having with more than one clause
Hi
Is posssible to have a query with more than one clause in having condition
Example In my query I have Count , Sum and AVG , I need to use 3 conditions in having, Is It possible ?
Thank you in advanceHi,
yes, in Having you can also use AND and OR.
with x as (select 1 nr from dual)
select nr
from x
group by nr
having count(*) = 1
and sum(nr) = 1Herald ten Dam
http://htendam.wordpress.com -
Problems with Parameter Mapping
Hi All,
I have problems with parameter-mapping. For me its a black box, sometimes it works sometimes not.
Lots of times my mappings doesnt work, and I dont know the reason.
For example: I want to map my Execution-CO to the Display-CO. For that I map the in the affected Action.
But it doesnt work, although I do have the same Context Structures, because its the same CO. The technical Name is also the same.
What could it be?
Thanks for answering me
Bye SteveHi Andre,
sorry for my late answer, but I'm writing my diploma thesis and wasnt at work since wednesday and so I dont have a access to our GP-System.
Hope I understood you right.
The Use Case of parameter mapping is that Users of further steps has the possibility to see the Input of previous steps.
When I dont map the parameter inside one action, it isnt possible. I tried it out with the SAP example "Time-off-process". I took the CO "Create Request" and add it in one Action (as Display & Execution). When I understand you right mapping inside an action is not necessary, to see the Inputs from further Actions --> But this way I cannot see the Inputs.
The mapping of my application works before I changed it.
I know never touch a running system, but It was necessary, we need a new Input and Output Parameter.
Cause I have 20 parameter the mapping was very time-consuming, to map every single parameter. I read a method to reduce the time: Adding a structure requires only mapping of the two structures. But now the Mapping doesnt work.
Hope you can help me
Bye Steve -
Dear Sir….
How can I Macke log in user if success to page with
parameter.
I have DW SC4
Your reply it’s highly appreciates.
Regards;Please your help.
-
Stored Procedure in access with parameter name
Hi, i'm new in JDBC.
I came from Ado.Net.
I want to call a stored procedure in access and set my parameters by name and not by index.
When i try to call the SP with params by index it works as expected,
but with param names it give me this exception:
java.lang.UnsupportedOperationException
Is there a way to call SP with parameter names?
BogN,Well, it still doesn't work. Here is part of the code, have a look please.
public DisplayQueryResults() {
String studattUrl = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:/StudAtt/StudAtt.mdb";
String mustbUrl = "jdbc:odbc:mustb";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
studattConn = DriverManager.getConnection(studattUrl);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
mustbConn = DriverManager.getConnection(mustbUrl, "sa", "");
private void getTable() {
try {
stmtStudAtt = studattConn.createStatement(resultSet.TYPE_SCROLL_SENSITIVE, resultSet.CONCUR_READ_ONLY);
stmtMustb = mustbConn.createStatement();
CallableStatement callSP = studattConn.prepareCall("{call mustbFaculty}");
resultSet = callSP.executeQuery();
displayResultSet(resultSet);
} -
CANT execute query with parameter on user defined tables using query genera
Dear All,
I have problem when executing query with parameter on user defined tables using query generator.
It seems SBO cannot accept parameter to query user defined tables.
I've tried these:
SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = [%0] --- this FAIL
I try to pass the value directly without using parameter and It works
SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = 2 --- this SUCCESS
This one works
SELECT * FROM RDOC T0 WHERE T0.width =[%0] --- this SUCCESS
and this one works too
SELECT * FROM RDOC T0 WHERE T0.width = 595 --- this SUCCESS
Is there anyone can help me ....???
Thanks,
AlfaI generated this code using query wizard ....
SELECT T0.[U_Status] AS 'Document Status' FROM [dbo].[@ST_PR_H] T0 WHERE T0.[U_Status] = (N'2' )
and replaced the (N'2' ) with [%0]
SELECT T0.[U_Status] AS 'Document Status' FROM [dbo].[@ST_PR_H] T0 WHERE T0.[U_Status] = [%0]
and It worked ......
Thanks 4 all ..... -
On success of form save I want to go to another for with a detail where clause
I have the follow code snippet which is intented to go to a form on a successfull save. I query some data based on the save then build a url to navigate to a new form. I want the form to show only data that is lacking in one column not being populated (column is null). The url works, but the form detail where clause is ignored. Does anyone have any experience with passing detail where clauses to a form? Did I miss something in the code below?
begin
select count(rl_id) into n_rl_id_cnt
from rfq_lines
where part_part_id is null and rh_rh_id=n_rh_id;
exception
when others then
null;
end;
htp.p('cnt '||to_char(n_rl_id_cnt));
if n_rl_id_cnt>0 then
htp.p('cnt >1');
my_url := 'PORTAL30.wwa_app_module.link?' ||
'p_arg_names=_moduleid&p_arg_values=3677858481' ||
'&p_arg_names=_show_header&p_arg_values=YES' ||
'&p_arg_names=rh_id&p_arg_values=' || LTRIM(TO_CHAR(n_rh_id)) ||
'&p_arg_names=_rh_id_cond&p_arg_values=%3D'||
'&p_arg_names=_detail_where_clause&p_arg_values=part_part_id%20is%20null'; -- <this is not working right. where clause is ignored.
htp.p(my_url);
go (my_url);Hi Jeffrey ,
You need to use a custom Format script for the field.
Regards
Sukrit Dhingra -
Create a view with a changing where clause
Hi all,
i'm developing an application with oracle forms i want to create a view in the database with a different where clause in every time , the where clause is determined due to the department id of the current user .
thanks alot.SQL> create view emp_view as select empno, ename, deptno from emp;
View created.
SQL> select * from emp_view where deptno = 10;
EMPNO ENAME DEPTNO
7782 CLARK 10
7839 KING 10
7934 MILLER 10
SQL>
Maybe you are looking for
-
Mail won't open after installing Lion 10.7.4
Hi at all, I have just downgraded my Mac Book Pro - June 2010 from OS X 10.8 - DP3 12A206J to Lion OS X 10.7.4, as soon as I started checking everything's ok I found out Mail's not working anymore, with the following error showing up. "Mail cannot be
-
I am trying to access my Template on Proxibid's Auctioneer website and the Firefox screen goes away, showing me my wallpaper, then it comes back and says Firefox is not responding, then it suddenly displays a full screen of HTML. I spoke with Proxibi
-
Company Merger Prerequisite - SAP MM
Hi Experts, Before posing i have check the post regarding this, but not find suitable solution. We have 2 company codes, now we have to merger both company codes under single company code. In MM & CIN what will be prerequisites, scenario's & cut over
-
How do I set up my new HP laptop to view photos from a DVD?
How do I set up my HP laptop to view photos from a DVD?
-
HT201269 What type of data/information can be transferred through iCloud?
Hi there, I just received my new iPhone 5, & I still have my old iPhone 3GS, which have all of my ringtones & songs that i used to listen to, & I would like to have them on my new iPhone 5. But the problem is that I no longer use my old PC, which use