[ Pobierz całość w formacie PDF ]
.group_name%TYPE;BEGINif v_group_id is nullthen return '';end if;-- note the usage of INTO below, which pulls a column-- from the table into a local variableselect group_name into v_group_namefrom user_groupswhere group_id = v_group_id;return v_group_name;END;/show errorsChoosing between PL/SQL and JavaHow to choose between PL/SQL and Java? Easy: you don't get to choose.In lots of important places, e.g., triggers, Oracle forces you tospecify blocks of PL/SQL.So you have to learn at least the rudimentsof PL/SQL.If you're going to build major packages, Java is probably abetter long-term choice.ReferencelOverview: Oracle8 Server Application Developer's Guide, "UsingProcedures and Packages"atlPL/SQL User's Guide and Reference atlJava Stored Procedures Developer's Guide atNext:Reader's CommentsRe: Choosing Between PL/SQL and Java: In my experience, the "original" feature (in this case, PL/SQL as an embedded language) always works better, is better understood, documented, and supported, and has more people available who can fix it for you, than the "added later" feature (Java).So, I would think carefully (and ask people who've used both) before jumping onto the New & Improved bandwagon.-- Thomas Hundt, May 30, 2000Re: Stored procedures.IMO it's a good idea to do transaction control (BEGIN TRANSACTION/ROLLBACK/COMMIT) solely in stored procedures, and not in a client program.The situation you want to avoid at all costs is a client opening a transaction, and then crashing -- with your database holding a transaction open (and pages locked) until (some time later) the operating system figures out that the TCP/IP connection to the client has closed, and tells the database about it (which then rolls back the transaction).This is more of an issue with PC clients (and users hitting Ctrl-Alt-Del) as opposed to a webserver program.Also, it should be mentioned that putting SQL into stored procedures makes it run faster, as it can be "precompiled" (some of the interpretation steps done ahead of time, such as parsing and generating a query plan).This is true of Sybase and (I would think) of Oracle etc.as well.-- Thomas Hundt, May 30, 2000|
[ Pobierz całość w formacie PDF ]