一段代码看懂日期格式在PL/SQL中的作用
DECLARE
l_Cursor_Num INTEGER;
l_Date DATE;
l_Date_Char VARCHAR2(20);
BEGIN
EXECUTEIMMEDIATE q"?ALTER SESSION SET NLS_DATE_FORMAT = "YYYY-MM-DD"?";
l_Date :="2020-06-17";-- PLSQL中的隐式转换:字符->日期
l_Date_Char :=SYSDATE;-- PLSQL中的隐式转换:日期->字符
l_Cursor_Num := Dbms_Sql.Open_Cursor();
Dbms_Sql.Parse(l_Cursor_Num,
"SELECT :T_SELECT_DATE D FROM DUAL WHERE TRUNC(SYSDATE) = :T_WHERE_DATE",-- SQL 条件中的隐式转换:字符->日期
Dbms_Sql.Native);
Dbms_Sql.Bind_Variable(l_Cursor_Num,":T_SELECT_DATE", l_Date);
Dbms_Sql.Bind_Variable(l_Cursor_Num,":T_WHERE_DATE", l_Date_Char);
Dbms_Sql.Define_Column(l_Cursor_Num,1, l_Date_Char,20);
IF Dbms_Sql.Execute_And_Fetch(l_Cursor_Num)>0THEN
Dbms_Sql.Column_Value(l_Cursor_Num,1, l_Date_Char);-- 游标提取的转换:日期->字符
Dbms_Output.Put_Line(l_Date_Char);
ENDIF;
Dbms_Sql.Close_Cursor(l_Cursor_Num);
END;
以上是 一段代码看懂日期格式在PL/SQL中的作用 的全部内容, 来源链接: utcz.com/z/534201.html