`
talentkep
  • 浏览: 100497 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

complex sql search

阅读更多

Declare

  sqlStr_part1 varchar2(4000);

  sqlStr_part2 varchar2(4000);

  sqlStr_part3 varchar2(4000);

  sqlStr_part4 varchar2(4000);

  out_string_in_part1 varchar2(4000);

  out_string_in_part2 varchar2(4000);

  out_string_in_part3 varchar2(4000);

  out_string_in_part4 varchar2(4000);

  TYPE   cur_type   IS   REF   CURSOR;  

  d_cursor_tab_part1   cur_type;

  d_cursor_tab_part2   cur_type;

  d_cursor_tab_part3   cur_type;

  d_cursor_tab_part4   cur_type;

  idNum_part1 NUMBER;

  idNum_part2 NUMBER;

  idNum_part3 NUMBER;

  idNum_part4 NUMBER;

  v_rows NUMBER;

  str_len_part1 NUMBER;

  str_len_part2 NUMBER;

  str_len_part3 NUMBER;

  str_len_part4 NUMBER;

  loop_count_part1 NUMBER;

  loop_count_part2 NUMBER;

  loop_count_part3 NUMBER;

  loop_count_part4 NUMBER;

  cursor searchSQL_Cursor_part1 is

         select 'select count(*) from "'|| t.TABLE_NAME || '" t where 

             '|| 'upper("' ||COLUMN_NAME || '") like ''%PFINGOI%'' or '|| 'upper("' || COLUMN_NAME ||'") like ''%R538LA%''  or '|| 'upper("' || COLUMN_NAME ||'") like ''%R519LA%'' or '|| 'upper("' || COLUMN_NAME ||'") like ''%R532LA%''  or '|| 'upper("' || COLUMN_NAME ||'") like ''%4249B%''   or '|| 'upper("' || COLUMN_NAME ||'") like ''%4977B01A%''  or '|| 'upper("' || COLUMN_NAME ||'") like ''%3437A%''   or '|| 'upper("' || COLUMN_NAME||'") like ''%3437C%''    or '|| 'upper("' || COLUMN_NAME||'") like ''%R613A-LOOP-UTM%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%R613A-LOOP-MIM%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%R614A%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%R613A%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%R455A%''or '|| 'upper("' || COLUMN_NAME||'") like ''%DFDRLGDM%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%R613-LOOP-TESTS%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%AAAA-LOOP-TESTS%''  or '|| 'upper("' || COLUMN_NAME||'") like ''%R143%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%R123%'' 

          or '|| 'upper("' || COLUMN_NAME||'") like ''%R162%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%1870%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%3221%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%3624%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%3131%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%3037%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%3698%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%R184%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%2900%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%4270%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%4035%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%4450%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%4675%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%R473%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%R342%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%R358%'' '

          as sqlStrr, TABLE_NAME from user_tab_columns t where data_type = 'VARCHAR2' or data_type = 'CHAR';

         

  cursor searchSQL_Cursor_part2 is

         select 'select count(*) from "'|| t.TABLE_NAME || '" t where  

             '|| 'upper("' || COLUMN_NAME||'") like ''%P65NLG-LOOP-GOI%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P65NLG57L1PBMAC1%''or '|| 'upper("' || COLUMN_NAME||'") like ''%P65NLG47L1P8M7C1%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P65NLG45L1P8M7C1%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P65NLG38L1P8M7C1%'' 

          or '|| 'upper("' || COLUMN_NAME||'") like ''%P55NLG35L1P8M7C1%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P11ULG32L1P7M6C1%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P11ULG32L1P7M6C1%''or '|| 'upper("' || COLUMN_NAME||'") like ''%P09ULG-LOOP-UTM%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P09ULG-LOOP-MIM%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P09ULG54L1PAM9C3%''or '|| 'upper("' || COLUMN_NAME||'") like ''%P09ULG54L1PAM9C2%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P09ULG54L1PAM9C1%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P09UCI-LOOP-TESTS%''or '|| 'upper("' || COLUMN_NAME||'") like ''%PDDF_LGDMY%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P09UCI-LOOP-TESTS%'' '

          as sqlStrr, TABLE_NAME from user_tab_columns t where data_type = 'VARCHAR2' or data_type = 'CHAR';

          

  cursor searchSQL_Cursor_part3 is

         select 'select count(*) from "'|| t.TABLE_NAME || '" t where  

             '|| 'upper("' ||COLUMN_NAME || '") like ''%0920POX0116%'' or '|| 'upper("' || COLUMN_NAME ||'") like ''%0760SIN1250%''  or '|| 'upper("' || COLUMN_NAME ||'") like ''%1000LOX0106%'' or '|| 'upper("' || COLUMN_NAME ||'") like ''%1100ANN120M%''  or '|| 'upper("' || COLUMN_NAME ||'") like ''%0650SIN0300%''   or '|| 'upper("' || COLUMN_NAME ||'") like ''%0800WGO0051%''  or '|| 'upper("' || COLUMN_NAME ||'") like ''%0850GOX0032-65LL%''   or '|| 'upper("' || COLUMN_NAME||'") like ''%0620UPY1000-65LL%''    or '|| 'upper("' || COLUMN_NAME||'") like ''%0410ALY030M-65LL%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%0800SOX0029%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%0800SOX0028%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%0800ANN060M-90G%''  or '|| 'upper("' || COLUMN_NAME||'") like ''%0650SIN0206B%''or '|| 'upper("' || COLUMN_NAME||'") like ''%0650SIN0124%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%B1AL10N700-C124%'' 

          or '|| 'upper("' || COLUMN_NAME||'") like ''%C090N200-12%''  or '|| 'upper("' || COLUMN_NAME||'") like ''%C65%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%C090N200-13%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%C090N200-42%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%C090N200-43%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%C90%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%E30C65N200-D43%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P_16KAV2E1A1-13%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P_7KAV1E2A1-123%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P_7KAV1E2A1-2%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%P_8KAV1E2A1-23%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%E35T05N50-C12%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%E35T05N50-C13%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%E35T05N50-C42%'' '

          as sqlStrr, TABLE_NAME from user_tab_columns t where data_type = 'VARCHAR2' or data_type = 'CHAR';

          

  cursor searchSQL_Cursor_part4 is

         select 'select count(*) from "'|| t.TABLE_NAME || '" t where '|| 'upper("' ||COLUMN_NAME || '") like ''%LOGIC%'' or '|| 'upper("' || COLUMN_NAME ||'") like ''%LG%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%65LL%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%55LL%'' or '|| 'upper("' || COLUMN_NAME||'") like ''%90RF%'' or '

         || 'upper("' || COLUMN_NAME||'") like ''%CIS%''or '|| 'upper("' || COLUMN_NAME||'") like ''%CCD%''or '|| 'upper("' || COLUMN_NAME||'") like ''%FSI%''or '|| 'upper("' || COLUMN_NAME||'") like ''%BSI%''or '|| 'upper("' || COLUMN_NAME||'") like ''%APS%''or '|| 'upper("' || COLUMN_NAME||'") like ''%R614%''or '|| 'upper("' || COLUMN_NAME||'") like ''%R613%''or ' || 'upper("' || COLUMN_NAME||'") like ''%IMAGE SENSOR%'' '

         as sqlStrr, TABLE_NAME from user_tab_columns t where data_type = 'VARCHAR2' or data_type = 'CHAR';          

          

begin 

  

   --part1 loop

   for searchSQL_Cursor_Point_part1 in searchSQL_Cursor_part1 loop

     DBMS_OUTPUT.enable(1000000);

     sqlStr_part1 := searchSQL_Cursor_Point_part1.sqlStrr;

     out_string_in_part1:=sqlStr_part1;

     str_len_part1 := length(sqlStr_part1);

     loop_count_part1 := 0;

 

     execute immediate sqlStr_part1;

 

     

     

     OPEN   d_cursor_tab_part1   FOR   sqlStr_part1;

     LOOP  

              FETCH   d_cursor_tab_part1   INTO   idNum_part1;  

              EXIT   WHEN   d_cursor_tab_part1%NOTFOUND;

              

              if (idNum_part1>0)

                 then

                    WHILE loop_count_part1<str_len_part1 loop       

                          dbms_output.put_line( substr( out_string_in_part1, loop_count_part1 +1, 255 ) );       

                          loop_count_part1 := loop_count_part1 +255;    

                    end loop;

                    DBMS_OUTPUT.PUT_LINE('--------------------------------------Search for prodID find table:'||searchSQL_Cursor_Point_part1.TABLE_NAME||'Found:='||idNum_part1||'=exists!');

              end if;

              --   process   record  

     END   LOOP; 

    end loop; 

    

    --part2 loop

    for searchSQL_Cursor_Point_part2 in searchSQL_Cursor_part2 loop

     DBMS_OUTPUT.enable(1000000);

     sqlStr_part2 := searchSQL_Cursor_Point_part2.sqlStrr;

     out_string_in_part2:=sqlStr_part2;

     str_len_part2 := length(sqlStr_part2);

     loop_count_part2 := 0;

 

     execute immediate sqlStr_part2;

 

     

     

     OPEN   d_cursor_tab_part2   FOR   sqlStr_part2;

     LOOP  

              FETCH   d_cursor_tab_part2   INTO   idNum_part2;  

              EXIT   WHEN   d_cursor_tab_part2%NOTFOUND;

              

              if (idNum_part2>0)

                 then

                    WHILE loop_count_part2<str_len_part2 loop       

                          dbms_output.put_line( substr( out_string_in_part2, loop_count_part2 +1, 255 ) );       

                          loop_count_part2 := loop_count_part2 +255;    

                    end loop;

                    DBMS_OUTPUT.PUT_LINE('--------------------------------------Search for planID find table:'||searchSQL_Cursor_Point_part2.TABLE_NAME||'Found:='||idNum_part2||'=exists!');

              end if;

              --   process   record  

     END   LOOP; 

    end loop;

    

    --part3 loop

    for searchSQL_Cursor_Point_part3 in searchSQL_Cursor_part3 loop

     DBMS_OUTPUT.enable(1000000);

     sqlStr_part3 := searchSQL_Cursor_Point_part3.sqlStrr;

     out_string_in_part3:=sqlStr_part3;

     str_len_part3 := length(sqlStr_part3);

     loop_count_part3 := 0;

 

     execute immediate sqlStr_part3;

 

     

     

     OPEN   d_cursor_tab_part3   FOR   sqlStr_part3;

     LOOP  

              FETCH   d_cursor_tab_part3   INTO   idNum_part3;  

              EXIT   WHEN   d_cursor_tab_part3%NOTFOUND;

              

              if (idNum_part3>0)

                 then

                    WHILE loop_count_part3<str_len_part3 loop       

                          dbms_output.put_line( substr( out_string_in_part3, loop_count_part3 +1, 255 ) );       

                          loop_count_part3 := loop_count_part3 +255;    

                    end loop;

                    DBMS_OUTPUT.PUT_LINE('--------------------------------------Search for recipeID find table:'||searchSQL_Cursor_Point_part3.TABLE_NAME||'Found:='||idNum_part3||'=exists!');

              end if;

              --   process   record  

     END   LOOP; 

    end loop;

    

    --part4 loop

    for searchSQL_Cursor_Point_part4 in searchSQL_Cursor_part4 loop

     DBMS_OUTPUT.enable(1000000);

     sqlStr_part4 := searchSQL_Cursor_Point_part4.sqlStrr;

     out_string_in_part4:=sqlStr_part4;

     str_len_part4 := length(sqlStr_part4);

     loop_count_part4 := 0;

 

     execute immediate sqlStr_part4;

 

     

     

     OPEN   d_cursor_tab_part4   FOR   sqlStr_part4;

     LOOP  

              FETCH   d_cursor_tab_part4   INTO   idNum_part4;  

              EXIT   WHEN   d_cursor_tab_part4%NOTFOUND;

              

              if (idNum_part4>0)

                 then

                    WHILE loop_count_part4<str_len_part4 loop       

                          dbms_output.put_line( substr( out_string_in_part4, loop_count_part4 +1, 255 ) );       

                          loop_count_part4 := loop_count_part4 +255;    

                    end loop;

                    DBMS_OUTPUT.PUT_LINE('--------------------------------------Search for Logic or CIS keyword find table:'||searchSQL_Cursor_Point_part4.TABLE_NAME||'Found:='||idNum_part4||'=exists!');

              end if;

              --   process   record  

     END   LOOP; 

    end loop;

    

end;

  

 

分享到:
评论

相关推荐

    [开发工具] SQL Toolbelt 1.8.2.238

    SQL Multi Script - allows you to quickly and easily create complex scripts for SQL Server. SQL Refactor - helps the user to automatically format your SQL code and database objects that provides a ...

    Microsoft SQL Server 2016: A Beginner’s Guide, 6th Edition

    From there, you will learn how to write Transact-SQL statements, execute simple and complex database queries, handle system administration and security, and use the powerful analysis and BI tools....

    微软内部资料-SQL性能优化5

    With a multitable query, SQL Server must sometimes search a table multiple times so each page is scanned much more than once. Having useful indexes speeds up finding individual rows in a table, as ...

    基于自然语言处理技术的政务智能搜索引擎应用探索.pdf

    3. 政务智能搜索引擎系统(Government Affairs Intelligent Search Engine System):是一种基于自然语言处理技术的搜索引擎系统,可以将自然语言问题转换为SQL语言,从而使用户可以通过输入自然语言问题直接获得...

    Scalable Big Data Architecture(Apress,2015)

    concrete industry use cases that leverage complex distributed applications , which involve web applications, RESTful API, and high throughput of large amount of data stored in highly scalable No-SQL ...

    DbMouse Pro 5.6.3

    Quick search between tables, view, procedures, functions and columns. Generate SQL scripts from database objects. Query designer -Design SELECT, UPDATE, DELET and INSERT queries. Use data preview of...

    Scalable Big Data Architecture pdf 无水印 0分

    concrete industry use cases that leverage complex distributed applications , which involve web applications, RESTful API, and high throughput of large amount of data stored in highly scalable No-SQL ...

    Learning Apache Flink电子版

    Bringing the power of SQL to Flink, this book will then explore the Table API for querying and manipulating data. In the latter half of the book, readers will get to learn the remaining ecosystem of ...

    史上最全最详细的flink 中文教程(一千多页pdf).pdf

    Flink 还提供了 Table API 和 SQL 接口,用于关系型的数据操作和查询,这些 API 和 SQL 都建立在 DataStream API 和 DataSet API 之上。 Flink 中的分布式运行时环境涉及到多个组件,包括 JobManager 和 ...

    hadoop 开发规范

    - `REPLACE(s, search, replacement)`: 替换字符串 - **日期和时间函数** - `CURRENT_DATE()`: 获取当前日期 - `CURRENT_TIMESTAMP()`: 获取当前日期和时间 - `ADD_MONTHS(date, num)`: 增加月份 - `DATEDIFF...

    Cody‘s_Data_Cleaning_Techniques_Using_SAS_(Second_Edtion)

    - **Selecting Patients with Duplicate Observations by Using a Macro List and SQL**: Shows how to select patients with duplicate observations using a macro list and SQL. - **Identifying Subjects with ...

    Scalable Big Data Architecture

    concrete industry use cases that leverage complex distributed applications , which involve web applications, RESTful API, and high throughput of large amount of data stored in highly scalable No-SQL ...

    用户画像推荐系统springboot设计和实现 计算机专业.pdf

    The system employs the use of SQL functions like GROUP BY and HAVING for data processing within the database, leveraging the Spring Boot framework for backend development. The frontend is constructed...

    Rails.Angular.Postgres.and.Bootstrap.2nd.Edition

    You should have some experience with basic Rails concepts and a cursory understanding of JavaScript, CSS, and SQL, but by no means need to be an expert. You'll learn how to install Postgres on your ...

    Learning.Django.Web.Development

    Build two real-life based projects, one based on SQL and other based on NoSQL Best practices to code, debug, and deploy the Django web application Easy to follow instructions and real world examples ...

    sigmod2011全部论文(2)

    Efficient Auditing for Complex SQL Queries (Page 697) Raghav Kaushik (Microsoft Research) Ravi Ramamurthy (Microsoft Corporation) (Return to Top) Session 15: Data Mining Exact Indexing for Support...

    Building.Your.Next.Big.Thing.with.Google.Cloud.Platform.1484210050

    Host web services in Cloud Platform and orchestrate complex applications with ease. Architecture recipes using several Google Cloud Platform harmoniously Who this book is for Application Developers ...

    Beginning PHP 5.3

    - **Search and Replace:** Discussion on searching and replacing substrings within strings using regular expressions. - **Validation:** Techniques for validating input using regular expressions. **...

Global site tag (gtag.js) - Google Analytics