Like conditions
I would like to convert the following Informix statements to Oracle 9i. Can anyone help me.
Informix
Select col1 from tab1 where col1 not matches "*[A-z]*];
Select col1 from tab1 where col1 not matches "*[!-/]*];
means the query will return the values only when the matches statements matches. '*' means 0 or more occurances of any character, '[A-z]' means characters from capital letter A to small letter z.
Can anyone help me in coverting this to Oracle. Is it possible to convert it to a LIKE statement
use OWA_PATTERN pacakge to do conditions involving pattern matching.
Similar Messages
-
Like condition in the where clause.
Dear All,
I have created a new form using a datablock wizard with one table.
Now i placed a text box and a button in the same form. I will be entering the value in the text box and based up the condition in the where clause of the datablock property i am restricting the values where the column name is thetext box value.
Now my problem is i need to give a string value in the text box and the datablokc has to populate based up the like condtion. I dont know the syntax how to give like condition in the where clause of the property pallet.
Please help me in this.
Thanks in advance.
Cheers,
RajuMaybe try this ...
Create a button to query the block :
In the WHEN-BUTTON-PRESSED-Trigger enter :
DECLARE
v_block_def_where VARCHAR2(255) := '1 = 1';
BEGIN
v_block_def_where := v_block_def_where || ' AND NAME_OF_YOUR_TABLE_COLUMN LIKE ''' || '%' || :NAME_OF_YOUR_BLOCK.SEARCH_ITEM || '%' || '''';
SET_BLOCK_PROPERTY('NAME_OF_YOUR_BLOCK', DEFAULT_WHERE, v_block_def_where);
GO_BLOCK('NAME_OF_YOUR_BLOCK');
EXECUTE_QUERY;
END; -
Hi in my sql query i applied like condition (like '%TEST') but it is taking long time. I applied indexes also,but still i'm facing the same problem. In my databse nearly 2,00,000 records their.
Hi Manikandan
Is there a difference in performance between running the query in BEx and WebI?
have you aggregates in place on the BEx side of things?
When you say its taking too long to open the report, have you a variable screen coming up for the report and is that what is taking the time or is it the report execution.
With regards
Gill -
Multi-choice parameters with "like" condition
Hi,
I defined a parameter, multi-choice, using a "like" condition. It always works for the first value of the LOV and ignores the rest of the values chosen.
Is there any way that the "like" condition can be used for more than one parameter value?
In other words, if someone chooses values A,B,C from the LOV, I would like the condition to be interpreted as:
Field like 'A' or Field like 'B' or Field like 'C'.
--Further explanation--->
The reason that I need to use LIKE is that the field contains, e.g. A-1, A-2, A-3, B-1,B-2...
Instead of having the LOV list the variations, it would be much easier for the user to choose A and then get all the A's that exist.
Thanks.
LeahWhat I am still understanding is defining the calculated field as a predefined length which I don't think will work since some of the values are shorter and some longer.
However, you gave me another idea (unless this is what you really meant). I can define the calculated field similar to how I defined the list of values, i.e. take the value of the field until the '-' sign (if it exists). If the actual field value is "permit medical-2", then in the LOV it only says "permit medical". If the original field is "surgery" then the LOV is "surgery. I can do the same thing in the calculated field. Then the condition would be calculated field = LOV.
Thank you! Now my only problem is that I will not be at work for 10 days so I will have to wait until then to try it.
I will let you know how it worked out.
Thanks.
Leah -
Multiple values for a Like condition
How can I make a like condition for multiple value options,
for example
select b.segment1, b.segment2, b.description, c.cross_reference, c.cross_reference_type
from inv.mtl_system_items_b b, inv.mtl_cross_references_b c
where b.inventory_item_id = c.inventory_item_id and
b.ORGANIZATION_ID = 136 and
c.cross_reference like (
'1267801228%',
'1267801230%',
'1500005030%',
'1745%',
'1874106005%',
'2004%',
'2004%',
'232003000000%',
'303681020128%',
'3426441351%',
'489122853014%',
'4894230110%',
'5383800117%',
'5422810701%',
'5422810711%',
'5422810711%',
'70986205105%',
'70986205112%',
'70986205122%',
'70986205131%',
'70986205131%',
'70986205131%',
'70986205142%')Edited by: user8986013 on 28-oct-2010 8:19One way could be to sort the String for length and then use SUBSTR with an IN-List:
select b.segment1, b.segment2, b.description, c.cross_reference, c.cross_reference_type
from inv.mtl_system_items_b b, inv.mtl_cross_references_b c
where b.inventory_item_id = c.inventory_item_id and
b.ORGANIZATION_ID = 136 and
(substr(c.cross_reference,1,12) in (
'232003000000',
'303681020128',
'489122853014')
or
substr(c.cross_reference,1,11) in (
'70986205105',
'70986205112',
'70986205122',
'70986205131',
'70986205142')
or
substr(c.cross_reference,1,10) in (
'4894230110',
'5383800117',
'5422810701',
'5422810711',
'3426441351',
'1267801228',
'1267801230',
'1500005030',
'1874106005')
or
substr(c.cross_reference,1,4) in (
'1745',
'2004')
);By the way: I removed some duplicates.
Edited by: hm on 28.10.2010 09:29 -
List of Like condition from one Lookup table.
Hi,
I have 2 tables.
SourceData table and LookUp table .
SourceData table has one column called SName
SName
Jayesh Krishnan
Karthik Kumar
Liju Sharma
Kumar Jayesh
Kumar Pradeep
Lookup table has one column called LName(Lookup table is the one which is required to look up with "like" condition)
LNamne
Kumar%
%Krishnan
I need to query SourceDate table with the like condition mentioned in lookup table.
So my result based on above two tables should look like
Jayesh Krishnan
Kumar Jayesh
Kumar Pradeep
Please help me in this regard.Try this,
create table sourcetable (SName varchar(200))
insert into sourcetable values('Jayesh Krishnan')
insert into sourcetable values('Karthik Kumar')
insert into sourcetable values('Liju Sharma')
insert into sourcetable values('Kumar Jayesh')
insert into sourcetable values('Kumar Pradeep')
create table lookuptable (LName varchar(200))
insert into lookuptable values('Kumar%')
insert into lookuptable values('%Krishnan')
go
declare @sql nvarchar(max)
declare @temp table ([where] nvarchar(max))
declare @where nvarchar(max)
set @sql = 'SELECT Substring(COLS,4, LEN(COLS)) FROM (
SELECT Stuff((SELECT '' OR SName like '''''' + LName + ''''''''
FROM lookuptable
FOR xml path('''')), 1, 1, '''') COLS
) X'
insert into @temp exec sp_executesql @sql
select @where = [where] from @temp
set @sql = 'SELECT * FROM sourcetable WHERE ' + @where
exec sp_executesql @sql
go
drop table sourcetable
drop table lookuptable
Regards, RSingh -
If like condition in rtf (template for oracle report)
i'm begineer developer in oracle ebs i'm using report builder and rtf (xml) template to build report
can anyone help my i want to make 2 layout in 1 template (1 rtf file) and give condition with if, lower and like (in sql i'm use like) but is error
i give this query in my rft template:
<?if: lower(WORK_ORDER_TYPE) like 'breakdown'?>
<?start:body?>
my_template
<?end:body?>
<?end if?>please help my for this problem
thank you very muchYou can use choose too,
note: the conditions are same
<?choose:?>
<?when: SHIP_COUNTRY_CODE=’IT’?>
<?concat(‘Iscrizione Registro AEE n.’,WEEE_REG_NUM)?>
<?end when?>
<?when: SHIP_COUNTRY_CODE=’IT’?>
<?concat(‘WEEE Registration No.’,WEEE_REG_NUM)?>
<?end when?>
<?end choose?> -
Passing parameters to like condition
hi all,
i am trying to pass a parameters from a form to a report and use this parameter
in a where condition of the sql query , my problem is that i need to use this parameter in a like statment to bring all the records which are like this parameter
its not working...
function AfterPForm return boolean is
V_WHERE VARCHAR2(200);
begin
--:P_called is the parameter sent from the form
IF :P_called IS NOT NULL THEN
V_WHERE := '%'||:P_called||'%';
END IF;
:P_where := 'AND CALLED like' || V_WHERE;
return (TRUE);
end;
----- this is the query----
SELECT *
FROM VOIP_CDR
where substr(VOIP_CDR.CALL_INITIATION_TIME,1,8) between :f_date and :t_date
&p_whereWhat if you change the code like:
:P_where := ' AND CALLED like' || V_WHERE;
so add an additional space in front of the AND statement -
Add dummy Like condition '%%' inorder to use index scan
Hi,
I have a table like below , which have data which capture each minute(columnB) transactions
CREATE TABLE tableA
columnA CHAR(6),
columnB Date,
columnC Number(3,0),
CRT_ID CHAR(8),
CRT_TS TIMESTAMP(6),
UPD_ID CHAR(8),
UPD_TS TIMESTAMP(6),
CONSTRAINT PK_tableA_colAB PRIMARY KEY (columnA , columnB )
When I query the table, to get the list of transaction between particular date, it goes for TABLE FULL SCAN.( cost and execution time also high)
Total no of records in the table(tableA) is 13669094, the below query returns only around 150 to 200 no of records
select columnA,columnB,columnC,Crt_Id,Crt_ts
from tableA
where columnB between TO_DATE('06/28/2013','MM/DD/yyyy') and to_date('06/29/2013','MM/DD/yyyy')
when i use the query like below it will use the INDEX SCAN (cost and execution time also less)
select columnA,columnB,columnC,Crt_Id,Crt_ts
from tableA
where columnB between TO_DATE('06/28/2013','MM/DD/yyyy') and to_date('06/29/2013','MM/DD/yyyy')
and columnA like '%%'
Please advice is it good to add condition like '%%' inorder to use the index scan. Also kindly let me know if it works in the same way in all environments.Hi RP0428,
Thank you very much for your response.
1. Are you collecting statistics on the table and indexes?
2. Post the exact command you use to collect those statistics.
Recently my DBA had gathered the statistics on 17-Dec-2013 22:01:32(LAST_ANALYSED). I am unaware about what query he ran to gather the statistics.
After that it executed in 28 seconds itself, before it took several minutes.
My concerns is only gathering the statistics periodically will improve performance.
Table is growing with thousands of records daily. Already it have 13669094 records. In order to avoid Full Table Scan
From my knowledge, I feel creating composite Range-Hash partitioning will helpful in improving the performance.
3. Post info about the data distribution for the two columns used by the index. This is 'counts and amounts' for each of the two columns and a GROUP BY date showing the skew of the values.
Plz find the details below
ColumnA
ColumnB
AA1
118800
AA2
117600
AA3
118200
AA4
118200
AA5
118200
AA6
118800
AA7
118800
AA8
117600
AA9
117600
AA10
117600
AA11
118200
AA12
118200
AA13
37234
AA14
118200
AA118
18450
AA119
96600
AA120
105000
AA121
105000
AA122
105600 -
Multiple conditions in LIKE condition
Hai all,
Am using a condition like
select * from segmentsload where segment1 like ('SPGA0022%','TY%')
tried using changing the conditions..
I cannot use IN clause here, since this particular segment has got more than 264 distinct values ..
Please guide
Kaiwhere segment1 like 'SPGA0022%'
or segment1 like 'TY%' -
SQL Performance tuning with wildcard Like condition
Hi,
I have performance issue with SQL query.
When I am using "where emp_name like '%im%' " query is taking longer time than when I use "where emp_name like 'im%' " .
With former condition query takes 40 sec , with later it takes around 1.5 sec.
Both returns almost same no. of rows. We have function based index created on emp_name column.
With wildcard at both ends query goes for full table scan.
Can any one please suggest way so that query responce time can be reduced.?
I even tried using hints but still it is going for full table scan instead of using index.>
Hi Mandark,
<I've rearranged your post>
When I am using "where emp_name like '%im%' " query is taking longer time than when I use "where emp_name like 'im%' " .
With wildcard at both ends query goes for full table scan.
I even tried using hints but still it is going for full table scan instead of using index.
With former condition query takes 40 sec , with later it takes around 1.5 sec.
Both returns almost same no. of rows. We have function based index created on emp_name column.You are never going to be able to speed things up with a double wild card - or even 1 wild card at the beginning
(unless you have some weird index reversing the string).
With the double wild-card, the system has to search through the string character by character to see
if there are any letter "i's" and then see if that letter is followed by an "m".
That's using your standard B-tree index (see below).
Can any one please suggest way so that query responce time can be reduced.?Yes, I think so - there is full-text indexing - see here:
http://www.dba-oracle.com/oracle_tips_like_sql_index.htm and
http://www.oracle-base.com/articles/9i/full-text-indexing-using-oracle-text-9i.php
AFAIK, it's an extra-cost option - but you can have fun finding out all that for yourself ;)
HTH,
Paul... -
Is there a plan to introduce conditional indexes the way it's done in XSLT?
Something like this:
<xsl:key name="action" match="/*/ENTRY[(@Operation='notify' or @operation='notify')]/DATA" use="@action"/>From the top of my head:
1. Index by attribute value when another attribute of the same element has particular value[s], or evaluation of another attribute has particular value[s]. Combining of two indexes is not the same at all.
2. Index by element or attribute when path is important and there are other elements/attributes with the same name or exactly the same element, but located differently in tree.
I didn't look into documentation too deep, but it seems I never saw Berkeley DB XML supports full text search index. Does it? -
Hi All,
I need to write a select statment where we have a column called Booked By as starting string.
Now I need to write a condition which will return only records which are boked otjer than Booked By Admin
For this i written the follwoing condition
Select * from sample_table where notes like 'Booked By%' and notes not like 'Booked By Admin'.
Is this query correct.
Thanks.Hi Lokanath,
His query is correct but...
WITH T AS
(SELECT 'Booked By R.K Laxman' Notes FROM DUAL UNION ALL
SELECT 'Booked By Admin' Notes FROM DUAL
SELECT * FROM T WHERE Notes LIKE 'Booked By%' and Notes not like 'Booked By Admin'
;If like is to be used then it doesn't make much sense to use it against a plain string. The statement would be best rewritten as:
WITH T AS
(SELECT 'Booked By R.K Laxman' Notes FROM DUAL UNION ALL
SELECT 'Booked By Admin' Notes FROM DUAL
SELECT * FROM T WHERE Notes LIKE 'Booked By%' and Notes != 'Booked By Admin'
;(using !=) or if something may follow the "Booked By Admin" string then:
WITH T AS
(SELECT 'Booked By R.K Laxman' Notes FROM DUAL UNION ALL
SELECT 'Booked By Admin' Notes FROM DUAL
SELECT * FROM T WHERE Notes LIKE 'Booked By%' and Notes not like 'Booked By Admin%'
;lack of precision can lead to subtle bugs. His query is correct but certainly not robust.
HTH,
John.
Edited by: 440bx - 11gR2 on Aug 11, 2010 1:53 AM - correction had been made already before I had time to post this. -
Like condition in Hibernate SQL
Hi,
I have the following configuration:-
1. Hibernate 3.2
2. JBOSS 4.3GA application server
I have a table named Customer with three columns:-
a) Id
b) FistName
c) LastName
I want to create a hibernate restriction for looking up cusomers whose LastName begins with FirstName i.e. something like "select * from Customer where LastName like %FirstName"
How do I do it through hibernate???
Thanks
Ashwaniashj_chugh wrote:
I want to create a hibernate restriction for looking up cusomers whose LastName begins with FirstName i.e. something like "select * from Customer where LastName like %FirstName"As a side issue you might want to add some lower case (or upper) to that where clause as well unless you have already dealt with that. -
Is there something like conditional compiling in JAVA...
...or do I really have to use a constant in the main class to prevent my test code from being executed in a final release. Which has the disadvantage, of course, that the code is still there.
You have to use the constant. The code will (should) not be in the compiled bytecode - the compiler will (should) optimize it out.
Maybe you are looking for
-
Can we get the data from two internal tables in ALV.
hi friends i would like to display the data using two internal tables using alv grid.please guide me.
-
Back up for Nokia C3-01.5
I am new to Nokia Suite. I have recently backed up my phone. When i went into word to view it i found it unreadable. Can anyone please tell be how i can read it? I have enclosed attachment.
-
So I booted my computer up like normal today, and it didn't post. I looked at the LED readout and saw it was code 62. I did some reading, and found it may be the graphics card. I took it out, and tried again. Still 62. I read also that I should unplu
-
Hi! When I try to connect to WebDav via Windows Explorer I obtain the following error: "Server configuration properties could not be obtained" <?hda version="10.1.3.3.2 (071031)" jcharset=UTF8 encoding=utf-8?> @Properties LocalData StatusCode=-1 Stat
-
This message pops up wen I tray to pay for some chips on pokerist it tell me to contact iTunes support service to comple my purches