-2

during development, there are many codes/SQLs can be re-used, which is used to implement some kind of business logical. To avoid re-inventing the wheel, I propose to create a package, which contains these code/SQL/functions; then, any new code can call the functions/codes in this package and no need to write these frequently used codes again.

I wonder if the design is a decent solution for the scenario: avoid re-inventing wheel and decrease the lines of the code

William Robertson
  • 15,273
  • 4
  • 38
  • 44
fred wu
  • 55
  • 6
  • 1
    Sorry, but - what is the question here? – Littlefoot Nov 02 '22 at 08:05
  • Well yes, writing software is how we store processing logic for reuse. In PL/SQL, code modules are implemented as packages. If you are asking whether it’s a good idea to develop software to avoid repeating manual processing steps, I’d say yes, it is. – William Robertson Jan 23 '23 at 20:43

1 Answers1

0

PL/SQL is no different than any other programming language as for code reusability. If you can reuse - create apropritate function that can be called later.

In PL/SQL you just need to know how to create functions in case if there is huge data amounts in return. So you either need to use temporary tables or custom table types or create views or materialized views.

Martins
  • 39
  • 5
  • thanks for your answer! In Oracle PL/SQL, there is compile dependencies , which is my big concern; as for your concern of huge data amount, I can use cursor as the return of this function, no need to use temp table. – fred wu Nov 02 '22 at 12:36
  • It's like in any language that compiles - if it compiles - it works ;) I have worked projects that have 40+ packages in Oracle. So you need rules how to organize them. – Martins Nov 02 '22 at 15:39