PL/SQL :: Searching String In A Table

Sep 9, 2013

I am using Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production. 

I have a situation where I need to find the number of occurrences of a string that is present in a table having comma separated values. To explain with an example:  

create table test_data ( textfield varchar2(100)); 
insert into test_data values('DM,HM'); 
insert into test_data values('EM'); 
insert into test_data values('AM,CA,CD,FM,ST'); 
insert into test_data values('LS');
  insert into test_data values('TQ,SP,AM,FM,ST,CA,CD'); 
insert into test_data values('TQ,SP,AM,FM,ST,CA,CD,LS'); 
insert into test_data values('DM,HM,LS');

 The data in the table test_data looks like  DM,HMEMAM,CA,CD,FM,STLSTQ,SP,AM,FM,ST,CA,CDTQ,SP,AM,FM,ST,CA,CD,LSDM,HM,LS Now I need to search"LS" in the table test_data. Basically, I need to find if "LS" is present at least once in any of the rows or not. I want to avoid looping here. 

View 4 Replies


ADVERTISEMENT

SQL & PL/SQL :: Searching For A String In Whole Database

Aug 16, 2012

I've tried to write the procedure for search the string from whole database. If user give the string as an input the output will be tablename and column in which the string contained in the table,But it's showing an error .

CREATE OR REPLACE procedure sample.pr_search_table (p_search varchar )
is
type tb_type is table of varchar(30);
tb_table tb_type:= tb_type();
tb_column tb_type := tb_type();
v_temp varchar(30);
[code]...

View 6 Replies View Related

SQL & PL/SQL :: Insert Using String Matches / Matching And Searching Match

Jul 3, 2012

i have three tables ot_cut_head,ot_cut_det and om_mc_master based on which fourth table ot_cut_opr and fifth table ot_cut_mc must get populated , Conditions are as follows

first one is based on job_no in ot_cut_head the selection criteria will be filtered,if the job number is like '%M' then type MISC will be chosen ,if job number is '%G' then GRAT TYPE will be picked from om_mc_master (Machine Master) and operations and machines based on this will be filtered.

Second all the cd_ps_desc will be taken from ot_cut_det and will be compared with om_mc_master to get their corresponding operation codes and machine codes , there can be 2 operations or 1 operation.

Finally if the match is found record will be inserted into ot_cut_opr and ot_cut_mc ,based on the criterias and what i want is the search criteria to be more flexible and if there are 2 operations 2 rows will be inserted and if one opeation is defined in om_mc_master ,then only one record will be inserted.

We have to make sure that if based on operation number stage will be populated ,if its first operation then stage will be 1 and if its second operation the stage will be 2.like previous operation also depends on them , the second operation will have the previous operation as first operation and so on.

CREATE TABLE om_mc_master ( mc_type VARCHAR2(12),mc_prof VARCHAR2(30),mc_prep_cd1 VARCHAR2(30),mc_mach_cd1 VARCHAR2
(30),mc_prep_cd2 VARCHAR2(30),mc_mach_cd2 VARCHAR2(30));
INSERT INTO OM_MC_MASTER VALUES ('MISC','TEE SCH','IR','HO','RE','HO');
insert into om_mc_master values('MISC','Vertical Brace','R','HM','I','HO');
insert into om_mc_master values('MISC','Pipe','IR','HO',NULL,NULL);
INSERT INTO OM_MC_MASTER VALUES ('GRAT','PL','RE','HO',NULL,NULL);
SQL> SELECT * FROM OM_MC_MASTER;
[code]....

View 6 Replies View Related

SQL & PL/SQL :: Use Of Index For Searching Data In Table

Mar 5, 2010

i want to know the use of index for searching data in table...tell answer to my query with table example....

View 2 Replies View Related

Stored Procedure For Searching Data From A Table By Passing Tablename As A Parameter

Feb 6, 2012

This procedure is not working properly.

create or replace procedure bank_search_sp
(
p_tablename in varchar2,
p_searchname in varchar2,
p_bankcode out varchar2,
p_bankname out varchar2,
p_dist_code out number
)
as
v_tem varchar2(5000);
begin
v_tem :='select bankcode,bankname,dist_code from ' || UPPER (p_tablename) || '
where bankname like '''|| p_searchname||'';
execute immediate v_tem into p_bankcode,p_bankname,p_dist_code using p_searchname ;
commit;
end bank_search_sp;

the Procedure is getting created but i dont know what actually happens when it was executed ,This is the error shown..ORA-01756: quoted string not properly terminated

ORA-06512: at "PENSIONS.BANK_SEARCH_SP", line 14
ORA-06512: at line 1

View 1 Replies View Related

SQL & PL/SQL :: Searching Collection For A Specific Value?

Oct 18, 2011

I need to check if a small collection contains a specific value. I know I can use the .exist method to let me know if the nth element exists. But is there a similar syntax for checking if an actual value exists?

So the below collection has 6 values (300,301,310,320,400,410) after the cursor values are fetched. I want to use something similar to the below exists syntax in order to search the collection for a value (rather than position) within an IF statement.

The below code shows the kind of thing I want to do. Currently, unless my test value (310) is in the range 1 to 6 the test will always return FALSE. But is there a similar syntax for testing against the value?

The example I have given is a simplification of what I need. In reality there will be more than one test value... returned by another cursor.

DECLARE
CURSOR c_type_id_usg
IS

[Code]....

-- get the list of sms type id usg values
OPEN c_type_id_usg;
FETCH c_type_id_usg bulk collect into l_type_ids;
CLOSE c_type_id_usg;

-- the above returns value 300,301,310,320,400,410

IF l_type_ids.exists(310)
then
dbms_output.put_line('I have found an entry ');
else
dbms_output.put_line('I have NOT found an entry ' );
end if;
END;

View 2 Replies View Related

SQL & PL/SQL :: Searching City Name From Address

Apr 16, 2010

I want to write a SQL statement to search valid city name from address field. Valid city names are in one table and address column is in another table.

View 5 Replies View Related

SQL & PL/SQL :: Searching Numbers In Description Column?

Jun 15, 2010

I have two tables emp and dept

sql>select emp_id from emp;
emp_id
------
123
345
6782
32

[code].....

I would like to search all the employee id's which are present in description column of dept.

View 32 Replies View Related

SQL & PL/SQL :: Searching Data In Backup Tables

Apr 30, 2013

TEMP1--ORINIGAL TABLE NAME

DESC IS:

SNO NUMBER;
SNAME VARCHAR2(100);

BACK UP TABLES ARE

TEMP1_1;
TEMP1_2;
TEMP1_3;
.
.
.
.
.
TEMP1_10

IN THE ABOVE 11 TABLES SNAME COLUMN HAVING THE DATA AS 'NARESH'
IN SOME OF THE TABLES AND NOT IN OTHERS.

REQUIRMENT:

I WANT THE TABLES ONLY HAVING THE

SNAME COLUMN 'NARESH'.

View 7 Replies View Related

PL/SQL :: Searching Text Clobs From User_views?

Jul 22, 2013

I needed to search for some specific text in the DDL of each of the views in a particular schema. The text column of the user_views is LONG, and I looked at some old Tom's threads for converting long2clob, but found these processes to be really cumbersome, so I just opted to use DBMS_METADATA.GET_DDL instead even if it is a little slow.

One area I do not have a lot of experience with is searching clob fields. I tried this but not sure what would be the appropriate function to use for something like this:

SELECT *
FROM
(

[Code]....

WHERE contains(object_text, 'WHERE t.policy NOT LIKE') > 0; -- Show the names of all views that contain the matching text

View 4 Replies View Related

Tuning Searching Into Clob In Batch Operation?

Jul 3, 2012

My application runs a batch procedure weekly once for searching 'A_Text' from a column in Table1 in a clob column in Table2 and inserts accordingly into another Table3.

code snippet is like this -

---
CURSOR cr_sn
IS
SELECT serial_number

[Code]....

TABLE1 will have at least 1.1 Million rows but not significantly more than this.

This procedure takes 24+ hours to complete. I tried -

1. putting parallel hint ( INSERT /*+ PARALLEL*/INTO Table3)

2. partitioning TABLE2 based on last_update_date and putting a where clause in the above query last_update_date ( last_update_date between date1 and date2)

View 3 Replies View Related

Forms :: Creating Searching Tool Using Oracle 6i?

Nov 26, 2012

I have created searching tool using oracle forms 6i. while searching the cursor move from text field (A) to other block query the data according to the field (A) and come back again to field (A). Everything is working fine but the problem is, when the cursor move back to the field (A) the existing text is highlighted and when user right something in it. It's overwriting the existing text.

I want when the cursor moving bank to the field (A) the text should not be highlighted and when the user writes something that will be added to the existing text.

View 1 Replies View Related

SQL & PL/SQL :: Searching PRODUCT Column Based Upon User Input?

Apr 30, 2010

I have table in Oracle with one column PRODUCT. Column PRODUCT have following values -

Account Management
Active Directory
Adobe Acrobat Reader
NT Account
Application Security

[code]....

I am designing application where I need to search for PRODUCT based upon user's input. Lets say user wants search on 'Laptop Account Broken'. I want to search for all products which contains any of words in user's input. So based upon user's input I want output like below.

Expected Output:

Account Management
NT Account
WebSite Account
HP Laptop

View 2 Replies View Related

Sql Query - Insert Concatenation String To Table?

Aug 6, 2012

i try to insert Concatenation string to my table,i need that all traps that has 12 length will be insert the new trapnum like this:

for example: 26001005CC45 = 260001005CC0045 ....... 08060027RF05 = 080600027RF0005 ......... and so....

update trap set TrapNum = (
select trim(both from to_char(substr(TrapNum,1,4),'0000'))||
trim(both from to_char(substr(TrapNum,5,1),'00'))||
trim(both from to_char(substr(TrapNum,6,3),'000'))||
substr(TrapNum,9,2)||
trim(both from to_char(substr(TrapNum,11,2),'0000')) from Trap)
where length(Trapnum)=12

but i got error ORA-01427

View 1 Replies View Related

SQL & PL/SQL :: Update Long String In Table By Command

Jan 23, 2011

I use sqlplus in oracle (linux).I have a table and the string cell have long string .

Like below :

column A Column B

A BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
.....................................BBBBBBBBBBB

So, I need to edit/update the row A and the value in Column B.But the string in Column B is so long and I only need to edit one character.IF I use update command , I need to type very long string and it is easy to wrong edit .

View 8 Replies View Related

JDeveloper, Java & XML :: How To Generate String From Nested Table

Mar 19, 2013

CREATE TYPE TEST_103 AS OBJECT(CHILD_CSE_ID VARCHAR2(25));
CREATE TYPE TEST_104 AS TABLE OF TEST_103;
CREATE TABLE TEST_105 (
CL_ID VARCHAR2(25),
CSE_ID VARCHAR2(14),
EXP_ID VARCHAR2(13),

[code]....

I want an XML output like as follows

<?xml version="1.0" encoding="UTF-8"?>
<Main_case>
<cl_id="A">
<cse_id="100">
<cs_lst>

[code]....

View 2 Replies View Related

PL/SQL :: String Search Query In Any Columns / Table In Database?

Sep 4, 2012

I am trying to search a word which starts with 'FRA' in any columns and any tables.

I am unable to find what is generating a join datasets in the webservice from teh database as it is not apparent within the 100 tables.

I ahve looked into

Re: How to search in all rows and all columns?
Re: SQL Search Query?

but none of these queries is working out for me as I am a user with no tables on its own but rather a user quering other tables.I think its a tweak on which dat a dictionary I can view

select distinct substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from all_cons_columns,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || 'fra'
|| '%'')'
).extract ('ROWSET/ROW/*')
)
) t
order by "Table";

running teh above query got me thsi error:

ORA-19202: Error occurred in XML processing
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_XMLGEN", line 288
ORA-06512: at line 1
19202. 00000 - "Error occurred in XML processing%s"
*Cause:    An error occurred when processing the XML function
*Action:   Check the given error message and fix the appropriate problem

View 4 Replies View Related

ORA-02085 - Database Link String Connects To String

Jun 19, 2012

I have this error (and solution):

ORA-02085: database link string connects to string

Cause: a database link connected to a database with a different name. The connection is rejected.

Action: create a database link with the same name as the database it connects to, or set global_names=false.
Where should I set global_names=false ?

View 7 Replies View Related

SQL & PL/SQL :: Remove Last Comma End Of String And Load Clob Data Into Table

Aug 29, 2012

To remove the last comma end of string and load the Clob data into table. create table test(name clob)

View 2 Replies View Related

SQL & PL/SQL :: Insert Records Of One Table Into Another - Literal Does Not Match Format String

Sep 30, 2010

I'm trying to insert records of one table into another using the insert into table with select logic.

I'm trying to convert a two character value using CASE statement:

CASE REC_TYPE
WHEN '00' THEN to_number('0')
ELSE to_number('1')
END "REC_TYPE"

The target field is defined as number(1,0) and the source field is varchar2(2).

I keep getting an ORA-01861 literal does not match format string error.

View 10 Replies View Related

SQL & PL/SQL :: Converting Comma And Pipe Delimited Input String To Nested Table

Nov 12, 2010

I am expecting the input to my procedure will be in the following format

'AAA, aaa, Aa12|BBB, bbb, bb2B|dd3, DDDE,ddd67'

I need to convert it to nested table and when I query the nested table , the output should be

column_value
------------
AAA
aaa
Aa1
BBB
bbb
bb2B
dd3
DDDE
ddd67

View 9 Replies View Related

SQL & PL/SQL :: How To Find Whether Exact String Is Present / Not In Given String

Mar 14, 2013

I'm facing some problem even after using INSTR function in Oracle.The problem is I have written the logic in the PL/SQL block which appends all the values fetched in a loop on the basis of whether the string is present or not.

For ex:

The first value fetched from the select query first is ABCDEFG which gets appended to a variable
The next value fetched is AB even this has to be appended to the variable since this exactly doesn't match with ABCDEFG.
The next value fetched is BCDEF even this has to be appended to the variable since this exactly doesn't match with ABCDEFG.
The third Value fetched is ABCDEFG this will not get appended presently according to the logic which is correct.

writing that piece of code to append the value fetched which doesn't exactly match with the existing string

View 3 Replies View Related

How To Use String Buffer Instead Of String Query

May 9, 2008

show an ex to use string buffer for select statemnt

View 1 Replies View Related

Get Table Name / Constraint Name / Constraint Type With Join Processes In String Type

Dec 25, 2007

i want to get table name, constraint name, constraint type with join processes in string type. this is what i want: alter table tablename add constraint constraintname constrainttype(columnname)

View 1 Replies View Related

SQL & PL/SQL :: Remove String Before And After Pipeline To Get String Between Pipeline?

May 10, 2010

I have a string like below:

string = 'HEADER||MEAL||15'

How to get 'MEAL' string? The length of the string can be various. Means, 'MEAL' can be 'INFLIGHT'. So, i cant use the substr. Is there a function that can recognize the pipeline? so that i can remove all the string before the pipeline and after the pipeline to get the string between the pipeline?

View 9 Replies View Related

String To Array

May 22, 2009

I have a comma seperated string say (tr,er,pr) and i have to convert it to ('tr','er','pr'). if there is function coded to do so.

View 1 Replies View Related

String Of Numbers

Oct 12, 2007

I have the following set of numbers that i am passing in as one input into a stored procedure.

234,456,234,456,567

Now i want to take this list of numbers and use it in an IN statement:

select * from table where column_a in (P_INPUT);

however, when i try this, it give me an invalid error. I have tried inserting single quote around each value and get the same invalid error. I tried a To_char around my column, which solved the error, but it never finds a match!

View 6 Replies View Related

Count For A Particular String?

Oct 9, 2008

say there is astring "mumbojumbo "i need the count of given string in it

ex:when o is given count shuld be 2 when m is given count shuld be 3

is there any pre defined function for counting a given string ...

View 2 Replies View Related

SQL & PL/SQL :: How To Get First Word From String

Aug 22, 2013

how to get first word from string.example i have string like:-

Jack Bore American
Mark D'suz Australian
Raj
Deniel indian
Some

i am expecting first word as out put like :-

jack
mark
Raj
Deniel
Some

in the same maner if i want should get two words also.

View 36 Replies View Related

SQL & PL/SQL :: How To Get Last 4 Characters In A String

Dec 12, 2010

how to get last 4 characters in a string. But i don't know the length , for example the string is

abcdefghij

i want only ghij.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved