declare
i int;
str varchar(10);
begin
i:=to_number(to_char(current_timestamp(3),'FF'));--error
str:=to_char(current_timestamp(3),'FF');--error
dbms_output.put_line(length(str));
dbms_output.put_line(i);
end;我的原意是想像sqlserver里的datepart('ms',getdate())一样获得3位的毫秒数
但是oracle里的to_char(sysdate,'')没有毫秒级的
上网找到了current_timestamp用 select 语句
to_number(to_char(current_timestamp(3),'FF'))
str:=to_char(current_timestamp(3),'FF')
都可以,但是放入表达式赋值就不行了pl/sql develop 提示错误:
Error: PLS-00306: wrong number or types of arguments in call to 'CURRENT_TIMESTAMP'请大家帮下我,谢谢了。
笔误
是to_char(current_timestamp(3),'FF')
I INT;
STR VARCHAR(10);
BEGIN
I := TO_NUMBER(TO_CHAR(CURRENT_TIMESTAMP(), 'FF')); --error
STR := TO_CHAR(CURRENT_TIMESTAMP( ), 'FF'); --error
DBMS_OUTPUT.PUT_LINE(LENGTH(STR));
DBMS_OUTPUT.PUT_LINE(I);
END;
/