Using to_char to convert a timestamp into a string can produce different results in SQL and PL/SQL.
in SQL this returns 20240704062506.298731:
in PL/SQL this returns 20240704062506.298731
000:
The
documentation about the FF format model elements states:
"If you do not specify a digit, then Oracle Database uses the precision specified for the datetime data type or the data type's default precision."
Apparently this is not the same for SQL and PL/SQL - not by default anyway, your database may be set up differently.
If you do specify a digit, e.g. FF6 instead of FF, it works as expected.
I noticed this when I got a "ORA-06502: PL/SQL: numeric or value error: character string buffer too small" exception because of this.
As you can imagine, this took a while to pinpoint and debug...