3 ms·
Granted PL/SQL isn't as flexible as Perl or Python - it is not a fully-fledged application/system language (don't think it was meant to be that). Having said th
by noisy_boy 5y ago
Granted PL/SQL isn't as flexible as Perl or Python - it is not a fully-fledged application/system language (don't think it was meant to be that). Having said that, it does have ability to define types/reference column/row types, typical data structures like arrays/hashes/records(which are like structs), control-flow etc but the main point is that all of that runs within the database engine - this is useful when you must deal with complicated conditional logic but don't want to make those round-trips and handle all of it in one go. Generally traditional relational SQL is the preferred approach and it can cater to conditional scenarios as well but sometimes SQL statements combined with conditional logic written procedurally in one place is simpler to understand/more performant.
To be clear, I'm not advocating this over the traditional approach of programs running discrete queries and handling the logic themselves - just saying that the approach taken by PL/SQL has its merits.
- hnlmorg 5y agoI get the reason for PL/SQL and completely understand the advantages of stored procedures (I used to write code for Oracle Middleware so have had several years of experience in specifically this domain). I'm just answering the question of why the language sucks to write code for. I'm not suggesting PL/SQL should be a fully fledged scripting language either (neither Perl nor Python are systems languages by the way). I'm just saying the two paradigms PL/SQL aims to leverage don't combine well so the end result is always going to be ugly.
- masklinn 5y ago> Granted PL/SQL isn't as flexible as Perl or Python Which, incidentally, can be used as procedural languages in Postgres (as well as TCL) as part of the standard distribution. And there are third-party extensions for javascript, ruby, scheme, r, java, lua, … (though some of them may not be maintained anymore, the pg13 documentation doesn't list scheme and ruby anymore).