Is there a way to use Like in a Long field?

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
Post Reply
lopes_andre
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Mon, 13 Oct 2008 9:01 am
Location: Lisboa

Viva,

I need to search strings within a long field that is, make a select using the like.

Is it possible to do this in a LONG field?


Thanks
User avatar
fsitja
Rank: OraSauro
Rank: OraSauro
Posts: 611
Joined: Mon, 19 Jan 2009 4:29 pm
Location: Gaúcho no Rio de Janeiro - RJ
"The scars exist to remind us that the past was real"
Campanha: Como fazer uma pergunta e obter uma resposta.
http://tkyte.blogspot.com/2005/06/how-t ... tions.html

OCA & OCP Developer — OCE SQL Expert — OCS Data Warehousing Specialist

It is not possible, firing an error or-00932.

Inclusive it is recommended that no more long types in the new oracle versions because this will be discontinued. Replace by BLOB if you are feasible and the varchar2 does not serve you.
http://www.techonthenet.com/oracle/errors/ora00932.php
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Just to complement:
BLOB - for binaries
clob - for characters

: -O
User avatar
fsitja
Rank: OraSauro
Rank: OraSauro
Posts: 611
Joined: Mon, 19 Jan 2009 4:29 pm
Location: Gaúcho no Rio de Janeiro - RJ
"The scars exist to remind us that the past was real"
Campanha: Como fazer uma pergunta e obter uma resposta.
http://tkyte.blogspot.com/2005/06/how-t ... tions.html

OCA & OCP Developer — OCE SQL Expert — OCS Data Warehousing Specialist

Oh yeah, pretend it was TYPO! : roll:
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Remember that in dbms_lob has some functions that can help, such as dbms_lob.instr, dbms_lob.substr ...

These can "simulate" a like ...
lopes_andre
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Mon, 13 Oct 2008 9:01 am
Location: Lisboa

Live again.

I spent the Long Clob field to be able to use the like, but now needed to change again for Long and I can not.

The question, is there a way to pass a cloze field for Long?


Thanks.


Greetings.
User avatar
NightSpy
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 49
Joined: Tue, 09 Sep 2008 4:18 pm
Location: SP

Andre, could not turn to Varchar2 ?? I think it would be more feasible.
Trevisolli
Moderador
Moderador
Posts: 2016
Joined: Wed, 12 Jan 2005 3:25 pm
Location: Araraquara - SP
Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Brother,

Doing alter returning I believe it is not possible. I made some tests here and I could not.

Create it as Long (I am using version 9i) is possible yes, however, after changed, you can not return to the original datatype.

may be any Oracle Feature , which no longer allows you to use this type of data in some bank versions (would need to take a more calm search).

But to be sure, I did the tests below:

Select all

 
CREATE TABLE teste (cod NUMBER(10), descricao LONG); 
 
SELECT * 
FROM teste; 
 
ALTER TABLE teste MODIFY descricao CLOB; 
 
SELECT * 
FROM teste; 
 
 
ALTER TABLE teste MODIFY descricao LONG; 
 
-- ORA-22859: invalid modification of columns 
a tip: I do not know the Your structure and complexity of your table, but if you are obligatoryly to need this type of data again (as informed by Dr_Gori, if other datatypes do not satisfy your need), give a drop on your table (saving information before) and recreate This datatype you will probably get.

If you can not give a Drop in the table, create another column in this table, type long , give a update of the values ??of the CloB Pro Long field and then drop this cloble column.

There is the Brother tip.

Anything, send us to us.
GuGatto
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Wed, 30 Oct 2019 3:07 pm
Location: Campinas/SP

You can create a function to convert the field.

Select all

CREATE OR REPLACE FUNCTION get_search_condition 
( 
  p_owner           all_constraints.owner%TYPE, 
  p_constraint_name all_constraints.constraint_name%TYPE 
) RETURN VARCHAR2 IS 
  v_long LONG; 
BEGIN 
  SELECT search_condition 
  INTO   v_long 
  FROM   all_constraints 
  WHERE  constraint_name = p_constraint_name 
  AND    owner = p_owner 
  AND    constraint_type = 'C'; 
 
  RETURN substr(v_long, 1, 32760); 
END;
then use it at Query:

Select all

SELECT constraint_name, 
       get_search_condition(owner, constraint_name) AS search_condition 
FROM   all_constraints 
WHERE  owner = 'MYSCHEMA' 
AND    table_name = 'MYTABLENAME' 
AND    constraint_type = 'C' 
AND    get_search_condition(owner, constraint_name) = 'TEXT_SEARCH';
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest