What is the recommended practice of writing reusable code procedures?

I want to check with some of the more experienced Oracle developers here about best practices for backend development.

I write many packages that print data in XML format and are used by HTTP services.

For this purpose, I scan cursors and print data using htp.p.

eg.

for i in c_my_cursor loop htp.p('<element>', i.data_field, '</element>'); end loop; 

Now I heard that cursors are bad for performance (is that true?). In addition, there are similar cursors used in different packages, which, in my opinion, it is better to switch to functions from the point of view of service.

But what can I return from a function? I do not think the cursor will work. What are you using?

+4
source share
1 answer

Cursors are not inherently bad. The bad news is that you are processing the Row By Agonizing Row, and not using the specified processing. SQL is all about The Joy Of Sets. The problem with cursors is that PL / SQL developers often come to them automatically; this often leads us to the RBAR route when a direct SQL statement will be more efficient.

Functions are no more effective than procedures. Choose functions or procedures that match what you are doing or doing something.

In your case, I would be wondering if the inline XML functionality would be inline in your specific case. Partly it depends on which version of Oracle you are using, but almost any version, since 8i will work with the specific example that you published. Find out more .

+10
source

All Articles