procedure check_startDate_is_grower_than_last_foo(startDate IN OUT DATE) as
last_foo_tsp DATE;
begin
select max(version_tsp) into last_foo_tsp from foo;
if startDate <= last_foo_tsp then
if trunc(startDate) = trunc(last_foo_tsp) then
startDate := (last_foo_tsp + 1/86400); -- +1 seg
else
raise_application_error(-20001, 'Blabla');
end if;
end if;
end;
我收到一个错误:
PLS-00363: expression 'STARTDATE' cannot be used as an assignment target
我做错什么了?
发布于 2022-03-14 05:35:34
我不知道你做错了什么,因为-这对我有用。
SQL> alter session set nls_date_format = 'dd.mm.yyyy hh24:mi:ss';
Session altered.
SQL> select * from foo;
VERSION_TSP
-------------------
15.02.2022 00:00:00
SQL> create or replace
2 procedure p_check (startDate IN OUT DATE) as
3 last_foo_tsp DATE;
4 begin
5 select max(version_tsp) into last_foo_tsp from foo;
6 if startDate <= last_foo_tsp then
7 if trunc(startDate) = trunc(last_foo_tsp) then
8 startDate := (last_foo_tsp + 1/86400); -- +1 seg
9 else
10 raise_application_error(-20001, 'Blabla');
11 end if;
12 end if;
13 end;
14 /
Procedure created.
测试:
SQL> set serveroutput on
SQL> declare
2 l_datum date := date '2022-02-15';
3 begin
4 p_check (l_datum);
5 dbms_output.put_line('result = ' || l_datum);
6 end;
7 /
result = 15.02.2022 00:00:01
PL/SQL procedure successfully completed.
SQL>
https://stackoverflow.com/questions/71468558
复制