????2?????????schema?????????????

?????????????У????SQL?????????????????????????????????

DECLARE
         sql_stmt VARCHAR2(100);
         v_count  NUMBER;
       BEGIN
         EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM :tb_name'
           INTO v_count;
         DBMS_OUTPUT.PUT_LINE('The table record  is  ' || v_count);
       END;
 
       DECLARE
       *
       ERROR at line 1:
       ORA-00903: invalid table name
       ORA-06512: at line 5

?????????

DECLARE
             sql_stmt VARCHAR2(100);
             v_tablename VARCHAR2(30) :='scott.emp';   --????????????????
             v_count  NUMBER;
           BEGIN
             EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || v_tablename   --???|| ???????
              INTO v_count;
             DBMS_OUTPUT.PUT_LINE('The table record is  ' || v_count);
           END;
        
           The temp table count is  14

????3?????SQL?鯔????÷?????(;)

?????????????У????SQL??????????????????????????????

DECLARE
         sql_stmt VARCHAR2(100);
         --v_tablename VARCHAR2(30) :='scott.emp';
         v_count  NUMBER;
       BEGIN
         EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM tb_emp;'   --?????????????????
           INTO v_count;
         DBMS_OUTPUT.PUT_LINE('The temp table count is  ' || v_count);
       END;
 
       DECLARE
       *
       ERROR at line 1:
       ORA-00911: invalid character
       ORA-06512: at line 6

?????????

?????????SQL????β????

????4?????PL/SQL?鯔???????б?????????飬??????β?????????÷??(;)

DECLARE
         plsql_block VARCHAR2(300);
       BEGIN
         plsql_block := 'DECLARE ' ||
                      ' v_date DATE; ' ||
                      ' BEGIN ' ||
                        ' SELECT SYSDATE INTO v_date FROM DUAL; ' ||
                        ' DBMS_OUTPUT.PUT_LINE (TO_CHAR(v_date??''YYYY-MM-DD''));' ||
                      'END;
                        /';   --????????/????y??????
         EXECUTE IMMEDIATE plsql_block;
       END;
        
       DECLARE
       *
       ERROR at line 1:
       ORA-06550: line 3?? column 2:
       PLS-00103: Encountered the symbol "/" The symbol "/" was ignored.
       ORA-06512: at line 13

?????????

?????????PL/SQL ??β????б??