2020/11/30

DBMS_ASSERT

DBMS_ASSERT.ENQUOTE_LITERAL => 回傳字串前後加上 ' 

DBMS_ASSERT.ENQUOTE_NAME => 回傳字串前後加上 " 

DBMS_ASSERT.SQL_OBJECT_NAME => 尋找是否存在符合的物件 

 select table_name, dbms_assert.enquote_literal(table_name) , dbms_assert.enquote_name(table_name) from all_tables where rownum <= 1 

 

DECLARE
  vobject1 VARCHAR2(80) := 'dual';
  vobject2 VARCHAR2(80) := 'dualx';
  vresult1 VARCHAR(80);
  vresult2 VARCHAR(80);
BEGIN
  BEGIN
    vresult1 := dbms_assert.sql_object_name(vobject1);
    IF vresult1 IS NOT NULL THEN
      dbms_output.put_line('Found Object:' || vresult1);
    END IF;
  EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line(dbms_utility.format_error_stack);
  END;

  BEGIN
    vresult2 := dbms_assert.sql_object_name(vobject2);
  EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line(dbms_utility.format_error_stack);
  END;
END;

沒有留言: