`

查询表和字段

阅读更多
CREATE OR REPLACE PROCEDURE FIND_STRING(I_STRING IN VARCHAR2,
                                        O_STRING OUT VARCHAR2) AS
  V_RESULT_STRING VARCHAR2(1000);
  V_COUNT         NUMBER;
BEGIN
  DBMS_OUTPUT.ENABLE (buffer_size=>null);
  FOR X IN (SELECT TABLE_NAME, COLUMN_NAME
              FROM /*USER_TAB_COLUMNS*/ all_tab_columns
             WHERE DATA_TYPE LIKE 'VARCHAR%' AND OWNER = 'WFM_SERVICEDESK_1') LOOP
    V_RESULT_STRING := 'SELECT COUNT(*) FROM WFM_SERVICEDESK_1.' || X.TABLE_NAME || ' WHERE "' ||
                       X.COLUMN_NAME || '" LIKE ''%' || I_STRING || '%''';
    EXECUTE IMMEDIATE V_RESULT_STRING INTO V_COUNT;
   
    IF V_COUNT > 0 THEN
      O_STRING := O_STRING || X.TABLE_NAME || '.' || X.COLUMN_NAME || ';';
      Dbms_Output.put_line('#######'||O_STRING);
    END IF;
  END LOOP;
END;
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics