Contains vs Instr vs as
Hello
Just to understand the function CONTAINS oracle, I created the table below:
create table empmst ( eid number, ename varchar2(50), constraint pk_empmst primary key (eid) ) insert into empmst values (1,'RAVINDRA'); insert into empmst values (2,'JHON') insert into empmst values (3,'PETER') insert into empmst values (4,'JHON PETER') insert into empmst values (5,'JAMES') insert into empmst values (6,'JHONY')
If I run
select * from empmst where CONTAINS(ename, 'JAMES', 1) > 0;
Get the error
ORA-20000: Oracle text error:
DRG-10599: the column is not indexed
so I created index
CREATE INDEX IDX_ENAME ON EMPMST(ENAME) LOGGING NOPARALLEL;
Then also get the same error.
and what is the difference between the statements below:
select * from empmst where ename like 'JAMES'; select * from empmst where instr(ename ,'JAMES',1)>0; select * from empmst where CONTAINS(ename, 'JAMES', 1) > 0;
BANNER Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod 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
Thank you
Knockaert
CONTAINS is not a classic SQL function. It is part of the text of the Oracle. And his search for the index is not ordinary index, its oracle text index.
https://docs.Oracle.com/database/121/ccApp/TOC.htm
Tags: Database
Similar Questions
-
HELP: instr() error - invalid identifier
Hello
Query is attack on this line:
instr(hntl.note_text, "Critical and/or Actionable") != 0
Error:
ORA-00904: "criticism and/or action": invalid identifier
00904, 00000 - '% s: invalid identifier '.
note_text column is of type varchar (2000)
How can I make this work?
Hello
In Oracle SQL, string literals are enclosed in single quotes, not double - quote. You probably want to
... instr (hntl.note_text, "Criticism and/or Actionable")! = 0
Note that SQL differs from SQL * more in this regard. In SQL * Plus, - single and double quotes are often used interchangeably. In SQL, they always have a different meaning.
In Oracle SQL, quotation marks are used in identifiers (such as table names or column) which are not conform to the normal rules of naming. For example, the column names cannot usually contain special characters such as spaces or slashes (' / '). If you really want to have a column that is named
Criticism or action
you will then need to with the spaces and the bar slash, surround it with quotation marks. That's exactly what the system thought you were doing: he thought you were trying to refer to a column called 'Critical and/or usable' and, when he couldn't find a column with this name, it gave you an error indicating that the column name was not fair.
-
Need help with Substr and Instr
I have a request
Select msg
from table_a
She returned as log messages below
Continued in logid = > 241153 < for oid = > 1621 <, GoC = > 795, bday = > 01.04.2013 <
If the message contains logid = > then I want to display
Continued in logid = > 241151 <
for example
case
When the msg like ' % logid = > %'
then
I tried the combinations of substr and instr, but cannot make it work
Any help appreciated
Gus
SQL >-samples:
SQL > with t as
2 (choose "continued in logid-online 241153< for="" oid="">1621<, gdc="">795, bday-online 01.04.2013")<;' str="" from="" dual="" union="">;'>
3 select "continued in pid-online 241153< for="" oid="">1621<, gdc="">795, bday-online 01.04.2013"<;' str="" from="">;'>
4)
5. Select case-sensitive
6 when instr (str, 'logid') > 0
7 then substr (str
8, instr (str, ' > ', 1, 1) + 1
9, instr(str, '<', 1,="" 1)-instr(str,="" '="">', 1, 1)-1
10 )
11 another null - or what you want / need
12 end str
13 t;
STR
------------------------------------------------------------------------
241153
2 selected lines.
',>,>,> -
ORA-01460: letter dead or unreasonable conversion requested and INSTR func
Hi all
I have the table and the data, following the output of the query is correct but when the data inside the column gen_value more than
4000 bytes.
I am facing the following error
which include the function Instr can spend just less than 4000 bytes. So how can I solve this problem.ORA-01460:unimplemented or unreasonable conversion requested
drop table a; create table a(id number(9), gen_value CLOB); insert into a values(1, 'ACD BCD AAA, AFD BCF , Egypt,BDE AAC AFC,Egypt,BCF AAE'); insert into a values(2, 'AVF BCD, BBA BBG BCEV, GACD MNF BCV'); insert into a values(3, 'AFC ABC, BBG HUH ABCE, Egypt,JHU KK MNK');
error is,declare gen_value varchar2(20000); id number(9); type bulk_collect is table of varchar2(500) index by PLS_INTEGER; v_bluk1 bulk_collect; v_bluk2 bulk_collect; v_bluk3 bulk_collect; begin select id,gen_value into id, gen_value from a where id=1; select id,v,cnt bulk collect into v_bluk1,v_bluk2,v_bluk3 from( with data as ( select id , gen_value ||',' gen_value from dual ) ,r (id, gen_value , l) as ( select id ,substr( gen_value , instr( gen_value , ',') + 1) ,substr( trim(substr( gen_value ,1, instr( gen_value , ',') - 1)) ,instr(trim(substr( gen_value ,1, instr( gen_value , ',') - 1)),' ',-1) ) from data union all select id ,substr( gen_value , instr( gen_value , ',') + 1) ,substr( trim(substr( gen_value ,1, instr( gen_value , ',') - 1)) ,instr(trim(substr( gen_value ,1, instr( gen_value , ',') - 1)),' ',-1) ) from r where length( gen_value ) > 0 ) select id, soundex(l)as l ,count(*) cnt ,trim(max(l) keep ( dense_rank last order by length(l), l desc nulls first)) v from r where l is not null group by soundex(l),id order by 1); for b in 1..v_bluk1.count loop dbms_output.put_line ('The DOC NUMBER IS '||v_bluk1(b)||v_bluk2(b)||v_bluk3(b)); end loop; end;
Which column includes more than 4000 bytes.ORA-01460:unimplemented or unreasonable conversion requested
concerning
Benjamin
Published by: 973907 on April 14, 2013 04:21
Published by: 973907 on April 14, 2013 06:13Solomon Yakobson says:
If you explain what your code is trying to accomplish, someone might offer an alternative solution.The column GEN_VALUE in table A is a CLOB containing the list separated by commas. Your code divides this list separated by commas into indivitual elements. If none of the elements of comma-separated string exceeds 4000 bytes, what you need is to change GEN_VALUE variable PL/SQL CLOB type and then cast individual items to VARCHAR2:
declare gen_value CLOB; id number(9); type bulk_collect is table of varchar2(500) index by PLS_INTEGER; v_bluk1 bulk_collect; v_bluk2 bulk_collect; v_bluk3 bulk_collect; begin select id,gen_value into id, gen_value from a where id=1; select id,v,cnt bulk collect into v_bluk1,v_bluk2,v_bluk3 from( with data as ( select id , gen_value ||',' gen_value from dual ) ,r (id, gen_value , l) as ( select id ,substr( gen_value , instr( gen_value , ',') + 1) ,substr( trim(substr( gen_value ,1, instr( gen_value , ',') - 1)) ,instr(trim(substr( gen_value ,1, instr( gen_value , ',') - 1)),' ',-1) ) from data union all select id ,substr( gen_value , instr( gen_value , ',') + 1) ,substr( trim(substr( gen_value ,1, instr( gen_value , ',') - 1)) ,instr(trim(substr( gen_value ,1, instr( gen_value , ',') - 1)),' ',-1) ) from r where length( gen_value ) > 0 ) select id, soundex(cast(l as VARCHAR2(4000))) as l ,count(*) cnt ,trim(max(cast(l as VARCHAR2(4000))) keep ( dense_rank last order by length(cast(l as VARCHAR2(4000))), cast(l as VARCHAR2(4000)) desc nulls first)) v from r where l is not null group by soundex(cast(l as VARCHAR2(4000))),id order by 1); for b in 1..v_bluk1.count loop dbms_output.put_line ('The DOC NUMBER IS '||v_bluk1(b)||v_bluk2(b)||v_bluk3(b)); end loop; end; / The DOC NUMBER IS 1AAA512 The DOC NUMBER IS 1AFC256 The DOC NUMBER IS 1BCF256 The DOC NUMBER IS 1Egypt512 PL/SQL procedure successfully completed. SQL>
SY.
-
LONG - instr and grid... Select
Hello
Two queries:
(a) how to search for a character/combination of characters in a column
(b) how to perform a backup of a table that contains a LONG column (may contain other types of data such as the number, etc. varchar columns.)
I tried to use INSTR and CREATE (INSERT)... SELECT the options, but both failed with errors.
SQL> CREATE TABLE T1(C1 LONG); Table created SQL> INSERT INTO T1 VALUES (';Z00:101CGEZZP1904300M5'); 1 row inserted SQL> SELECT INSTR(C1,'ZP') FROM T1; SELECT INSTR(C1,'ZP') FROM T1 ORA-00932: inconsistent datatypes: expected NUMBER got LONG SQL> CREATE TABLE T2 AS SELECT * FROM T1; CREATE TABLE T2 AS SELECT * FROM T1 ORA-00997: illegal use of LONG datatype SQL>
Hello
LONG is an old format with a lot of limitations that will make your life miserable. If you need to copy your table to another, take this opportunity to convert long on the CLOB type using the to_lob() function.
create table t1(id long); create table t2 (id clob); insert into t2 (id) select to_lob(id) from t1;
Best regards
Nikolai -
Is this possible with "INSTR."
Hello
I have a table that contains the details of the book with the Structure of the Table and sample data as:
The balance amount is always calculated on 31 March of the year, so there may be a number of "balance on. Similarly, the advanced amount can be in addition to 1 times. I have a scenario where a) that I have to select the sum of all the 'ACCRUED_AMT' of 1 amount advanced to the last ' balance on. and (b) sum of all 'ACCRUED_AMT' last ' balance on "until the date of the day of the transaction. Kindly help me.CREATE TABLE LEDGER_TMP ( SRNO NUMBER(3), PARTICULAR VARCHAR2(300 BYTE), DEBIT NUMBER(20,2), CREDIT NUMBER(20,2), BALANCE NUMBER(20,2), MAKERID VARCHAR2(10 BYTE), MAKEDATE DATE, ACCURED_AMT NUMBER(20,2), TOTAL_DAYS NUMBER(5), ); INSERT INTO LEDGER_TMP ( SRNO, PARTICULAR, DEBIT, CREDIT, BALANCE, MAKERID, MAKEDATE, ACCRUED_AMT, TOTAL_DAYS ) VALUES ( 1, 'To Advanced on 13/07/2010', 250000, 0, 250000, 'JASMIN', TO_Date( '12/30/2010 04:10:00 PM', 'MM/DD/YYYY HH:MI:SS AM') , 3415, 50); INSERT INTO LEDGER_TMP ( SRNO, PARTICULAR, DEBIT, CREDIT, BALANCE, MAKERID, MAKEDATE, ACCRUED_AMT, TOTAL_DAYS ) VALUES ( 2, 'To Advanced on 01/09/2010', 250000, 0, 500000, 'JASMIN', TO_Date( '12/30/2010 04:10:00 PM', 'MM/DD/YYYY HH:MI:SS AM') , 12158, 89); INSERT INTO LEDGER_TMP ( SRNO, PARTICULAR, DEBIT, CREDIT, BALANCE, MAKERID, MAKEDATE, ACCRUED_AMT, TOTAL_DAYS ) VALUES ( 3, 'By Prin. Recd on 28/11/2010', 0, 5000, 495000, 'JASMIN', TO_Date( '12/30/2010 04:10:00 PM', 'MM/DD/YYYY HH:MI:SS AM') , 3111, 23); INSERT INTO LEDGER_TMP ( SRNO, PARTICULAR, DEBIT, CREDIT, BALANCE, MAKERID, MAKEDATE, ACCRUED_AMT, TOTAL_DAYS ) VALUES ( 4, 'By Prin. Recd on 21/12/2010', 0, 200000, 295000, 'JASMIN', TO_Date( '12/30/2010 04:10:00 PM', 'MM/DD/YYYY HH:MI:SS AM'), 8163, 101); INSERT INTO LEDGER_TMP ( SRNO, PARTICULAR, DEBIT, CREDIT, BALANCE, MAKERID, MAKEDATE, ACCRUED_AMT, TOTAL_DAYS ) VALUES ( 5, 'To Balance on 31/03/2011', 0, 0, 295000, 'JASMIN', TO_Date( '12/30/2011 04:10:00 PM', 'MM/DD/YYYY HH:MI:SS AM'), 26847, 263); INSERT INTO LEDGER_TMP ( SRNO, PARTICULAR, DEBIT, CREDIT, BALANCE, MAKERID, MAKEDATE, ACCRUED_AMT, TOTAL_DAYS ) VALUES ( 6, 'By Prin. Recd on 31/05/2011', 0, 200000, 95000, 'JASMIN', TO_Date( '12/30/2011 04:10:00 PM', 'MM/DD/YYYY HH:MI:SS AM'), 2595, 1); INSERT INTO LEDGER_TMP ( SRNO, PARTICULAR, DEBIT, CREDIT, BALANCE, MAKERID, MAKEDATE, ACCRUED_AMT, TOTAL_DAYS ) VALUES ( 7, 'By Prin. Recd on 01/06/2011', 0, 95000, 0, 'JASMIN', TO_Date( '12/30/2011 04:10:00 PM', 'MM/DD/YYYY HH:MI:SS AM'), 0, 0); INSERT INTO LEDGER_TMP ( SRNO, PARTICULAR, DEBIT, CREDIT, BALANCE, MAKERID, MAKEDATE, ACCRUED_AMT, TOTAL_DAYS ) VALUES ( 8, 'By Int. Recd on 01/06/2011', 0, 29442, 0, 'JASMIN', TO_Date( '12/30/2011 04:10:00 PM', 'MM/DD/YYYY HH:MI:SS AM'), 0, 0); commit;
>
(a) I have to select the sum of all the 'ACCRUED_AMT' of 1 amount advanced to the last ' balance on.
>
somethingSELECT sum(nvl(ACCRUED_amt, 0)) FROM LEDGER_TMP WHERE SRNO >= (SELECT NVL(MIN(SRNO), 0) FROM LEDGER_TMP WHERE MAKERID = 'JASMIN' AND INSTR(PARTICULAR, 'To Advanced on') > 0 ) and SRNO <= (SELECT NVL(MAX(SRNO), 0) FROM LEDGER_TMP WHERE MAKERID = 'JASMIN' AND INSTR(PARTICULAR, 'To Balance on') > 0 )
and (b) sum of all 'ACCRUED_AMT' last ' balance on "until the date of the day of the transaction.
>
somethingSELECT sum(nvl(ACCRUED_amt, 0)) FROM LEDGER_TMP WHERE SRNO >= (SELECT NVL(MAX(SRNO), 0) FROM LEDGER_TMP WHERE MAKERID = 'JASMIN' AND INSTR(PARTICULAR, 'To Balance on') > 0 ) and MAKEDATE <= sysdate
-
Explanation of the instr function
Hello
I have been helped with a query and received the following code. The code does what I wanted to do, but I don't really understand how it works. I tried Googling, but examples are different in this one and do not contain the value > 0 or | (Which I guess makes reference to a column. Could someone please explain it to me.
Banner:SET Financial_Review = ( case when instr(Debt_Review||Judgement||Liquidation||under_admin,'Y') > 0 then 'Y' else 'N' end)
Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production."
AMT for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - ProductionDebt_Review||Judgement||Liquidation||under_admin
You concatenate 4 columns. then
instr(Debt_Review||Judgement||Liquidation||under_admin,'Y')
You check if the letter there exist in the concatenated string. INSTR returns the position of the character of research. So if the position is greater than 0 that means that the search string exists.
So eventually, if it exists, you define Y n else.
-
Need help with instr/Regexp for the query
Hi people of Oracle
I use Oracle
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing options
I have a few responses from students and the valid values are + / / (alphabet) o/p and spaces at the end of the scam only not in the middle.
According to my condition, the registration number 2 3.4 must be in the request but I'm alone (chart 3).
Can we use REG_EXP
Help, please.
Thanks in advance.
Rajesh
with x as)
(
SELECT '+-+-POPPPPPP' STUDENT_RESPONSE, 1 numero_enregistrement FROM DUAL Union all the
SELECT ' + --AOPPPPPP++' STUDENT_RESPONSE, 2 numero_enregistrement FROM DUAL Union all the
SELECT "+-+-OPPPPPP -' STUDENT_RESPONSE, 3 numero_enregistrement FROM DUAL union all
SELECT '+-+-9OPPPPPP' STUDENT_RESPONSE, 4 numero_enregistrement FROM DUAL)
)
(SELECT NUMERO_ENREGISTREMENT,
TRIM (STUDENT_RESPONSE) X
WHERE
((INSTR (UPPER (TRIM (STUDENT_RESPONSE)),'-') = 0))
OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)), '+') = 0)
OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)), 'O') = 0)
OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)), 'P') = 0)
OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)),' ')! = 0)
)
)Hi, Renon,
Rb2000rb65 wrote:
Hi people of OracleI use Oracle
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing optionsThanks for posting this (and the WITH clause for sample data). It is very useful.
I have a few responses from students and the valid values are + / / (alphabet) o/p and spaces at the end of the scam only not in the middle.
You combine several qeustions responses in a single VARCHAR2 column? It would be better to have a separate line for each question.
According to my condition, the registration number 2 3.4 must be in the request but I'm alone (chart 3).
What exactly are your needs? You try to find the rows where the student_response contains one of the forbidden characters, or if it contains a space anywhere, but at the end of the string?
Can we use REG_EXP
Yes, but it's pretty easy and probably more effective, do not use regular expressions in this case:
Here's one way:SELECT record_number , student_response FROM x WHERE TRANSLATE ( UPPER ( RTRIM (student_response, ' ')) , 'X+-OP' , 'X' ) IS NOT NULL ;
In other words, once you remove the spaces and all occurrences of '+', '-', 'o' or 'P', then the forbidden characters are left, and you want to select the line, if there is one of these.
If you really, really want to use a regular expression:
SELECT record_number , student_response FROM x WHERE REGEXP_LIKE ( RTRIM (student_response) , '[^-+OP]' -- or '[^+OP-]', but not '[^+-OP]'. Discuss amongst yourselves , 'i' ) ;
but, again, it will be probably slower than the first solution, using TRANSLATE.
Published by: Frank Kulash, October 17, 2011 13:05
Published by: Frank Kulash, October 17, 2011 13:41
What follows is a bit simpler that TRANSLATE:SELECT record_number , student_response FROM x WHERE RTRIM ( UPPER ( RTRIM (student_response, ' ')) , '+-OP' ) IS NOT NULL ;
-
How to use 'LIKE' operator/substr/instr with if condition?
Hello
How to use 'LIKE' operator/substr/instr with if condition?
I can use the following function:
<? xdofx:InStr('ssStatus','Open',1) = '0'? >
which returns true or false depending on ssStatus as Open *.
But when I try to use <? If: xdofx:instr('ssStatus','Open',1) = '0'? > calculating <? end if? >
It gives an error.
Any suggestion? OR a solution?
Thank you.
Published by: user12427117 on March 10, 2011 20:42
Published by: user12427117 on March 10, 2011 20:46You can try to use
0? >
Use contains to AS
-
PL/SQL: ORA-00904: "CONTAINS": invalid identifier
create or replace
PF_SEARCH PACKAGE BODY
IS
PROCEDURE PF_QUICK_SEARCH
(
Help keyword VARCHAR2 DEFAULT NULL,
locale VARCHAR2 DEFAULT NULL,
VARCHAR2 DEFAULT NULL, catalogue
VARCHAR2 NULL by DEFAULT, price list
minCount INTEGER by DEFAULT 5,
maxCount INTEGER by DEFAULT 1000,
searchCount OUT INTEGER,
categorySet OUT cursorType,
productSet OUT cursorType
)
AS
BEGIN
SELECT count (*)
IN searchCount
OF dcs_pf_product_trans t1,.
dcs_prd_prdinfo t2,
dcs_price t3
WHERE t1.product_id = t3.product_id
AND t3.price_list = price list
AND t2.product_id = t1.product_id
AND (((CONTAINS(t1.product_id,searchWord,0) > 0
OR CONTAINS (t1.manufacturer_part_number, searchWord, 1) > 0
OR CONTAINS(t1.vendor_name,searchWord,2) > 0
OR CONTAINS(t1.display_name,searchWord,3) > 0
OR CONTAINS(t1.long_description,searchWord,4) > 0)
AND t2.catalog_id = catalog)
AND (t1.locale_id = local));
IF searchCount < = minCount THEN
OPEN for ProductSet
SELECT t1.product_id
OF dcs_pf_product_trans t1,.
dcs_prd_prdinfo t2,
dcs_price t3
WHERE t1.product_id = t3.product_id
AND t3.price_list = price list
AND t2.product_id = t1.product_id
AND (((CONTAINS(t1.product_id,searchWord,0) > 0
OR CONTAINS (t1.manufacturer_part_number, searchWord, 1) > 0
OR CONTAINS(t1.vendor_name,searchWord,2) > 0
OR CONTAINS(t1.display_name,searchWord,3) > 0
OR CONTAINS(t1.long_description,searchWord,4) > 0)
AND t2.catalog_id = catalog)
AND (t1.locale_id = local));
ON THE OTHER
IF searchCount > maxCount THEN
OPEN for CategorySet
SELECT DISTINCT t3.cat_lvl1_id, t3.cat_lvl2_id, t3.cat_lvl3_id
OF dcs_pf_product_trans t1,.
dcs_prd_prdinfo t2,
dcs_pf_search_cat t3,
dcs_price t4
WHERE t1.product_id = t4.product_id
AND t4.price_list = price list
AND t2.product_id = t1.product_id
AND (((CONTAINS(t1.product_id,searchWord,0) > 0
OR CONTAINS (t1.manufacturer_part_number, searchWord, 1) > 0
OR CONTAINS(t1.vendor_name,searchWord,2) > 0
OR CONTAINS(t1.display_name,searchWord,3) > 0
OR CONTAINS(t1.long_description,searchWord,4) > 0)
AND t2.catalog_id = catalog)
AND (t1.locale_id = local))
AND t2.product_info_id = t3.product_info_id
ORDER BY t3.cat_lvl1_id, t3.cat_lvl2_id, t3.cat_lvl3_id;
ON THE OTHER
OPEN for CategorySet
SELECT DISTINCT t3.cat_lvl1_id, t3.cat_lvl2_id, t3.cat_lvl3_id
OF dcs_pf_product_trans t1,.
dcs_prd_prdinfo t2,
dcs_pf_search_cat t3,
dcs_price t4
WHERE t1.product_id = t4.product_id
AND t4.price_list = price list
AND t2.product_id = t1.product_id
AND (((CONTAINS(t1.product_id,searchWord,0) > 0
OR CONTAINS (t1.manufacturer_part_number, searchWord, 1) > 0
OR CONTAINS(t1.vendor_name,searchWord,2) > 0
OR CONTAINS(t1.display_name,searchWord,3) > 0
OR CONTAINS(t1.long_description,searchWord,4) > 0)
AND t2.catalog_id = catalog)
AND (t1.locale_id = local))
AND t2.product_info_id = t3.product_info_id
ORDER BY t3.cat_lvl1_id, t3.cat_lvl2_id, t3.cat_lvl3_id;
OPEN for ProductSet
SELECT t1.product_id
OF dcs_pf_product_trans t1,.
dcs_prd_prdinfo t2,
dcs_price t3
WHERE t1.product_id = t3.product_id
AND t3.price_list = price list
AND t2.product_id = t1.product_id
AND (((CONTAINS(t1.product_id,searchWord,0) > 0
OR CONTAINS (t1.manufacturer_part_number, searchWord, 1) > 0
OR CONTAINS(t1.vendor_name,searchWord,2) > 0
OR CONTAINS(t1.display_name,searchWord,3) > 0
OR CONTAINS(t1.long_description,searchWord,4) > 0)
AND t2.catalog_id = catalog)
AND (t1.locale_id = local));
END IF;
END IF;
END PF_QUICK_SEARCH;
PROCEDURE PF_CATEGORY_SEARCH
(
Help keyword VARCHAR2 DEFAULT NULL,
locale VARCHAR2 DEFAULT NULL,
VARCHAR2 DEFAULT NULL, catalogue
VARCHAR2 NULL by DEFAULT, price list
parentCat VARCHAR2 DEFAULT NULL,
productSet OUT cursorType
)
AS
BEGIN
OPEN for ProductSet
SELECT t4.product_id
OF dcs_pf_product_trans t1,.
dcs_prd_prdinfo t2,
dcs_price t3,
dcs_product t4
WHERE t1.product_id = t3.product_id
AND t3.price_list = price list
AND t2.product_id = t1.product_id
AND (((CONTAINS(t1.product_id,searchWord,0) > 0
OR CONTAINS (t1.manufacturer_part_number, searchWord, 1) > 0
OR CONTAINS(t1.vendor_name,searchWord,2) > 0
OR CONTAINS(t1.display_name,searchWord,3) > 0
OR CONTAINS(t1.long_description,searchWord,4) > 0)
AND t2.catalog_id = catalog)
AND (t1.locale_id = local))
AND t1.product_id = t4.product_id
AND t4.parent_cat_id = parentCat;
END PF_CATEGORY_SEARCH;
PROCEDURE PF_GENERIC_FULL_SEARCH
(
SQLQuery VARCHAR2 DEFAULT NULL,
sqlCountQuery VARCHAR2 DEFAULT NULL,
categoryQuery VARCHAR2 DEFAULT NULL,
minCount INTEGER by DEFAULT 5,
maxCount INTEGER by DEFAULT 1000,
count ON the WHOLE,
countSet OUT cursorType,
categorySet OUT cursorType,
productSet OUT cursorType
)
AS
searchCount INTEGER.
BEGIN
CountSet OPEN for sqlCountQuery;
SEEK countSet INTO searchCount;
County: = searchCount;
IF searchCount < = minCount THEN
ProductSet OPEN for sqlquery;
ON THE OTHER
IF searchCount > maxCount THEN
CategorySet OPEN for categoryQuery;
ON THE OTHER
CategorySet OPEN for categoryQuery;
ProductSet OPEN for sqlquery;
END IF;
END IF;
END PF_GENERIC_FULL_SEARCH;
PROCEDURE PF_GENERIC_PROD_SEARCH
(
SQLQuery VARCHAR2 DEFAULT NULL,
productSet OUT cursorType
)
AS
BEGIN
ProductSet OPEN for sqlquery;
END PF_GENERIC_PROD_SEARCH;
END PF_SEARCH;
----------------------------------------
Package body PFCA4. PF_SEARCH@US_DEV_WD1_PFCA4
Error (22.2): PL/SQL: statement ignored
Error (34.5): PL/SQL: ORA-00904: "CONTAINS": invalid identifier
Error (43.5): PL/SQL: statement ignored
Error (54.5): PL/SQL: ORA-00904: "CONTAINS": invalid identifier
Error (61.7): PL/SQL: statement ignored
Error (73,14): PL/SQL: ORA-00904: "CONTAINS": invalid identifier
Error (82.7): PL/SQL: statement ignored
Error (94,14): PL/SQL: ORA-00904: "CONTAINS": invalid identifier
Error (102.6): PL/SQL: statement ignored
Error (113.5): PL/SQL: ORA-00904: "CONTAINS": invalid identifier
Error (137,5): PL/SQL: statement ignored
Error (149,5): PL/SQL: ORA-00904: "CONTAINS": invalid identifier
---------------Think you that trying to do something like that?
CONTAINS(t1.manufacturer_part_number,searchWord,1) > 0
How would you do the same thing with INSTR or SIMILAR?
select * from dual where instr('Test','st') > 0; select * from dual where 'ABCXD' like '%' || dummy || '%';
-
find fields that contains a space
I'm trying to find a field that contains a space in the data. I have a user_login column where all the user id is stored. User IDs are normally "SMITHJ', 'DOEJ' etc... but I wanted to see if we got one with a space. what the script would look like this get?
Thank you
example of
user_login PK
1 SMITHJ
2 DOEJ
3 OF THE CRUZJHello
Welcome to the forumSQL> with t as 2 ( 3 select 1 pk, 'SMITHJ' user_login from dual union all 4 select 2, 'DOEJ' from dual union all 5 select 3, 'DE LA CRUZJ' from dual 6 ) 7 -- 8 select * from t 9 where instr(user_login, ' ') > 0 10 / PK USER_LOGIN ---------- ----------- 3 DE LA CRUZJ
do a google on string handling Oracle and especially Instr.
-
Problem with Textfield autocomplete-->; only use the INSTR function
Hello team dev,
I use the new "textfield autocomplete" item type APEX and you have a crazy problem with it.
I have a table with an index on the same column I want to search with AutoComplete field.
Index:
Select which is automatically generated by APEX 4:CREATE BITMAP INDEX TEST.GEO_DATA_IDX1 ON TEST.GEO_DATA (postcode) NOLOGGING TABLESPACE TS_INDEX;
The APEX 3, I used the addon of Tyler Muth with my own Select:SELECT a.* FROM ( SELECT DISTINCT postcode AS RV FROM TEST.GEO_DATA WHERE country_id = :P1_COUNTRY ORDER BY 1) a WHERE INSTR ("RV", :p$_search_string) > 0 AND ROWNUM <= :p$_max_rows; -- plan Plan SELECT STATEMENT ALL_ROWSCost: 4,308 Bytes: 45,31 Cardinality: 1,97 2 SORT UNIQUE Cost: 4,307 Bytes: 45,31 Cardinality: 1,97 1 TABLE ACCESS FULL TABLE #TABLE# Cost: 4,306 Bytes: 47,311 Cardinality: 2,057
Is there a chance to get my INDEX used by the new element of the APEX? I do not. But I still want to ask before I just rebuild. :)SELECT DISTINCT postcode AS DV, postcode AS RV FROM TEST.GEO_DATA WHERE country_id = L_COUNTRY AND postcode like l_search||'%' ORDER BY 1 -- Plan SELECT STATEMENT ALL_ROWSCost: 840 Bytes: 152,867 Cardinality: 13,897 8 SORT ORDER BY Cost: 840 Bytes: 152,867 Cardinality: 13,897 7 HASH UNIQUE Cost: 838 Bytes: 152,867 Cardinality: 13,897 6 VIEW VIEW index$_join$_001 Cost: 836 Bytes: 232,111 Cardinality: 21,101 5 HASH JOIN 2 BITMAP CONVERSION TO ROWIDS Cost: 31 Bytes: 232,111 Cardinality: 21,101 1 BITMAP INDEX RANGE SCAN INDEX (BITMAP) #INDEX# 4 BITMAP CONVERSION TO ROWIDS Cost: 45 Bytes: 232,111 Cardinality: 21,101 3 BITMAP INDEX SINGLE VALUE INDEX (BITMAP) #INDEX#
Best regards
TobiasHi Tobias,.
I guess that you are currently using "contains and case sensitivity ' to the attribute of"search ". Have you ever tried out "Exact and case sensitivity? Because that internally uses the LIKE operator as does your original query and the % is at the end, she must allow the use of an index. But it might still work, because ORDER BY can be run at a different time in your original example, but it's worth a try.
Concerning
Patrick
-----------
My Blog: http://www.inside-oracle-apex.com
APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
Twitter: http://www.twitter.com/patrickwolf -
I have created table:
create table wekaRules_productmgr)
The rule ID number,
WekaRule varchar2 (500),
VARCHAR2 (250) antecedent.
VARCHAR2 (250) resulting.
);
The table contains the following data with insert statements:
INSERT INTO wekaRules_productmgr (ID rule, WekaRule)
VALUES (1, ' PM_PRICE_REDUCTION_TYPE = None 9828 == > PM_COUPON_TYPE = None 9828 conf: (1) lift: (1.06) conv: (576.86)') lev: (0.05) [576];
INSERT INTO wekaRules_productmgr (ID rule, WekaRule)
VALUES (2, ' PM_AD_TYPE = None 9684 == > PM_PRICE_REDUCTION_TYPE = None 9684 conf: (1) lift: (1.12) conv: (1063.13)') lev: (0.1) [1063];
INSERT INTO wekaRules_productmgr (ID rule, WekaRule)
VALUES (3, ' PM_AD_TYPE = None 9684 == > PM_COUPON_TYPE = None 9684 conf: (1) lift: (1.06) conv: (568.41)') lev: (0.05) [568];
The values for the last two columns in the wekaRules_productmgr table is contained in the string values for each statement. For example, in the # 1 folder, the values are (from left to right):
history = PM_PRICE_REDUCTION_TYPE = None
result = PM_COUPON_TYPE = None
I need to find a way to analyze the values in each record and update in the appropriate table columns. So to case # 1, I need to update columns with the values given above, such as the records would look like:
Rule ID History Resulting
1 PM_PRICE_REDUCTION_TYPE = None PM_COUPON_TYPE = None
2 PM_AD_TYPE = None PM_PRICE_REDUCTION_TYPE = None
3 PM_AD_TYPE = None PM_COUPON_TYPE = None
I have tried this solution, but cannot very well:
UPDATE wekaRules_productmgr SET history =
(SELECT SUBSTR (wekarule, 1, (INSTR(wekarule,' ',1,1)-1)) 'history')
OF wekaRules_productmgr);
I also have a similar one for the suite. Does anyone have any suggestions? Any help is appreciated. Thank you!I saw there is anonther detachment of you the same theme. If this can help you:
SELECT regexp_substr(wekarule,'[a-zA-Z_]+ *= *[a-zA-Z_]+',1,1) antecedent, regexp_substr(wekarule,'[a-zA-Z_]+ *= *[a-zA-Z_]+',1,2) consequent, LTRIM(REGEXP_SUBSTR(wekarule, 'conf:\([^\)]+'), 'conf:(') conf, LTRIM(REGEXP_SUBSTR(wekarule, 'lift:\([^\)]+'), 'lift:(') lift, LTRIM(REGEXP_SUBSTR(wekarule, 'lev:\([^\)]+'), 'lev:(') lev, LTRIM(REGEXP_SUBSTR(wekarule, 'conv:\([^\)]+'), 'conv:(') conv FROM wekaRules_productmgr;
Published by: hm on 11.10.2010 11:29
-
Use instr to search for multiple values
Hello
My version of Oracle DB is 10.2.0
I have a file of text separated by delimiters. The text file has 14 columns, and in each column, I have to check the presence of the following
RV, RV, RV, GV, GV, GV.
The sample file contains the following
51151111; 28.18.11; 14711119; 512-GV; 821949,39; 1223,21; 471,49; 821197,29; ABC; 1; 27.18.11; 13
The following code is for the search for GV
How can I search for other cases?FUNCTION FUNC_FIND_GV (p_str IN VARCHAR2) RETURN NUMBER AS l_gv_pos NUMBER ; begin l_gv_pos := INSTR(p_str, 'GV') ; RETURN l_gv_pos ; EXCEPTION WHEN OTHERS THEN l_gv_pos := 0; RETURN l_gv_pos END FUNC_FIND_GV ;
Hello
You can use regular expresssions to find one a |-at the same time delimited list.
For example:SELECT REGEXP_INSTR ( p_str , '(RV|RV-|RV/|GV|GV-|GV/)' ) AS match_pos FROM ... ;
It is unnecessary to search for one of the 'RV', 'RV' - and ' RV /'; hot for just 'RV' will give the same results. However, it does no harm real, so if you build the list ' RV | RV | RV / | GV | GV | GV /' dynamically, so you don't have to check for duplicates.
I hope that answers your question.
If this isn't the case, post CREATE TABLE and INSERT statements for some examples of data and the results desired from these data. -
Discoverer INSTR function does not have a hyphen in the ID Oppty
I need to identify the IDS that have a number that produces a hyphen. INSTR (opportunity ID,'-', 1, 1) calculation identifies the location of the hyphen for most of ID. However, it does not recognize the hyphen in some. Identifiers that have hyphens that are not recognized, I know that the hyphen is counted as a character because Discover include the hyphen when I use a calculation of LENGTH on the field service ID.
Example:
INSTR (field ID,'-', 1, 1) calculation for ID 3 - XXXXX1 = 2; but for ID 3 - XXXXX2 = 0.
Calculations of LENGTH (ID field) for the two ID = 8.
Anyone who has ever encountered this problem and found a resolution?
Any help would be greatly appreciated... Thank you!
Published by: user740605 on Sep 8, 2010 13:43
Published by: user740605 on Sep 8, 2010 13:45
Published by: user740605 on Sep 8, 2010 13:47
Published by: user740605 on Sep 8, 2010 13:47Hello
I suspect that the character is not hyphenated, but hyphenated "windows". If the text was cut and paste from a windows like word or excel application, then it will probably contain the hyphen of windows which is a different character.
You can use the lengthB function to check if there are 2-byte characters or use the dump function to watch the ascii characters in the field.
Rod West
Maybe you are looking for
-
Portege Z10 stucks on blue screen - cannot open a session
My system has issues where I couldn't get in the restoration of the system as it was not appearingso went to msconfig and I went to start advanced and chose to go into diagnostic mode and restart it now has just a blue screen. I can move the mouse an
-
k. I downloaded the application. I recorded a few songs. Maybe 8 or 9. I closed out of the app by habit when I switch to a different application. Just reopened the music memos app and all my "ideas" have disappeared. I just recorded a new test t out
-
Measurement of high frequency with the NI 9411
Hello I would like to measure the frequency of a TTL signal with the 9411 OR in a cDAQ-9178 chassis. 1.6 at 48 kHz frequency range. With examples of Labview digital frequency meter, it is not picking up on the signal. Any advice? Anna
-
OfficeJet pro 8620: scanning and capture app scan document
I run HP Scan and Capture. If I scan a document and do not save it, the app does not allow me to analyse other documents of the IOA, but I can scan photos or from another machine - I can also use the buttons on the IOA to scan to my computer, but the
-
Ello - first of all, let me ask if there is a fee involved to belong to the community of Dell? Then, as a loyal Dell customer, I recently got a wireless Dell Inspiron One computer. My question is: can be used as a printer "connected" with this comput