Same algorithm in function and procedure so that one will be better?
Why is better to pl sql function calculates a value instead of the procedure?If I apply the same algorithm in function and procedure while one will perform better?
Siddharth Singh says:
Oracle documentationhttp://docs.Oracle.com/CD/B10500_01/AppDev.920/a96624/08_subs.htm
This:
Generally, you use a procedure to perform an action and a function to calculate a value.
Does not mean that the function are better to calculate a value, but you usually use functions to calculate a value.
Usually, a function is can be more useful if you plan to use in a query.
that is to say:
SELECT myfunc(col1) from mytable;
That you can't do with a procedure. Functions are also usually limited to the returning a single value, while procedures may have several OUTPUT parameters.
Kind regards.
Al
Published by: Alberto Faenza on 21 November 2012 15:31
Tags: Database
Similar Questions
-
How to move the functions and procedures of packages in a schema?
Hello
I have less than the needs for a work at home and my question is if anyone can point me in the right direction to find documentation that can help me solve below. Any information will be appreciated. Thank you.
Write procedures and functions (included or not in packets) as .txt or .sql scripts. Once they have been launched in Developer SQL they should, in addition, the functions and procedures of packages in the current schema. If the current schema contains only 2 packages, pac1 (p11, p12 procedures and functions f11, f12, f13) and pac2 (contains the p21 following procedures, p22, p23 and f21 and functions f21 (case of overload), running the scripts produce the following effects:)
- Procedures p11, p12, p21, p22, p23, and f11, f12 and f13 functions will be created in the current schema.
- PAC2 will contain 2 instances of the function of overload-f21; they will be kept in the package, without be created in the current schema. If all overloaded procedures/functions will be kept in their original packaging
- If pac1 contains variables, cursors, and public types, keep us only the details of the package (and remove the body); usually if the packages contain no overloaded functions or procedures the body will be removed and if no variable, cursors, types of public then we will remove the header.
- If in the triggers, procedures and functions we will call procedures/functions packages (procedures and functions moved into the current schema) they reference will need to be updated (via editing the body or recompilation) for example if pa1.p12 will be replaced with p12.
- Scripts must have numbers in the next series (01... n) and the characters that explain the content.
My only advice would be to remember that these are public forums and if YOU can find them, therefore cannot your instructors.
In addition, those are horrible procedure names and function
This mission seems to be around to overload the pl/sql objects and... prioritize a research on Oracle documentation around overhead and legacy
http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28371/adobjplsql.htm#i21148 -
Oracle form functions and procedures in the APEX, how?
I'm working to recreate in the APEX, already existing read only forms in Oracle Forms. Report features interactive APEX among other things, in fact worth as well as to target a different audience than utilizies versions of Oracle Form. Versions of Oracle Forms use a lot of pre and post query triggers, PLSQL functions.
In Oracle Forms that places, these functions can be found in the "Units of program" section of the form. A feature typical of this kind, based on a particular Mission ID route, collecting names of regular passengers, is shaped with a comma and a space after each of them, in a single string that is returned and displayed the list of passengers of a line.
I have all of this written code so I can move most of the main request of the Oracle form in an interactive report. These functions and triggers called in the form of the "Units of program" section of the Oracle form rather than stored in the database schema in a package, where they would go inside the APEX? Can I create a 'shortcut' in the APEX and call it from the interactive report "Source Région"? I can create the PLSQL function at the level of the region of the interactive report or page level? Or, my best bet creates a package that is stored in the database, all these functions and/or proecedures I might need the original form of Oracle?
Some advice would be greatly appreciated.RLBickham wrote:
I don't think I've been pretty clear in the description of the specific thing I want to do, simply, it does not reach the level of forms of conversion of the APEX. It is basically a problem of PLSQL function.I have an interactive report which is currently 90 percent of what I want however, each line, which represents a Mission may have several feet. Each arm has two places or ICAO codes attached to it. Based on the number of Mission, I want to loop through the array of leg, collect all the codes of ICAO for this Mission, put them together in 1 variable separated by a coma and add this variable to display the columns in this interactive report as the last column.
In Oracle Forms, I have a function registered in the database, which is called in the main query. Maybe I ask a question that does not need to be asked, but anyway my question is can I put this function currently in the database somewhere within the interactive report and somehow reference it via Http, or should I just stick with set of functions and procedures in the packages stored in the database and called the conventional way?
You could switch the function to the database and call it from the report query, but it sounds as if it were superfluous. In the report query using any form of Re: 4. How can I convert rows to columns? is appropriate for your version of the (unspecified) database.
-----
When you have a problem, you will get an answer faster, more efficient including information as much information as possible from the outset. This should include:
- Full version of APEX
- Complete operating system DB, version, edition, host
- Architecture of Web server (EPG, SST or APEX listener/host operating system)
- Browser (s) and version (s) used
- Theme
- Model (s)
- Region/section type (s) (particularly as to distinguish if a 'report' is a standard report, an interactive report, or indeed a 'update report' (i.e. a tabular presentation))
With APEX, we also had the chance to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproduce things is the best way to solve most of the questions, particularly those relating to the layout and Visual formatting. If you expect a detailed response it is appropriate that you take on an important part of the effort by getting as much as possible with an example of the problem on apex.oracle.com before asking for help on specific issues, then we can see firsthand.
-
Doubts in functions and procedures
Hello world
Can someone tell the exact differences between function and procedure?
My doubts are
1. If the procedure can return and is not necessary it must return a value (in other words, if we want to come back and is not as one can write procedure) then why do we need to function?
2. I tried to call a function that updates a table in the code, I got an error saying that the function does not use DML.
3. I want to know the combination that
procedure a. can call a function and vice versa?
b. function (which uses DML instructions) can be called from sql statement?
and if all other combinations are there let me know with reasons.
Thanks in advance,
VinayHave you looked at in the [reference Guide and the User Guide for PL/SQL | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm] already?
http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/subprograms.htm#i4075
http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/subprograms.htm#i4074(1) for example: functions can be used in SQL, procedures cannot.
(2) generally, the methods are used for DML.
It depends on how you are performing the function:hoek&XE> create table t as select 1 col from dual; Tabel is aangemaakt. hoek&XE> create or replace function f 2 return number 3 as 4 num number; 5 begin 6 update t 7 set col = 2; 8 num := sql%rowcount; 9 return(num); 10 end; 11 / Functie is aangemaakt. hoek&XE> select f from dual; select f from dual * FOUT in regel 1: .ORA-14551: cannot perform a DML operation inside a query ORA-06512: at "HOEK.F", line 6 hoek&XE> hoek&XE> var num number hoek&XE> exec :num := f; PL/SQL-procedure is geslaagd. hoek&XE> print :num NUM ---------- 1 hoek&XE> select * from t; COL ---------- 2
Yes 3A)
No. 3B), see 2. -
I have some important files on my desktop and the fear that one of my employees has copied that data on its USB, is it possible to check if there was such a transfer, such as a history of copy, or something?
In my view, the above question sums up all, I'm not that computer savvy, so please give detail instructions, and if there is way to secure these files are copied or sent by electronic mail, please let me know, if I can avoid these problems in the future. Thank you.
You may not know a posteriori if this transfer took place. To prevent it in the future, lock your device by pressing the Windows key + L before you leave your office and keep your secret password.
-
Hello, my name is Todd, I recently downloaded PS CC 2014. I've used PS for decades. The crop tool will show the bar of progression, and to 25%, that it will stop completely, even on VERY small 72 dpi images. What can I do? Thank you!
Double check all settings in the crop tool and make sure that you are not say things to create an image of HUGE due to your settings.
-
Recently, I updated my Oracle SQL Developer to the latest version (see below) and now when I try to run the function or procedure of the IDE, I had an alert with the error: "ORA-00904:"OBJECT_ID": invalid identifier." Code provider 904 ". Previous version of IDE works pretty well. What is the problem?
Oracle SQL Developer 4.1.0.19
Version 4.1.0.19
Build a HAND - 19.07
It seems that OBJECT_ID added to ALL_PROCEDURES for the 10g DB version, but after the version you have (10.2.0.1.0). I don't have a link to the documentation specific to hand Oracle, but see the last comment by Steven Feuerstein in the next blog...
PL/SQL challenge: ALL_PROCEDURES changes over version (5980)
Typically when generation SQL for a particular version of the DB with SQL Developer, only major (10) and (more rarely) secondary numbers (2) gets checked, if your problem is one of those borderline cases that are easy to miss and less likely to get fixed. Whenever a customer has a specific need to use an older version, Oracle expects usually only the last set of patch (for example, 10.2.0.5) would be used.
-
So I'm new to Muse, and my Adobe cloud has 2 different programs of Muse... How do I know what is the best new version?
You must program (Muse CC 2014.2) has a black background when working on it... It looks like other programs such as Photoshop Adobe.
The other is color of light (Muse CC) very similar to the black color Muse on the functions...
One of the difference that I see it is that the color of the light Muse has a few widgets in the library, while the black Muse seems to have an empty library
Then... Why are there 2 different programs of Muse in my cloud of Adobe?
Hello
The latest version of Muse is 2014.2, so you need to uninstall another version of Muse manually.
about library items, you can add items to your library manually, as described in this article
Adobe help Muse | Organize and reuse design elements using the library panel
Please let me know if you have any other question.
-
Difference between function and procedure
Hi all
My doubt is that the procedure can be used to return multiple values with OUT parameter and function can also be used to do the same if necessary to return multiple values with OUT parameter.
So with this point of view, which is maybe the difference between these types of the two objects. and obviously if necessary to choose one of these two, we'll go to procedure, why not function?
What is perhaps the reason for this?
Thanks in advance.
Kind regards
Vipin Kumar RaiNitesh. wrote:
The main difference I between stored procedure and function of stored procedures compiled only once and can be called again and again without be compiled every time, this improves performance and saves time, of other functions to compile every time as is called...Would you care to show what you mean. To the best of my knowledge this last statement is not correct.
The main difference for procedures and functions it program design.
A procedure should be used for something that is running a process, where nothing is required to be returned.
A function should be used when a value is required to be returned.Yes, the procedures can have OUT parameters (as can functions) but that is generally considered bad practice. If you have values be returned, you must use a function with an appropriate return type (structured type if necessary) so that all the requirements of data is returned via the return value. IMO the only acceptable practice to use variables is when you use a variable IN OUT for something in a procedure for this element which is manipulated by the procedure, so for example you'd 'ManipulateData (myData); as a procedure rather than "myData: = ManipulateData (myData);" in function, where the latter would be using resources of additional memory (copies of data) in most cases.
-
all functions and procedures works this way? (dbms_lock)
Hi guys,.
throughout, I thought...
Start
dbms_output.put_line ('a');
dbms_output.put_line ('b');
end;
When built, I thought of the oracle pl/sql interpreter read the source line by line
the steps below
-seen dbms_output.put_line ('a'), print a
-seen dbms_output.put_line ('b'); ... print b
That's all...
but after using dbms_lock, I realize its abit differs from the way I thought...
Start
dbms_output.put_line ('a');
DBMS_LOCK. Sleep (10);
dbms_output.put_line ('b');
end;
/
I'd actually wait for 10 seconds before I see the result 'a' and 'b '...
so it seems to me
the interpreter would be
(1) see dbms_output.put_line ('a'); -It's going to print 'a' but which is still
(2) see dbms_lock.sleep (10); -sleep for 10 sec...
(3) see dmbS_output.put_line ('b') - you know it's going to print 'b', but which is still
(4) see at the end; -ok print 'a' and 'b '.
so, somehow, to return the result or printing... He seems to have done until the END of the block/procedure/function instead of intepreting line-by-line and runs it.
However, for dbms_lock.sleep (10), its seems to be interpreted and executed immediately in the middle of the block.
so can I conclude that
for his return / displaying the result, it is done at the end of the block
for others, it is done during the block
Am I wrong?
Best regards
NoobThe thought is always a good thing, but read the docs is also useful. PL/SQL unit is still running on the side of server database and always as a unit. written dbms_output.put_line('A') simply has to a buffer and PL/SQL unit continues to run. any unit buffer has all the lines written. Now the client tool, SQL * Plus, in your case, can read the contents of the buffer and display it. SQL * more is it based on the command SET SERVEROUTPUT on / off. I hope now you understand that DBMS_OUTPUT does not provide an interface to display the customer exit, but rather store it in a buffer.
SY.
-
My computer is to launch my a note that I have another computer on my network using the IP, I do not understand.
I have a stereo Kardon Karmon, a drive Sony DVD with WIFI and a printer with WIFI. 2 mobile phones and that's it. All meant to share my home network. The dvd player will not acquire the web well that directly connect to the modem. I did not any changes for several months.
RA
What is wifi has an IP address. This situation occurs generally if the INVESTIGATION period have the value static or more likely in your case that the whole of the network (including the router) need to be restarted. Usually if you restart all devices at the same time it will erase it
-
integer_tbl function and procedure
Hi all
I have a function that uses ref cursor and integer table.
FUNCTION gp_long (ID IN integer_tbl, p_start_date IN VARCHAR2, p_end_date IN VARCHAR2)
RETURN gp_long_cur;
I understand gp_long_cur is a ref cursor, but not able to understand ID IN integer_tbl.
If I want to pass parameters in ID integer_tbl how to do this.
Could someone direct me to a link.
Thanks in advance
Rgds
SaazIt depends on how the definition of the integer_tbl.
If it is defined asTYPE integer_tbl IS TABLE OF INTEGER;
Then, you can call your function as for example.
DECLARE c SYS_REFCURSOR; BEGIN c := gp_long (integer_tbl(1, 2, 42), DATE '2011-01-01', SYSDATE); ... END;
URS
-
TOP N function and OTHER values that are not in the TOP clause
Hello... It's easier to explain with examples. Assume there is a table with 5 records. You will have to order them and use a TOP N feature to display 3 items albums. So far, it's easy!
But I need to show all others 2 records like the OTHERS, and have all the summaries. It would be something like this:
The flattened table:
Code Value
And I need to show it in responses like this:
1 2,000
2 1,500
3 1,000
4 800
5 600Name Value
How can I show OTHERS for these values that will be excluded when I create a TOP N function?
Number1 2,000
Number2 1,500
Number3 1,000
OTHERS 1,400
Thanks in advanceHello
Visit this link,
http://obiee101.blogspot.com/2009/08/OBIEE-TopN-versus-rest.html
Thank you
Vino -
execution of function and procedure
Hi all
I question in the execution of the procedure and run oracle database feature.
I want to know what is faster in execution procedure or function.
can I see the timeframes of proceedings and select request
I want to see one time not CPU cost or anything else.
I'm waiting for your answers...There is no difference in cost between if something is a function, or a procedure.
The decision-making process must reflect usage only. For example you can not use a procedure in SQL.
If you want to break things down to focus more on tracing 10046 and 10053.
See time only is roughly equivalent to cut all your fingers to see how something is your thumb.
Timing is only a small part of what you should look at. -
Passage of tables through multiple functions and PL/SQL procedures
I am now a great application of PL/SQL. There is a main procedure which is initially called who subsequently passes information to other PL/SQL functions and procedures. Ultimately an error code and the string is passed to PUT_LINE so it can be displayed. I want to be able to do is to have a table that stores an error code and a string for every error it then go through each of the procedures and functions. This would mean passing these codes and the strings of a function to a function within the pl/sql application. What would be the best way to implement this and is it possible to move heavy or folders to other PL/SQL functions? Thank you.Here is a simulation->
satyaki> satyaki>select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod PL/SQL Release 10.2.0.3.0 - Production CORE 10.2.0.3.0 Production TNS for 32-bit Windows: Version 10.2.0.3.0 - Production NLSRTL Version 10.2.0.3.0 - Production Elapsed: 00:00:00.20 satyaki> satyaki> satyaki>create or replace type n_array is table of number; 2 / Type created. Elapsed: 00:00:07.10 satyaki> satyaki>CREATE OR REPLACE PROCEDURE Get_Array(array_in IN n_array, 2 array_out OUT n_array) 3 IS 4 BEGIN 5 array_out := n_array(); 6 FOR i IN 1..array_in.count 7 LOOP 8 array_out.extend; 9 array_out(i) := array_in(i) * 2; 10 END LOOP; 11 END Get_Array; 12 / Procedure created. Elapsed: 00:00:00.89 satyaki> satyaki> satyaki>Create or Replace Procedure Set_Array(myArray IN n_array) 2 is 3 i number(10); 4 rec emp%rowtype; 5 w n_array:=n_array(1200,3200); 6 bucket n_array := n_array(); 7 Begin 8 Get_Array(w,bucket); 9 10 for i in 1..myArray.count 11 loop 12 select * 13 into rec 14 from emp 15 where empno = myArray(i); 16 dbms_output.put_line('Employee No:'||rec.empno||' Name:'||rec.ename); 17 for j in 1..bucket.count 18 loop 19 dbms_output.put_line('Commission Sub Type: '||bucket(j)); 20 end loop; 21 end loop; 22 End Set_Array; 23 / Procedure created. Elapsed: 00:00:01.33 satyaki> satyaki> satyaki>select * from emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 9999 SATYAKI SLS 7698 02-NOV-08 55000 3455 10 7777 SOURAV SLS 14-SEP-08 45000 3400 10 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 4450 10 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7839 KING PRESIDENT 17-NOV-81 7000 10 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7900 JAMES CLERK 7698 03-DEC-81 950 30 7902 FORD ANALYST 7566 03-DEC-81 3000 20 13 rows selected. Elapsed: 00:00:00.28 satyaki> satyaki>declare 2 v n_array:=n_array(9999,7777); 3 begin 4 Set_Array(v); 5 end; 6 / Employee No:9999 Name:SATYAKI Commission Sub Type: 2400 Commission Sub Type: 6400 Employee No:7777 Name:SOURAV Commission Sub Type: 2400 Commission Sub Type: 6400 PL/SQL procedure successfully completed. Elapsed: 00:00:00.15 satyaki> satyaki>
Kind regards.
LOULOU.
Maybe you are looking for
-
Repair a Windows XP on a laptop
How can I repair an installation of windows XP with the recovery cd without format the whole drive?ConcerningPeter tarek
-
Hello Does anyone know how to solve the problem with the screensaver kick watching a movie using Windows Media Player (WMP), even though I unchecked the option to "allow the screensaver during playback" in WMP? I found that if I start Windows Media C
-
How do you get a new load adapter Apple pencil?
I've already lost my charge adapter Apple pencil! Arghh! It is so small and slippery, it must have become right out of my case. Is it possible to buy a new one? I can't even find it on apple's site.
-
Envy printer 4250: driver install freezes at verification of network environment
I have a brand new 4250 want and he is suspended on 2 different computers at the same point "audit of network environment." I can ping IP address of the printer if it is connected ok (wireless). I tried runnig the Setup from the CD and it hangs to th
-
Get ink system failure-code-Oxc18a0201 error message when you try to print from C7180 printer
Original title: C7180 printer all in one I'm unable to print I receive ink system failure-code-Oxc18a0201. HELP IF YOU CAN THANK YOU FOR YOUR TIME.