po 9. 11. 2020 v 14:59 odesílatel 德哥 <digoal@126.com> napsal:
The customer originally used Oracle. Oracle supports using the table name in the variable name instead, while using the rowType corresponding to the table name of the variable name.
However, in PostgreSQL with the variable % RowType, compilation can pass if the variable has the same name as an existing table. The table name corresponding to the value of the variable name is used as rowType.
However, when the variable name cannot find the table name with the same name, the compilation error is directly reported, which is inconsistent with Oracle.
I think this is a bug, the reason has nothing to do with Oracle, but the execution behavior is biased, either do not replace the value of the variable during the execution, but directly use the table name corresponding to the variable name.
I looking to Oracle documentation, and %rowtype can be used only for tables and cursor variables. Unfortunately Postgres cannot support cursor variables there - Postgres requires known structure, and it is not defined in this moment. This syntax has more sense in Oracle, because it is much more static - and the query structure is fixed. PL/pgSQL cannot to support this feature. Instead you can use RECORD type. Although the PL/SQL and PL/pgSQL looks simillary, the implementation is significantly different - the work with cursors is very different. PL/pgSQL does not guarantee full compatibility with PL/SQL - and some features cannot be implemented there.