Text Query Syntax
I am brand new to Oracle Text. I am trying to
do a where clause with CONTAINS with a pattern
I want found ANDed to a pattern I want excluded
(using NOT) from the results that the condition
before the AND would return on its own.
Example:
select distinct m.id, m.time_period, m.retention
from l load_periods, m messages
where m.load_period_id = l.load_period_id
and
CONTAINS(x.xml_imt, 'Model% inpath(//description)
AND % NOT Model2 inpath(//description)', 1)>= 1;
The above example gives me errors when I run it in
SQLPlus. Getting this to run successfully in SQLPlus
is just the first, but necessary step for my task.
I don't see any example in the Oracle Text documents
that I have available to me that suggest a solution
to me, and I have experimented with variations that
I dreamed up myself without success either. Anyone
know how to write this CONTAINS clause?
TIA,
Greg
Oy! Typo! My Bad! Here is how my original post
should have read, now with text of error message
included:
I am brand new to Oracle Text. I am trying to
do a where clause with CONTAINS with a pattern
I want found ANDed to a pattern I want excluded
(using NOT) from the results that the condition
before the AND would return on its own.
Example:
select distinct m.id, m.time_period, m.retention
from l load_periods, m messages
where m.load_period_id = l.load_period_id
and
CONTAINS(m.xml_imt, 'Model% inpath(//description)
AND % NOT Model2 inpath(//description)', 1)>= 1;
The above example gives me errors when I run it in
SQLPlus, specifically "invalid relational operator". Getting this to run successfully in SQLPlus is just the first, but necessary step for my task.
I don't see any example in the Oracle Text documents
that I have available to me that suggest a solution
to me, and I have experimented with variations that
I dreamed up myself without success either. Anyone
know how to write this CONTAINS clause?
TIA,
Greg
Similar Messages
-
DRG-50901: text query parser syntax error
The query
SELECT * FROM ij
where
CONTAINS (ij.summary, 'ATTENZIONE!') > 0 returns an error:
ORA-29902: error in executing ODCIIndexStart() routine
ORA-20000: Oracle Text error:
DRG-50901: text query parser syntax error on line 1, column 13
Why?
There is a TEXT index on the summary column:
CREATE INDEX IJL_SUMMARY_IX ON IJ
(SUMMARY)
INDEXTYPE IS CTXSYS.CONTEXT
PARAMETERS('
lexer MITO_LEXER
wordlist DEFAULT_WORDLIST
stoplist IJL_STOPLIST
storage IJL_TEXT_STORAGE
SYNC (EVERY "SYSDATE + 10/1440")')
PARALLEL ( DEGREE 4 INSTANCES 1 );where the MITO_LEXER is
BEGIN
CTX_DDL.create_preference ('mito_lexer', 'BASIC_LEXER');
CTX_DDL.set_attribute ('mito_lexer', 'INDEX_STEMS', 'ITALIAN');
-- MITO-318: search on Text Index for Asterisks
CTX_DDL.set_attribute ('mito_lexer', 'printjoins', '*');
END;
/Because the exclamation mark ("!") is a reserved operator, meaning soundex, and must appear before the word it applies to.
-
Oracle Text query parser - sample code
I've posted a new entry on my "searchtech" blog which includes code for a "Google-like" query syntax parser:
https://blogs.oracle.com/searchtech/entry/oracle_text_query_parser
Currently it's just sample code, but if it goes down well we might include it, or something similar, in a future release of the product.
I'd very much welcome feedback on it, either here on the forum, or on the blog, or directly to me email address (which is included in the download file).
Thanks, everyone.When I select the "open in browser" option for each now, I get formatted, readable code, which can easily be copied and pasted into a file without the extra txt extension, and I much prefer that. So, for me, that is a sufficient fix.
It seems like this is handy, virtually idiot-proof code, easy to create the package, easy to use it, and provides the Google-like search that users expect, without raising errors or producing unexpected results. Frequently, on the OraFAQ forums, where I am a moderator, when there are various ways to solve a problem and I provide a Text solution, the complaint is that it is too complicated to create all of the formatting to fix potential problems with user input. Your code solves that problem and I hope it will be included in the next version. If you don't mind, I will post an announcement in the OraFAQ Text forum with the permanent link that you provided. -
Checking text query validity without actually running the query: ideas?
Hi,
I would like to implement a sort of function that does a preliminary check on the validity of the search string and ideally this function should work with both CTXCAT and CONTEXT indexes (and grammars).
Initially I thought that CTXQUERY.EXPLAIN function could do this for me, but, unless I am missing something, it only works with CONTEXT indexes and it doesn't accept a string containing a text query rewrite using CTXCAT grammar (it throws DRG-11119: operation is not supported by this index type).
Plan B would be to create an empty table with a CONTEXT index and then run the query either with the CONTEXT grammar or the CTXCAT grammar via query rewrite and if the query runs, returning no rows, presumably fast enough for this purpose, then the query string is assumed to be valid.
What I don't like much about plan B is the need for an additional table plus the "dummy" context indexes just to perform the parsing of the text query, but so far I didn't come up with more brilliant ideas.
Any thoughts?
Am I missing something that does the magic without hassle?
Thanks
FlavioUnder normal circumstances I wouldn't do this, as you say I'd just run the query and catch the error, but I need to do this inside a report refresh performed via AJAX (using Oracle Apex) and the catch is that when such refresh fails owing to a syntax error, the partial refresh mechanism of APEX becomes broken, so even if you amend the query and submit a new valid string, it won't show up any more.
That's why I need to be sure that the string is valid before running the query, hence the syntax checking function.
The google-style parser sounds interesting, may be I can try to implement it in a future release of my app!
Thanks
Flavio -
Ora-01704 string literal too long error on long query syntax
I have a query with more than 4000 characters. I can't seem to get ociparse to accept it. The bind variables are not an issue as I am not concatenating any strings to the query syntax. It is just that my query will all the columns and unions etc exceeds 4000 characters. Any way around this short of hiding it in a view ( which I have already done for other long queries ).
System:
PHP 4.3.10
OCI driver
Oracle 9i Release 2
Thanks,
BryanMisread your post, sorry. Oracle limits literal strings to 4,000 chars. According to the documentation it's required that you use bind variables where possible to shorten literal strings below 4,000. You could also try a pl/sql block.
The error you're getting is being returned by Oracle, not PHP. I've seen it pop up on bugtraq a couple of times for PHP, but the answer is always the same. I'm more of a programmer than a database expert, so forgive me for not having a better answer. You may want to try posting this to one of the more specific oracle forums where someone will probably have a better answer for you.
http://www.stanford.edu/dept/itss/docs/oracle/9i/server.920/a96525/toc.htm -
XPATH Database Query Syntax in an Assign
Trying to get an XPATH Database query to work by assigning the Input variable value in a simple BPEL Process to my query condition. I keep getting invalid XPATH errors. I cannot seem to figure out how get write it out.
Here is what I have:
<from expression="orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')"/>
Here is my error:
Error(30): [Error ORABPEL-10039]: invalid xpath expression [Description]: in line 30 of "C:\OraBPELPM_1\integration\jdev\jdev\mywork\BPELws\ReadDB\ReadDB.bpel", xpath expression "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" specified in <from> is not valid, because XPath query syntax error. Syntax error while parsing xpath expression "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')", at position "80" the exception is Expected: ). Please verify the xpath query "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" which is defined in BPEL process. . [Potential fix]: Please make sure the expression is valid.
Any help?
Thanks!!!Ok. I have figured out how to place the condition (variable value) inside a concatentated string. So my final result is the actual XPATH Query-Database statement. But the problem is it is being returned as a String. How can I turn that final string into the XPATH expression I need? I suspect another <COPY> block could pull this off but I am not sure how to do it.
Here is my code:
<process name="QueryBuild" targetNamespace="http://xmlns.oracle.com/QueryBuild" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:ns1="http://www.w3.org/2001/XMLSchema" xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:client="http://xmlns.oracle.com/QueryBuild" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
<partnerLinks>
<partnerLink name="client" partnerLinkType="client:QueryBuild" myRole="QueryBuildProvider"/>
</partnerLinks>
<variables>
<variable name="inputVariable" messageType="client:QueryBuildRequestMessage"/>
<variable name="outputVariable" messageType="client:QueryBuildResponseMessage"/>
<variable name="QueryText" type="ns1:string"/>
</variables>
<sequence name="main">
<receive name="receiveInput" partnerLink="client" portType="client:QueryBuild" operation="process" variable="inputVariable" createInstance="yes"/><!-- Generate reply to synchronous request -->
<assign name="Assign_1">
<copy>
<from expression="concat("orcl:query-database('select ename from emp where empno = ", bpws:getVariableData('inputVariable','payload','/client:QueryBuildProcessRequest/client:input'), ",false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL)'")"/>
<to variable="QueryText"/>
</copy>
<copy>
<from variable="QueryText"/>
<to variable="outputVariable" part="payload" query="/client:QueryBuildProcessResponse/client:result"/>
</copy>
</assign>
<reply name="replyOutput" partnerLink="client" portType="client:QueryBuild" operation="process" variable="outputVariable"/>
</sequence>
</process> -
Oracle Text query: Escaping characters and specifying progression sequences
How can I combine the escaping of a search string and the specification of progression sequences within an oracle text query
so that in all cases the correct results are delivered (see example below)?
The scenario in which to use this is the following:
+ Database: Oracle Database 10g Enterprise Edition Release 10.2.0.2.0
+ Requirement: Hitlist of results ordered by score whereby the different part within
the result list are specified using progression sequences within oracle text query
Example:
create table service_provider (
id number,
name_c varchar(100),
uri_c varchar(255)
insert into service_provider values (1,'ABB Company Mgmt','http://www.abb-company-mgmt.de');
insert into service_provider values (2,'Dr. Abbas Ming','http://www.dr-abbas-ming.de');
insert into service_provider values (3,'SABBATA United','http://www.sabbata-united.de');
insert into service_provider values (4,'ABB','http://www.abb.de');
insert into service_provider values (5,'AND Company Mgmt','http://www.and-company-mgmt.de');
insert into service_provider values (6,'Dr. Andas Ming','http://www.dr-andas-ming.de');
insert into service_provider values (7,'SANDATA United','http://www.sandata-united.de');
insert into service_provider values (8,'AND','http://www.and.de');
Query 1: works correctly in this case
select * from (
select /*+ FIRST_ROWS */ score(1), this_.*
from service_provider this_
where
CONTAINS ( this_.NAME_C , '<QUERY><textquery grammar="CONTEXT">' ||
'<progression>' ||
'<seq>abb</seq>' ||
'<seq>abb%</seq>' ||
'<seq>%abb%</seq>' ||
'<seq>fuzzy(abb,1,100,WEIGHT)</seq>' ||
'</progression></textquery></QUERY>', 1 ) > 0
order by score(1) desc, this_.NAME_C
) where rownum < 21
delivers
76 4 ABB http://www.abb.de
76 1 ABB Company Mgmt http://www.abb-company-mgmt.de
51 2 Dr. Abbas Ming http://www.dr-abbas-ming.de
26 3 SABBATA United http://www.sabbata-united.de
Query 2: procudes error
select * from (
select /*+ FIRST_ROWS */ score(1), this_.*
from service_provider this_
where
CONTAINS ( this_.NAME_C , '<QUERY><textquery grammar="CONTEXT">' ||
'<progression>' ||
'<seq>and</seq>' ||
'<seq>and%</seq>' ||
'<seq>%and%</seq>' ||
'<seq>fuzzy(and,1,100,WEIGHT)</seq>' ||
'</progression></textquery></QUERY>', 1 ) > 0
order by score(1) desc, this_.NAME_C
) where rownum < 21
produces ORA-29902, ORA-20000, DRG-50901 because AND is a reserved word in oracle text
So we need escaping ...
Query 3: does not work correctly
select * from (
select /*+ FIRST_ROWS */ score(1), this_.*
from service_provider this_
where
CONTAINS ( this_.NAME_C , '<QUERY><textquery grammar="CONTEXT">' ||
'<progression>' ||
'<seq>{abb}</seq>' ||
'<seq>{abb%}</seq>' ||
'<seq>{%abb%}</seq>' ||
'<seq>fuzzy({abb},1,100,WEIGHT)</seq>' ||
'</progression></textquery></QUERY>', 1 ) > 0
order by score(1) desc, this_.NAME_C
) where rownum < 21
delivers
76 4 ABB http://www.abb.de
76 1 ABB Company Mgmt http://www.abb-company-mgmt.de
Query 4: does not produce an error, but also does not work correctly
select * from (
select /*+ FIRST_ROWS */ score(1), this_.*
from service_provider this_
where
CONTAINS ( this_.NAME_C , '<QUERY><textquery grammar="CONTEXT">' ||
'<progression>' ||
'<seq>{and}</seq>' ||
'<seq>{and%}</seq>' ||
'<seq>{%and%}</seq>' ||
'<seq>fuzzy({and},1,100,WEIGHT)</seq>' ||
'</progression></textquery></QUERY>', 1 ) > 0
order by score(1) desc, this_.NAME_C
) where rownum < 21
delivers
76 8 AND http://www.and.de
76 5 AND Company Mgmt http://www.and-company-mgmt.deAnywhere that you just use the word by itself, enclose it in {}, but anywhere that you add % on either side or both don't enclose it in {}. Please see the demonstration below.
SCOTT@10gXE> SELECT * FROM v$version
2 /
BANNER
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SCOTT@10gXE> create table service_provider
2 (id number,
3 name_c varchar(100),
4 uri_c varchar(255))
5 /
Table created.
SCOTT@10gXE> insert all
2 into service_provider values (1,'ABB Company Mgmt','http://www.abb-company-mgmt.de')
3 into service_provider values (2,'Dr. Abbas Ming','http://www.dr-abbas-ming.de')
4 into service_provider values (3,'SABBATA United','http://www.sabbata-united.de')
5 into service_provider values (4,'ABB','http://www.abb.de')
6 into service_provider values (5,'AND Company Mgmt','http://www.and-company-mgmt.de')
7 into service_provider values (6,'Dr. Andas Ming','http://www.dr-andas-ming.de')
8 into service_provider values (7,'SANDATA United','http://www.sandata-united.de')
9 into service_provider values (8,'AND','http://www.and.de')
10 into service_provider values (9,'EBB','fuzzy test')
11 into service_provider values (10,'OND','fuzzy test')
12 select * from dual
13 /
10 rows created.
SCOTT@10gXE> CREATE INDEX your_index
2 ON service_provider (name_c)
3 INDEXTYPE IS CTXSYS.CONTEXT
4 PARAMETERS ('STOPLIST CTXSYS.EMPTY_STOPLIST')
5 /
Index created.
SCOTT@10gXE> VARIABLE search_string VARCHAR2 (100)
SCOTT@10gXE> EXEC :search_string := 'abb'
PL/SQL procedure successfully completed.
SCOTT@10gXE> COLUMN name_c FORMAT A20 WORD_WRAPPED
SCOTT@10gXE> COLUMN uri_c FORMAT A40
SCOTT@10gXE> select *
2 from (select /*+ FIRST_ROWS */ score(1), this_.*
3 from service_provider this_
4 where CONTAINS
5 (this_.NAME_C ,
6 '<QUERY>
7 <textquery grammar="CONTEXT">
8 <progression>
9 <seq>{' || :search_string || '}</seq>
10 <seq>' || :search_string || '%</seq>
11 <seq>%' || :search_string || '%</seq>
12 <seq>fuzzy({' || :search_string || '},1,100,WEIGHT)</seq>
13 </progression>
14 </textquery>
15 </QUERY>', 1 ) > 0
16 order by score(1) desc, this_.NAME_C)
17 where rownum < 21
18 /
SCORE(1) ID NAME_C URI_C
76 4 ABB http://www.abb.de
76 1 ABB Company Mgmt http://www.abb-company-mgmt.de
51 2 Dr. Abbas Ming http://www.dr-abbas-ming.de
26 3 SABBATA United http://www.sabbata-united.de
4 9 EBB fuzzy test
SCOTT@10gXE> EXEC :search_string := 'and'
PL/SQL procedure successfully completed.
SCOTT@10gXE> /
SCORE(1) ID NAME_C URI_C
76 8 AND http://www.and.de
76 5 AND Company Mgmt http://www.and-company-mgmt.de
51 6 Dr. Andas Ming http://www.dr-andas-ming.de
26 7 SANDATA United http://www.sandata-united.de
5 10 OND fuzzy test
SCOTT@10gXE> -
Hi,
I have a View object with various attributes (eg, name1, name2, name3, address1, address2, address3 etc). A query/table component based on this view object works just fine. However, I wish to replace name1, name2, name3 and other attributes in the query with just 'name'. These attributes are still to be shown in the result table. This new 'name' attribute will be used in an Oracle Text query clause, instead of individual searches on each attribute.
My plan was to simply make the various name1, name2 etc attributes non-'queryable' in the View def to hide them from the query. Then I'd add a transient 'name' attribute. My hope was, that I could override the getWhereClause() in the ViewObjectImpl and simply tack on the oracle text clause to the WHERE (example below):
WHERE CONTAINS (
SOMECOLUMN,
'<query>
<textquery lang="ENGLISH" grammar="CONTEXT">TRANSIENT_ATTR_VALUE
..... Oracle Text query grammar stuff here .... </query>') > 0How do I access the transient value in the ViewObjectImpl to add the above SQL? Or am I going about this in completely the wrong way?
thanks,
Barry.Based on what I found in
http://www.oracle.com/technology/oramag/oracle/09-nov/o69frame.html?_template=/ocom/print
and
http://blogs.oracle.com/smuenchadf/examples/
136. Introducing a Checkbox to Toggle a Custom SQL Predicate on an LOV's Search Form. [11.1.1.0.0] 19-NOV-2008
I have the following implementation, which seems to work. Does anyone see any problems with this?
With regard to SQL injection, does ViewCriteriaItem sanitise the 'val' from the query, or should I do that manually here myself?
@Override
public java.lang.String getCriteriaItemClause(ViewCriteriaItem vci) {
if ("OraTextTransientAttrib".equals(vci.getAttributeDef().getName())) {
if (vci.getViewCriteria().isCriteriaForQuery()) {
String val = (String)vci.getValue();
logger.debug("Doing oracle text name search on '" + val + "'");
// simplified version of my oracle text query
return "CONTAINS ('<query>..... " + val + "....</query>') > 0 ";
} else {
// SQL predicate for no changes to the results
// spaces needed if you have several of these blocks
return " 1=1 ";
// other blocks for other similar oracle text attribs
return super.getCriteriaItemClause(vci);
} -
If I have a text query in visual studio EXEC DCC_SPP_GetPeopleByDepartment @Department
how can i declare the @Department to be varchar (8000) ?
I tried declaring it in the stored procedure, but when I deploy the report, the query fails as it's looking at the text query.Try :
EXEC DCC_SPP_GetPeopleByDepartment Convert(varchar(8000),
@Department) -
Question about WebLogic query syntax
Hello,
I am using WebLogic Server 6.0, which came as part of the WebGain
Studio SE 4.5 development kit. My question regards the Web Logic query
syntax, which I have not yet mastered.
I am trying to create a finder method that takes a single argument
of type "char" and finds all matching fields of the column "keyword" in
which the argument is the first letter of keyword. That is, if I were
only looking for fields beginning with the letter "M", I'd use:
(like keyword 'M%')
However, I'm looking for all fields beginning with the first letter
defined by the first argument. Sadly, this syntax:
(like keyword '$0%')
doesn't seem to be working. Any suggestions on the correct syntax?
If this is not the right forum for this question, could someone
suggest an appropriate newsgroup?
Thanks, Dave962466 wrote:
Hi all,
I have an issue I need help with. I have created a script for an automated partition create on a monthly basis. It creates a monthly partition containing all dates within the respective month. The script is essentially this:
ALTER TABLE SCHEMA.TABLE
ADD PARTITION &&1
VALUES LESS THAN (to_number(to_char(to_date('&&2', 'DD-MON-YY'), 'YYYYMMDD')))
TABLESPACE LARGE_DATA94 COMPRESS;
I continually get this error message "ORA-14019: partition bound element must be one of: string, datetime or interval literal, number, or MAXVALUE"
The variable &&2 is passing in character data for the first of the month (E.G. '01-SEP-12'). &&1 passes character data for the month in MONYY (AUG12) I can run this query:
select
(to_number(to_char(to_date('&&2', 'DD-MON-YY'), 'YYYYMMDD')))
from dual;
With the output of 20120801. I cannot understand why I am able to run this partition create statement by hardcoding 20120901 but passing it in as a variable I receive the error. Note that I am not having problems with the &&1 variable. If anyone has any ideas please let me know. Thanks!I don't understand why you are taking a string, converting it to a date, then converting the date BACK TO a string ... then trying to convert that string to a number.
What is the data type of the partitioning key? It appears that it is a NUMBER, but actually represents a DATE. If so, that is a fundamentally flawed design. -
Hello guys,
I rather need an advice and my experience with the Oracle forums has always been auspicious.
I am using jDeveloper 11gR2 and Oracle database 11.2.0.1. Running the following query I have a view object based on that query and a search form with results table.
SELECT
SEEKER.SEEKER_ID SEEKER_ID,
SEEKER.CV CV,
SCORE(1)
FROM
SEEKER
WHERE CONTAINS(CV, '<query>
<textquery lang="ENGLISH" grammar="context">' ||
GET_RELATED_CATEGORIES(:keyword) ||
'</textquery>
<score datatype="INTEGER"/>
</query>', 1) > 0
GET_RELATED_CATEGORIES is a function which returns concatenated strings querying some semantic data in my database. The problem is when GET_RELATED_CATEGORIES returns null the "text query parser" is throwing an exception (that is how it is supposed to act).
I am asking for any suggestions for the implementation of that functionality and will be really grateful. Shall I export the whole query in a remote procedure and maybe call it as a web service or there is any other better solution (maybe some checks).
Thank you in advance!I see two possible ways you can try.
1. cause the function in a way that no null value is returned (return an empty string '')
2. put a nvl (get..., '') around the function
Timo -
Full text query across multiple columns
In the SQL Server, when you do the full text query, you can specify multiple columns, e.g.
FREETEXT ( { column_name | [b](column_list) | * } , 'freetext_string' [ , LANGUAGE language_term ] )
CONTAINS ( { column_name | [b](column_list) | * } , '< contains_search_condition>' [ , LANGUAGE language_term ])
Where,
column_list Indicates that several columns, separated by a comma, can be specified...
* Specifies that all columns in the table registered for full-text searching should be used to search for the given contains search condition. The columns in the CONTAINS clause must come from a single table...
That makes full text query cross multiple columns very convenient. Are there any mechnisms in Oracle to do the same thing?
Thanks in advance.Thanks for your reply.
I knew that you could build full text index for the multiple columns using Oracle Text. But that does not solve my problem, which is how to build the query to search multiple columns at once. Say, I have columns firstname, lastname, address, and email in the table customers. I want to get the results that ANY column contains 'bob'. In SQL Server, I can do
select * from customers where contains(*, 'bob')
that is. But for Oracle, I have to do
select * from customers where contains('firstname', 'bob') or contains('lastname', 'bob') or contains('address', 'bob') or contains('email', 'bob')
Can you imagine if I have many columns in many tables and I have to do the query against all columns in all tables? I have to dynamically get all the columns and then build the query string.
So, any better solutions? -
How can i change the default text "Query by Example"
Studio Edition Version 11.1.1.3.0
how can i change the default text *"Query by Example"* in a Panel Collection
ThxHi thieto,
The label you are looking for is af_panelCollection.LABEL_MENUITEM_QBE*
I'm currently writing a blogpost on this issue. In short, you will have to create a skin resource bundle.
In the skin definition, refer to this bundle class.
<?xml version="1.0" encoding="ISO-8859-1"?>
<skins xmlns="http://myfaces.apache.org/trinidad/skin">
<skin>
<id>mySkin.desktop</id>
<family>MySkin</family>
<extends>blafplus-rich.desktop</extends>
<render-kit-id>org.apache.myfaces.trinidad.desktop</render-kit-id>
<style-sheet-name>skins/MySkin.css</style-sheet-name>
<bundle-name>com.blogspot.lucbors.view.bundles.MySkinBundle </bundle-name>
</skin>
</skins>In this class, adjust the label text to your needs.
package com.blogspot.lucbors.view.bundles;
import java.util.ListResourceBundle;
public class MySkinBundle extends ListResourceBundle {
public MySkinBundle() {
super();
@Override
public Object[][] getContents() {
return _CONTENTS;
static private final Object[][] _CONTENTS = {
{"af_panelCollection.LABEL_MENUITEM_QBE","the text that you want"}
}More in the blogpost
Good luck
Luc Bors
Edited by: lucbors on Jul 26, 2010 11:39 AM (blogpost finished - URL added) -
SSRS multi value parameter expansion invalidates query syntax
These results from from running a demo solution and profiling the server.
--- here is the text of the query saved in the report's design ---
select *
from test_ssl
where [who] in(case when @P1 = 'all' then [who] else @P1 end)
and [recid] in(case when @P2 = 'all' then [recid] else @P2 end)
Executing the report works when @P1 = ‘all’, @P2 = ‘all’
---------------------------------------- as executed at the server ---------------------------
(@P1 nvarchar(3),@P2 nvarchar(3))
select *
from test_ssl
where [who] in(case when @P1 = 'all' then [who] else @P1 end)
and [recid] in(case when @P2 = 'all' then [recid] else @P2 end)
Executing the report fails when @P1 = (‘kid’,’adult’) & @P2 = ‘all’
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'DataSet1'. (rsErrorExecutingCommand)
For more information about this error navigate to the report server on the local server machine, or enable remote errors
---------------------------------------- as executed at the server ---------------------------
exec sp_executesql
N'select *
from test_ssl
where [who] in(case when N''kid'',N''adult'' = ''all'' then [who] else
N''kid'',N''adult'' end)
and [recid] in(case when @P2 = ''all'' then [recid] else @P2 end)
', N'@P2 nvarchar(3)', @P2=N'all'
SSRS expanded @P1 into its values then substituted @P1 with 'kid','adult' in the query's text, then sent the text to SQL server using sp_executesql().
This substitution invalidates the SQL syntax. The report fails.
For me to implement this simple example with only 2 parameters in separate queries in the report where @P1 &/ @P2 can each separately be {= 'all', or 1 value, or more than 1 value} will take 4 separate queries.
Query1: IF @P1 = all, @P2 = all BEGIN ... query text 1 ... END
Query2: IF @P1 != all, @P2 = all BEGIN ... query text 2 ... END
Query3: IF @P1 = all, @P2 != all BEGIN ... query text 3 ... END
and
Query4: IF @P1 != all, @P2 != all BEGIN ... query text 3 ... END
Each query will have to have a unique WHERE clause.
In my actual work problem some reports take 8 parameters that will be either 'all', 1 value, or multiple values.
This means that the report will have to have 64 queries each with its own unique WHERE clause and each query wrapped with its own IF @P..... = 'all' BEGIN ... query text ... END
Who knows what to do about this issue?
Hello!Hi Stevesl,
I have tested on my local environment and the query is invalid.
As
Jan Pieter Posthuma mentioned that you can just add filter as below in the query, when you set the "Allow multiple values" in the parameter, you will got the "Select All" in the dropdown list, so there is no need to add "all"
again.
select * from test_ssl
where [who] in(@P1) and [recid] in(@P2)
You can also add filter in the dataset, details information below for your reference:
By default we can add many filters and the default logic between these filter is "And" and if you want to add some "Or" filters you can reference to the blog below:
FAQ: How do I implement OR logic or complicated logics for filters in a SSRS report?
Details information about filter in SSRS :
Add a Filter to a Dataset (Report Builder and SSRS)
Because you have a lot of parameters and you can consider add the cascading parameters:
Add Cascading Parameters to a Report (Report Builder and SSRS)
If you still have any problem, please feel free to ask.
Regards
Vicky Liu
Vicky Liu
TechNet Community Support -
Hi,
I'm trying to add a search function to a servlet.
I am able to retreive the value of cof_name with the getParameter() method. However when I try to query the database for that value (cof_name) it doesnt work. Can anyone tell me what is wrong with my sql syntax?
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import java.sql.*;
import java.util.*;
public class Search extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/aubrey?";
String driver = "com.mysql.jdbc.Driver";
String userName = "Dude1";
String password = "supersecret";
Statement st;
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url,userName,password);
System.out.println("Connected to the database");
String cof_name = request.getParameter("cof_name");
String sup_id = request.getParameter("sup_id");
String price = request.getParameter("price");
String query = "select COF_NAME from COFFEES where COF_NAME like 'cof_name'";
System.out.println("query " + query);
st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
out.print("<html><head>");
out.print("</head><body>");
out.print("<code><pre>");
out.print("<font color=green>COF_NAME\tSUP_ID ");
out.println("\t\tPRICE\tSALES\tTOTAL\n</font>");
while(rs.next()){
out.print(rs.getObject("COF_NAME").toString()+"\t");
out.print(rs.getObject("SUP_ID").toString()+"\t\t");
out.print(rs.getObject("PRICE").toString()+"\t");
out.print(rs.getObject("SALES").toString()+"\t");
out.println(rs.getObject("TOTAL").toString());
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}Regards
Aubrey.1. Don't put business logic in your servlet. A servlet should just be a dispatcher to a business logic layer that has no idea that it's running in a servlet context.
2. "Doesn't work" means nothing. You have to provide more details.
3. You're doing select COF_NAME from COFFEES where COF_NAME like 'cof_name' Note that 'cof_name' is inside your string literal, so Java will not expand that variable. You'd have to do it as "select COF_NAME from COFFEES where COF_NAME like '" + cof_name+ "'"4. But even that's not the right way. The right way is to use a PreparedStatement.
String sql = "select COF_NAME from COFFEES where COF_NAME like ?";
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, cof_name);
ResultSet rs = ps.executeQuery();
Maybe you are looking for
-
Open Docs while period end closing..
Hi All, I just need to knw that, is it necessary that while performing the period end closing all the documents (sales and purchase) need to be closed.? what if i have a no of purchase and sales orders open.
-
New-Asset Report - awesome, but can't get it to run?
Howdy - I am trying to run the awesome new-asset report that Zachary Loeber shared with the technet community. The script is here: http://gallery.technet.microsoft.com/Excel-and-HTML-Asset-0ffbf569 However I can't get it to run against 1 server or m
-
Soap response Error when processing XML CF.
Hello, I have problems with soap response and wondered if you could give some advice. Every time I send my message via soap I get the following error: com.sap.aii.af.ra.ms.api.RecoverableException: SOAP: response message contains an error XIAdapter/H
-
Archive Support Messages using SARA
It is my understanding that the CRM message has to be archived using the archiving object CRM_SERORD in Transaction SARA. Does anyone have the detailed steps to correctly archive a CRM message within this transaction?
-
Looking For Recommendation - Software/Service to Print Payroll Checks
My company is looking to replace our payroll check printing software. The vendor no longer exists and 3rd party support is troublesome. Can anyone recommend a good vendor, with or without online features? We are using Oracle 11i HRMS, and don't ha