???SQL?????????
???????????? ???????[ 2013/4/17 9:57:26 ] ????????
????7?????????????????????????????
?????????????У?????????????????δ??????????????????????????????????????????????????????????????????????
DECLARE
sql_stat VARCHAR2(100);
v_date DATE :=&dt; --???????????????δ???????
v_empno NUMBER :=7900;
v_ename tb_emp.ename%TYPE;
v_sal tb_emp.sal%TYPE;
BEGIN
sql_stat := 'SELECT ename??sal FROM tb_emp WHERE hiredate=:v_date'; --??????λ??:v_date???б?????
EXECUTE IMMEDIATE sql_stat
INTO v_ename??v_sal
USING v_date;
DBMS_OUTPUT.PUT_LINE('Employee Name '||v_ename||'?? sal is '||v_sal);
END;
Enter value for dt: 1981-05-01 --?????????????????δ?????????????????????
old 3: v_date DATE :=&dt;
new 3: v_date DATE :=1981-05-01;
v_date DATE :=1981-05-01;
*
ERROR at line 3:
ORA-06550: line 3?? column 20:
PLS-00382: expression is of wrong type
ORA-06550: line 3?? column 13:
PL/SQL: Item ignored
ORA-06550: line 13?? column 9:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 11?? column 3:
PL/SQL: Statement ignored
??????????
?????????????????????
flasher@ORCL> /
Enter value for dt: '1981-05-01'
old 3: v_date DATE :=&dt;
new 3: v_date DATE :='1981-05-01';
Employee Name BLAKE?? sal is 2850
PL/SQL procedure successfully completed.
???????????
?????????????????????????????
v_date DATE :='&dt';
?????????????????????????????????????????
v_date DATE :=TO_DATE('&dt'??'DD-MON-RR');
?????????????????У????SQL?????e?????????????????????????????????????????????????
DECLARE
sql_stat VARCHAR2(100);
v_date DATE :='&dt';
v_empno NUMBER :=7900;
v_ename tb_emp.ename%TYPE;
v_sal tb_emp.sal%TYPE;
BEGIN
sql_stat := 'SELECT ename??sal FROM tb_emp WHERE hiredate=' || chr(39) ||v_date|| chr(39);--chr(39)?????????
EXECUTE IMMEDIATE sql_stat
INTO v_ename??v_sal;
DBMS_OUTPUT.PUT_LINE('Employee Name '||v_ename||'?? sal is '||v_sal);
END;
Enter value for dt: 1981-05-01
old 3: v_date DATE :='&dt';
new 3: v_date DATE :='1981-05-01';
SELECT ename??sal FROM tb_emp WHERE hiredate='1981-05-01'
Employee Name BLAKE?? sal is 2850
PL/SQL procedure successfully completed.
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11