Personal is the following.
I have a MCampo in a table that is kindly.
is a field for observations, but we are using the same with the intention of relating codes with another system.
In this field, there may be as follows:
1-33-566-23-230
Where each number It's a code. I wanted to see if someone has a role or script ready to locate within that field a certain number.
For example: if I search the observation with the code 23, it seeks the line where one of the related codes is the 23.
to break the head And I'm not finding a way to do this.
I tried with% 23% for example, but then he returns to 233 também.
Does anyone have an idea of ??how can I get it?
Find STRING NUMBER
-
diegopedrao
- Rank: Analista Sênior

- Posts: 164
- Joined: Fri, 22 Aug 2008 12:28 pm
- Location: SP
cara V C é This:
Att,
Diego Monteiro
select SUBSTR('34983024230892389809808',INSTR('34983024230892389809808', '23') , LENGTH('23')) from dual
Diego Monteiro
Dude, maybe it's, but only with this example I can not say.
shows me an example on swguento structure then, then I can see.
Let's say I have Table X
in this table X I have the COD and COD_RELAC field
COD is a Sequence (1,2,3,4 ...)
COD_RELAC is the VARCHAR field where there may be the string (1-2-33-22-45)
Let's say I want to locate the line where in the COD_RELAC field, it has the number 33.
How would SELECT?
vlw
shows me an example on swguento structure then, then I can see.
Let's say I have Table X
in this table X I have the COD and COD_RELAC field
COD is a Sequence (1,2,3,4 ...)
COD_RELAC is the VARCHAR field where there may be the string (1-2-33-22-45)
Let's say I want to locate the line where in the COD_RELAC field, it has the number 33.
How would SELECT?
vlw
-
victorhugomuniz
- Moderador

- Posts: 1396
- Joined: Fri, 01 Feb 2008 2:06 pm
- Location: Rio de Janeiro - RJ
- Contact:
Can not you do that?
select * from x where cod_relac like '%-33-%';-
diegopedrao
- Rank: Analista Sênior

- Posts: 164
- Joined: Fri, 22 Aug 2008 12:28 pm
- Location: SP
See this here then easier.
ATT,
Diego Monteiro
SELECT CAMPO
FROM (select '33-2-1-22-23' as campo from dual)
WHERE CAMPO LIKE '%-33-%'
OR CAMPO LIKE '%-33'
OR CAMPO LIKE '33-%'
Diego Monteiro
-
Marcelo Malta
- Rank: Estagiário Sênior

- Posts: 9
- Joined: Tue, 28 Sep 2010 3:23 pm
- Location: Serra-ES
Atc,
----------------------------------------
Marcelo Malta
Analista de Sistemas
----------------------------------------
----------------------------------------
Marcelo Malta
Analista de Sistemas
----------------------------------------
The solution is simple yes, but I do not see much difference between it and
if you have any code '1-29-18-333-182-91' will bring too, and I think it is not What you want, it picks up by '% -33%'
I would have to search to give you a correct answer, but there is a function that separates the values ??by a certain character, in case The '-', type the split in C # and brings a list of values. I can not remember what it's like in Oracle, but I guess it would suit you better.
If anyone knows what I'm talking about could help as well.
like '%33%'I would have to search to give you a correct answer, but there is a function that separates the values ??by a certain character, in case The '-', type the split in C # and brings a list of values. I can not remember what it's like in Oracle, but I guess it would suit you better.
If anyone knows what I'm talking about could help as well.
Dude, in fact that way there will not get a possible -333- because the like always has the trait.
or is% -33-% that sought 33 in the middle of string
or '33 -% which will seek at the beginning of it
or at last the % -33 'which will find if the 33 is at the end.
For always having the trace with 33, there is no danger of seeking a 333.
But VLW for the answer.
: -O
or is% -33-% that sought 33 in the middle of string
or '33 -% which will seek at the beginning of it
or at last the % -33 'which will find if the 33 is at the end.
For always having the trace with 33, there is no danger of seeking a 333.
But VLW for the answer.
: -O
-
victorhugomuniz
- Moderador

- Posts: 1396
- Joined: Fri, 01 Feb 2008 2:06 pm
- Location: Rio de Janeiro - RJ
- Contact:
-
gfkauer
- Rank: DBA Sênior

- Posts: 389
- Joined: Tue, 27 Jul 2010 1:34 pm
- Location: Sapiranga - RS
- Contact:
Quem falou que programar era fácil??
Quanto mais dificil for a implementação mais valorizado seu trabalho será!
Acessem: www.gfkauer.com.br
Quanto mais dificil for a implementação mais valorizado seu trabalho será!
Acessem: www.gfkauer.com.br
How about this:
Select g.*
From gfk_teste g
Where g.valor Like '%&p_busca%'
And ((instr(g.valor, &p_busca) + length(&p_busca)-1) = length(g.valor)
Or substr(g.valor, instr(g.valor, &p_busca) + length(&p_busca), 1) = &separador);
The problem of the diego code is if there is only the number 33 in the field (no traces before or after), it will not be returned.
I think the simplest solution is to use regular expressions:
I think the simplest solution is to use regular expressions:
select * from tabela
where regexp_like(coluna, '(^|-)33($|-)');-
Marcelo Malta
- Rank: Estagiário Sênior

- Posts: 9
- Joined: Tue, 28 Sep 2010 3:23 pm
- Location: Serra-ES
Atc,
----------------------------------------
Marcelo Malta
Analista de Sistemas
----------------------------------------
----------------------------------------
Marcelo Malta
Analista de Sistemas
----------------------------------------
I really ate fly. Your solution meets well, except for the case of only having the number 33 in the field.
However they have already put a solution to this.
However they have already put a solution to this.
The problem of the diego code is if there is only the number 33 in the field (no traces before or after), it will not be returned.
I think the simplest solution is to use regular expressions:
OPA There was no more facing the topic for already having solved the problem.
But really if it is only 33 that code did not seek.
But then I simply added another or
...
OR campo LIKE '33'
Thanks to all for help.
vlw.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 1 guest
