How to use wildcards in the query
Hi all,
I have the following code:
pStmt = conn.prepareStatement("SELECT * FROM library.books where title like ?",java.sql.ResultSet.TYPE_FORWARD_ONLY,java.sql.ResultSet.CONCUR_UPDATABLE);
pStmt.setString(1, name);
rs = pStmt.executeQuery();When I try to apply the following query including wildcard "%", I get an error:
SELECT *
FROM `books`
WHERE `title` LIKE '%?%';Doesn't Java accept "%" in the queries?
I didn't write whole code not to disturb the focus, but here it is:
private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {
ResultSet rs=null;
String[] pathS= new String[1000];
PreparedStatement pStmt = null;
int j=0;
try{
Connection conn = HandleCon.getConnInstance();
pStmt = conn.prepareStatement("DELETE FROM library.tempbook "
,java.sql.ResultSet.TYPE_FORWARD_ONLY,java.sql.ResultSet.CONCUR_UPDATABLE);
pStmt.execute();
if((jTextField12.getText().equals(""))) {
JOptionPane.showMessageDialog(null, "YOU SHOULD FILL","Display Message",JOptionPane.ERROR_MESSAGE);
} else{
String name;
name=jTextField12.getText();
pStmt = conn.prepareStatement("SELECT * FROM library.books where title like
%?%",java.sql.ResultSet.TYPE_FORWARD_ONLY,java.sql.ResultSet.CONCUR_UPDATABLE);
pStmt.setString(1, name);
rs = pStmt.executeQuery();
while (rs.next()) {
String a;
a=rs.getString(1);
String b;
b=rs.getString(2);
String c;
c=rs.getString(3);
String d;
d=rs.getString(4);
String e;
e=rs.getString(5);
String f;
f=rs.getString(6);
pathS[j]=f;
j++;
pStmt = conn.prepareStatement("INSERT INTO library.tempbook
(title,author,publisher,content,tag,paths) " + "VALUES
(?,?,?,?,?,?)",java.sql.ResultSet.TYPE_FORWARD_ONLY,java.sql.ResultSet.CONCUR_UPDATABLE);
pStmt.setString(1, a);
pStmt.setString(2, b);
pStmt.setString(3, c);
pStmt.setString(4, d);
pStmt.setString(5, e);
pStmt.setString(6, f);
pStmt.execute();
jList2.setListData(pathS);
catch (Exception e) {
System.err.println(e);
}I get the following error:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near '%'pap'%' at line 1The mentioned query runs when I use phpMyAdmin.
Similar Messages
-
How to use wildcards in ABAP query where condition?
Hi,
Please tell me how to use wildcards in ABAP qurey where condition.
e.g. select * from mara where matnr = * (wildcard we need to use.
Thanks & Regards,
Gaurav TDo you want to query asterix * ?
select * from mara where matnr = '*'. "then just put it in apstrophes
or you want certain part of string be used as * ?
select * from mara where matnr like '%*' "then use % sign before it
or maybe you want something like this
select * from mara where matnr like '%1' . "then it will look for all materials having '1' inside it
Regards
Marcin -
Imagine an invoice was created for a customer on the 1st of January 2008 for £1000
On the 1st of Feb, he paid $300, owing $700
On the 1st of Mar, he paid $450, owing $250
On the 1st of Apr, he paid $250.
If I run an AR report today the 10th of Aug, I would see he owes nothing. What I want to do is to run the report today based on the 2nd of March and see a debt of £250. I dont want to use the posting date in the selection criteria henceI think this is the case when you use a key date but Im not sure how to use this in the query properties of BI7. What Characteristic do I need to specify as time dependant? Is there anything else I should consider?hi,
Key Date setting is for the 'time dependent' master data.
Lets say u have a Characteristic MATERIAL with a time dependent attribute MATERIAL GROUP as follows.
MATERIAL FROM TO MATERIAL GROUP
ABD 01/01/1995 12/31/2003 X
ABD 01/01/2004 12/31/9999 Y
Depending on what you have for the Keydate, the Material group is selected.
If your key date is, ex, 06/12/2001 there material group is X. Or if key date is 02/15/2005, material group is Y.
If you do not enter any value for keydate, system automatically assumes today' date.
hope it helps.. -
How to find out query name using Elements of the query builder.
Hi SDNers,
how to find out query name using Elements of the query .
thanks,
satyaaHi,
For having a look at the relation between BEx tables,check the link below:
http://wiki.sdn.sap.com/wiki/display/BI/ExploretherelationbetweenBEx+Tables
-Vikram -
How can i know which index will be used when executing the query ?
1 ) I have query in which i have 3-4 tables but there multiple index on one column .
so how can i know which index will be used when executing the query ?
2) I have a query which ia taking too much time . how can i know which table is taking too much time ?
3) Please Provide me some document of EXplain plan ?Hi Jimmy,
Consider the below example
/* Formatted on 2011/02/04 21:59 (Formatter Plus v4.8.8) */
CREATE TABLE FIRST AS
SELECT * FROM all_objects;
UPDATE FIRST
SET object_name = 'TEST'
WHERE owner != 'SCOTT';
CREATE INDEX idx_first ON FIRST(object_name);
SELECT *
FROM FIRST
WHERE object_name = 'TEST';
It has not used index
Execution Plan
Plan hash value: 2265626682
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 58678 | 7334K| 163 (4)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| FIRST | 58678 | 7334K| 163 (4)| 00:00:02 |
/* Formatted on 2011/02/04 21:59 (Formatter Plus v4.8.8) */
SELECT *
FROM FIRST
WHERE object_name = 'emp';
This has used the index
Execution Plan
Plan hash value: 1184810458
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 128 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| FIRST | 1 | 128 | 1 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_FIRST | 1 | | 1 (0)| 00:00:01 |
From this we can come to the conclusion that, whether to use one index or not by oracle
would also depend on the data which is present in the table. This has to be this way as
we see in the bind peeking, if oracle sticks to only one plan, say only use the full table
scan, it would be a performance hit when it searches for the second query ie where object_name
='emp';
2.
If we have a query like below.
select * from emp
where upper(ename) = upper(:p_ename);
Evenif we have the index on ename column, oracle wouldn't be able to use the index, as there is a function in the predicate column. If you need oracle to use the index, we need to create a function based index as below.
Create index idx_ename on emp(upper(ename));
Regards,
Cool -
How to put distinct in the query
Hi all,
How to put distinct in the query.I checked in RPD , Distinct supported is already available. I marked the distinct check box in advance option still then i'm not getting distinct in the query.
any idea , please help...In the RPD i have join between base table and view .i'm selecting 2 columns one from base table and other from view . which gives cartesian product . to avoid that i want to put distinct . I'm not using any measure . I'm taking direct columns.
I'm getting distinct keyword if i'm accessing the report directly . but when i'm accessing it from dashboard in the back end while preparing the query it's writing distinct but the actual query which is sending to db does not have distinct.
==================================================
RqList distinct
VW_SCNR_114000074_TA_DATA.Match Identifier as c1 GB,
VW_SCNR_114000074_TA_DATA.Tot Trans Amt as c2 GB,
VW_SCNR_114000074_TA_DATA.Tot Trans Ct as c3 GB,
case when VW_SCNR_114000074_TA_DATA.Alert Quality Code = '1' then 'Productive' when VW_SCNR_114000074_TA_DATA.Alert Quality Code = '2' then 'Non Productive' else 'Indeterminate' end as c4 GB,
VW_SCNR_114000074_TA_DATA.Batch Identifier as c5 GB
DetailFilter: Alert TA Data.Run Id > 0 and Alert Scenarios.Scenario Name = 'ScnroName' and Alert TA Data.Batch Id > 0
OrderBy: c4 desc
=================================================
-------------------- Sending query to database named KYC1.1DEV-179 (id: <<16315>>):
select T353.BATCH_ID as c1,
case when T353.QLTY_RTG_CD = '1' then 'Productive' when T353.QLTY_RTG_CD = '2' then 'Non Productive' else 'Indeterminate' end as c2,
T353.TOT_TRXN_CT as c3,
T353.TOT_TRXN_AM as c4,
T353.BREAK_ID as c5,
T117.SCNRO_NM as c6
from
KDD_SCNRO T117,
KDD_TA_DATA T130,
KDD_TSHLD_SET T171,
VW_SCNR_114000074_TA_DATA T353
where ( T117.SCNRO_ID = T130.SCNRO_ID and T117.SCNRO_ID = T171.SCNRO_ID and T130.SCNRO_ID = T171.SCNRO_ID and T130.SCNRO_ID = T353.SCNRO_ID and T130.TSHLD_SET_ID = T171.TSHLD_SET_ID and T171.SCNRO_ID = T353.SCNRO_ID and T171.TSHLD_SET_ID = T353.TSHLD_SET_ID and 0 < T130.BATCH_ID and 0 < T130.RUN_ID ) -
How to pass parameter to the Query String of the Named Queries'SQL
Firstly to say sorry,I'm a beginner and my English is very little.
Now I want to know
How to pass parameter to the Query String of the Named Queries'SQL in the Map editor.
Thanks.benzi,
Not sure if this is on target for your question, but see #5 in the link below for some web screencasts that show how to pass an input text form field value to the bind variable of a view object. If you're looking for something different, maybe provide some more details such as what you are trying to accomplish and what technology stack you are using - for example, ADF BC, JSF, etc.
http://radio.weblogs.com/0118231/stories/2005/06/24/jdeveloperAdfScreencasts.html
Also see section 5.9 and chapter 18 in the developer's guide.
thanks -
How many optional allowed in the query?
Hi,
Data base is getting disconnected while running the below sparql query (Query with 9 optional conditions).
I tested the query with 5 optional its working fine but, its not working for more than 5 optional.
How many optional allowed in the query?
Please advice me to solve this problem.
Error Detail: ORA-03113: end-of-file on communication channel
SELECT bi, OWNER,name,usage,notes,icto,app,ssd,ssdname,ssdid,sdname,sdarchitect,schedule
FROM TABLE (sem_match('{
?bi rdf:type di:Bulk_Interface .
?bi di:hasBulkInterfaceItOwner ?OWNER .
?bi di:hasBulkInterfaceName ?name .
?bi di:hasBulkInterfaceRecipientApplicationArea ?usage .
?bi di:hasBulkInterfaceRecipientFeederType ?notes .
?bi di:hasBulkInterfaceSupplierApplicationId ?icto .
?app ds:hasConceptualSourceApplicationIctoId ?icto .
?ssd ds:hasConceptualSourceApplication ?app .
?ssd ds:hasConceptualSourceSubdomainName ?ssdname .
?ssd ds:hasConceptualSourceSubdomainIctoId ?ssdid .
?sd ds:hasConceptualSourceSubdomain ?ssd .
?sd ds:hasConceptualSourceDomainName ?sdname .
?sd ds:hasConceptualSourceDomainArchitect ?sdarchitect .
?bi di:hasBulkInterfaceDeliverySchedule ?schedule
optional {?bi di:hasBulkInterfaceRecSet1AverageStorageRequirements ?avgsize}
optional {?bi di:hasBulkInterfaceWorstStorageRequirements ?maxsize}
optional {?bi di:hasBulkInterfaceRecSet1AverageNumberOfRecords ?avgrec}
optional {?bi di:hasBulkInterfaceAverageNumberOfRecords ?avgrec}
optional {?bi di:hasBulkInterfaceRecSet1WorstNumberOfRecords ?maxrec}
optional {?bi di:hasBulkInterfaceWorstNumberOfRecords ?maxrec}
optional {?bi di:hasBulkInterfaceTransferMethodJob ?job}
optional {?bi di:hasBulkInterfaceDataFileAvailability ?post}
optional {?bi di:hasBulkInterfaceBusinessDescription ?descr}
sem_models ('IFM_CURR', 'SRC_CURR'),
SEM_Rulebases('OWLPRIME'),
sem_aliases(SEM_ALIAS('di','http://www.cse.com/sbip/dwh/mdm/data_interface#'),
SEM_ALIAS('ds','http://www.cse.com/sbip/dwh/mdm/data_sources#'))
, NULL));
Let me know if you need any other details.
Regards,
Kavitha.
Edited by: 789259 on Aug 3, 2011 2:01 AMIf possible, I would suggest that you upgrade to the latest release: 11.2.0.2.0. It has many bugfixes and enhancements.
There is no limit on the number of optionals per query. I suspect that the use of the same new variables (?avgrec and ?maxrec) in the parallel optional clauses is the reason you are seeing the error in this particular case. If you use different variable names does the error go away? If needed, you can use a coalesce in the outer SQL SELECT to get the same behavior as before (e.g. COALESCE(avgrec1, avgrec2) as avgrec).
Thanks,
Matt -
How can i display all the query items to a table?
how can i display all the query items to a table in a jsp file?
i always have an out of memory error..any body??any idea?
is it possible thru configuration or i have to write a program by the abaper??
Biswa -
I just bought photoshop elements 13 last night. Today I am watching tutorial videos to show me how to use it, but the videos are showing me things I don't have. Asking me to click on tabs i don't have. Why is this? Is there another way I can learn? Or is my download messed up and not giving me everything I need?
Got a link showing us which video tutorials you're watching and examples of what's missing in your software?
-
How to use shortDesc in the disabled inputtext
hi,all
i encounter a problem,our team must use disabled inputtext when the text is only used to output string.
the reson we don't use outputext is if there is noting in the outputtext,there is nothing displayed.
how to use shortDesc in the disabled inputtext?
here is the code:
<af:inputText value="#{bindings.shortdesc.inputValue}" disable="true"
id="ot2" columns="25" shortDesc="#{bindings.longdesc.inputValue}"
simple="true"/>
thanks allHi,
........... I use JDev 11g ..............
If you make your inputText disabled -----> shortDesc will not be displayed.
You can make a workaround to achieve this by using popup as :
1- add showPopupBehavior inside your inputText as :
<af:inputText label="label1" id="it1" disabled="true">
<af:showPopupBehavior triggerType="mouseOver"
align="endBefore" alignId="it1"
popupId="p1"/>
</af:inputText>2- add a popup which will display your shortDesc text
<af:popup id="p1">
<af:outputText value="Sameh POPUP" id="ot1"/>
</af:popup>I hope it is useful.
Sameh Nassar -
How to use labview with the handyboard
Hi,
how to use labview with the handyboard
Thx...I'm assuming you're talking about this, since you didn't provide a link for those of us who don't know what you're talking about.
As the other poster said, you didn't say how you want to use LabVIEW with it. If you want to write LabVIEW programs than run on the microprocessor, then you're out of luck. If you want LabVIEW to interact with it, then you've got a couple of options, SPI probably being the best, but it also has DI and AI that you could use to communicate with it - the DI's could be used as a parallel interface.
Message Edited by Matthew Kelton on 12-17-2007 02:21 PM -
1,How to use PS to judge the existence of a folder in the specified directory?(use javascript)
2, how to use PS in the specified directory to create to create the folder?(use javascript)
Thanks you!Thanks you!
-
I downloaded the free trial for Adobe XI Pro but now I cant find it on my computer or figure out how to use it. The only thing I see that downloaded is Adobe Download Assistant. How can I access the program?
Assistanttolindsey the Adobe Download Assistant will download the installation files for Adobe Acrobat Professional XI. By default they are saved to your download folder. You can begin the installation process from there.
-
How to analyse the performance by using RSRTand byseeing the query results
Hi,
I want to see the performance of the query in each land scape. I have executed my query
using the transaction RSRT. Ho w can we analyse the query reuires aggregats or not.
I have taken the no. of records in cube . I also saw the number of records in the aggregates.
I didnot get the clear picture.
I selected the options Aggregates , Statistics and donot use cache. Query got execute and it displays one report . But I am unable to analyse the performace.
Can anyone please guide me with steps . Which factors we need to consider for the performace point of view.
Points will be rewarded.
Thanks in advacne for all your help.
VamsiHi,
This info may be helpful.
General tips
Using aggregates and compression.
Using less and complex cell definitions if possible.
By using T-codes ST03 or ST03N
Go to transaction ST03 > switch to expert mode > from left side menu > and there in system load history and distribution for a particual day > check query execution time.
Using cache memoery will decrease the loading time of the report.
Run reporting agent at night and sending results to email.This will ensure use of OLAP cache. So later report execution will retrieve the result faster from the OLAP cache.
Also try
1. Use different parameters in ST03 to see the two important parameters aggregation ratio and records transferred to F/E to DB selected.
2. Use the program SAP_INFOCUBE_DESIGNS to see the aggregation ratio for the cube. If the cube does not appear in the list of this report, try to run RSRV checks on the cube and aggregates.
3. --- sign is the valuation of the aggregate. You can say -3 is the valuation of the aggregate design and usage. ++ means that its compression is good and access is also more (in effect, performance is good). If you check its compression ratio, it must be good. -- means the compression ratio is not so good and access is also not so good (performance is not so good).The more is the positives...more is useful the aggregate and more it satisfies the number of queries. The greater the number of minus signs, the worse the evaluation of the aggregate. The larger the number of plus signs, the better the evaluation of the aggregate.
if "-----" then it means it just an overhead. Aggregate can potentially be deleted and "+++++" means Aggregate is potentially very useful.
Refer.
http://help.sap.com/saphelp_nw70/helpdata/en/b8/23813b310c4a0ee10000000a114084/content.htm
4. Run your query in RSRT and run the query in the debug mode. Select "Display Aggregates Found" and "Do not use cache" in the debug mode. This will tell you if it hit any aggregates while running. If it does not show any aggregates, you might want to redesign your aggregates for the query.
Also your query performance can depend upon criteria and since you have given selection only on one infoprovider...just check if you are selecting huge amount of data in the report
5. In BI 7 statistics need to be activated for ST03 and BI admin cockpit to work. By implementing BW Statistics Business Content - you need to install, feed data and through ready made reports which for analysis.
http://help.sap.com/saphelp_nw70/helpdata/en/26/4bc0417951d117e10000000a155106/frameset.htm
/people/vikash.agrawal/blog/2006/04/17/query-performance-150-is-aggregates-the-way-out-for-me
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1955ba90-0201-0010-d3aa-8b2a4ef6bbb2
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ce7fb368-0601-0010-64ba-fadc985a1f94
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4c0ab590-0201-0010-bd9a-8332d8b4f09c
Performance of BW infocubes
Go to SE38
Run the program SAP_INFOCUBE_DESIGNS
It will shown dimension Vs Fact tables Size in percent If you mean speed of queries on a cube as performance metric of cube,measure query runtime.
You can go to T-Code DB20 which gives you all the performance related information like
Partitions
Databases
Schemas
Buffer Pools
Tablespaces etc
Thanks,
JituK
Maybe you are looking for
-
I have just recently purchased the new iPhone 4s and it is great. I am now using Siri a lot,however I don't like the fact that in the UK only the man's voice is available. I think we should have a choice of a Lady / a man assistant and not just a man
-
RAW images in Lightroom aren't opening in camera raw in Photoshop. Instead, I have to open the image in Finder before it will open in Camera Raw in Photoshop. How can I correct that?
-
Обновился до 7.0.1 . После закрытия Firefox, если хочешь открыть его снова выводится сообщение, что Firefox уже запущен. Приходится завершать процесс через Task Manager. Что делать?
-
Time Capsule in a Dual Band Network using Airport Extreme (N) and (2) AE
I need help and step by step directions to configure my TC in a Dual Band Network. Currently, I have my TC set up in a Create Network mode using 5Mhz and my AE (n) set up to establish a WDS and my AE (2) set up as WDS. Everything works but my AE cons
-
Unexplained Blue Dot in Calendar
Hello, I've been trying to figure out an unexplained blue dot on my calendar; it appears on a day in the month view when there are no events listed for that day. I've read through the forums and can see that people have encountered some issues when s