Procedure DBMS_DATAPUMP to function
HelloI created a procedure that works quite well as follows:
CREATE OR REPLACE PROCEDURE proc_expdp(p_schema_name VARCHAR2, p_table_name VARCHAR2)
IS
v_handle NUMBER;
v_jobname VARCHAR2 (100);
v_dirname VARCHAR2 (100);
v_filename VARCHAR2 (100);
BEGIN
v_filename := to_char(sysdate,'YYYYMMDDHH24MISS')||'.DMP';
v_jobname := v_filename||'_EXPDP';
v_dirname := 'DMPDIR';
v_handle := dbms_datapump.open(operation => 'EXPORT', job_mode => 'TABLE', job_name => v_jobname);
dbms_datapump.add_file(handle => v_handle, filename => v_filename, directory => v_dirname, filetype => 1);
dbms_datapump.add_file(handle => v_handle, filename => v_filename||'_EXPDP'||'.LOG', directory => v_dirname, filetype => 3);
dbms_datapump.metadata_filter (handle => v_handle, name => 'SCHEMA_EXPR', value => 'IN ('||p_schema_name||')');
dbms_datapump.metadata_filter (handle => v_handle, name => 'NAME_EXPR', value => 'IN ('||p_table_name||')');
-- dbms_datapump.data_filter (handle => v_handle, name => 'PARTITION_LIST', value => '''ODS_SLS_ITEM_DETAIL_20090101'', ''ODS_SLS_ITEM_DETAIL_20090102'', more here ''ODS_SLS_ITEM_DETAIL_20090227'', ''ODS_SLS_ITEM_DETAIL_20090228''', table_name => 'ODS_SLS_ITEM_DETAIL', schema_name => 'ODSPROD');
dbms_datapump.start_job(v_handle);
dbms_datapump.detach(v_handle);
END;
... and I use the following code from PL/SQL to execute, which works very well also.BEGIN
proc_expdp('''HR''','''DEPARTMENTS'',''EMPLOYEES''');
END;
I needed this as a function, so I corrected the following text:CREATE OR REPLACE FUNCTION system.func_expdp(p_schema_name VARCHAR2, p_table_name VARCHAR2) RETURN VARCHAR2
IS
v_handle NUMBER;
v_jobname VARCHAR2 (100);
v_dirname VARCHAR2 (100);
v_filename VARCHAR2 (100);
BEGIN
v_filename := to_char(sysdate,'YYYYMMDDHH24MISS')||'.DMP';
v_jobname := v_filename||'_EXPDP';
v_dirname := 'DMPDIR';
v_handle := dbms_datapump.open(operation => 'EXPORT', job_mode => 'TABLE', job_name => v_jobname);
dbms_datapump.add_file(handle => v_handle, filename => v_filename, directory => v_dirname, filetype => 1);
dbms_datapump.add_file(handle => v_handle, filename => v_filename||'_EXPDP'||'.LOG', directory => v_dirname, filetype => 3);
dbms_datapump.metadata_filter (handle => v_handle, name => 'SCHEMA_EXPR', value => 'IN ('||p_schema_name||')');
dbms_datapump.metadata_filter (handle => v_handle, name => 'NAME_EXPR', value => 'IN ('||p_table_name||')');
-- dbms_datapump.data_filter (handle => v_handle, name => 'PARTITION_LIST', value => '''ODS_SLS_ITEM_DETAIL_20090101'', ''ODS_SLS_ITEM_DETAIL_20090102'', more here ''ODS_SLS_ITEM_DETAIL_20090227'', ''ODS_SLS_ITEM_DETAIL_20090228''', table_name => 'ODS_SLS_ITEM_DETAIL', schema_name => 'ODSPROD');
dbms_datapump.start_job(v_handle);
dbms_datapump.detach(v_handle);
return v_filename;
END func_expdp;
... and I wouldn't be able to run it with a select statement. Well, this part is the problem. When I try to run as a select statementselect system.func_expdp('''HR''','''DEPARTMENTS'',''EMPLOYEES''') from dual;
I get the following error:An error was encountered performing the requested operation:
ORA-31626:job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 911
ORA-06512: at "SYSTEM.FUNC_EXPDP", line 4356
ORA-06512: at "SYSTEM.FUNC_EXPDP", line 11
31626. 00000 - "job does not exist"
*Cause: An invalid reference to a job which is no longer executing, is no executing on the instance where the operation was attempted, or that does not have a valid Master Table. Refer to any following error messages for clarification.
*Action: Start a new job, or attach to an existing job that has a valid Master Table.
What I would do... ?Thanks for your time
PS: I use 10g Express Edition. Lately I have created and deleted several datapump jobs, but I think it's irrelevant since my procedure works very well.
You cannot use the function inside a SELECT statement because dbms_datapump.open does an implicit validation. However, you can use the function within a pl/sql as block:
declare
l_filename varchar2(100);
begin
l_filename := system.func_expdp('''HR''','''DEPARTMENTS'',''EMPLOYEES''')
end;
/
Also, please avoid creating all objects in the SYS and SYSTEM schemas.
Tags: Database
Similar Questions
-
Can we call the procedure inside the function?
Hello
Can we call the procedure inside the function?
Thank you
Brij845712 wrote:
Can we call the procedure inside the function?
Strange question to ask.
Yes. This is the standard behavior in most (if not all) procedural and object oriented languages.
A procedure, function or a method is a unit of code.
You can call one of the other units. Units can call themselves (recursion). Technically, this means simply by pushing the battery current (to save the stack of the current device memory), the call to the new unit and then popping up battery when control is returned to the unity of the appellant.
There are very few exceptions to this. The only one that comes to mind programming languages I've used through the years, is natural 1 - could not call a new unit of code to replace the existing one in memory. If no call-and-return was possible.
Exactly what did you ask this question? Some newcomers to confused Oracle SQL and PL/SQL - two different languages aside server. And then also mistaken for PL/SQL client command vocabulary of SQL * more.
You will need to make sure that understand the basics of programming (applies to most current programming languages) and Oracle concepts.
-
Can we put procedure in a function?
Can we put procedure in a function?Hello
If you mant to say have a procedural code in a function, you can do it, you can have a block of code in a function or if you want to call a procedure in a function you can call it.
Have you tried to create a Package?http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/packages.htm
Thank you
-
Call a procedure and a function over a db link
I feel a few errors with the following and would be very happy in the view of some experts here.
My use case is to insert records into a table via a database link. Inserted records will be interviewed for a same table in the local data dictionary. Everything works, but sometimes, I get a unique constraint violation if I'm trying to insert a duplicate record, so I wrote a simple function to check for the scenario. My problem is that I can run my procedure using the link to the db and I can run my function using the db link, but I can't use the two together without errors.
My test scenario uses only the standard emp table:
create or replace procedure test_insert(p_instance varchar2) IS l_sql varchar2(4000); begin l_sql := 'insert into EMP@'||p_instance||' (EMPNO, ENAME, JOB, MGR, SAL, DEPTNO) (Select EMPNO, ENAME, JOB, MGR, SAL, DEPTNO from EMP)'; execute immediate l_sql; END;
BEGIN test_insert('myLink'); END;
It works very well and the insert occurs without any problem.
If I run the same process a second time, I get:
00001 00000 - "forced single (s.%s) violated" which is what I've been waiting for EMPNO has a unique constraint. So far so good.
Now, I create a function to check if the record exists:
create or replace function record_exists(p_empno IN NUMBER, p_instance IN varchar2) return number IS l_sql varchar2(4000); l_count number; BEGIN l_sql := 'select count(*) from EMP@'||p_instance||' where empno = '||p_empno; execute immediate l_sql into l_count; IF l_count > 0 THEN return 1; ELSE return 0; END IF; END;
I test this situation as follows:
select record_exists(8020, 'myLink') from dual;
RECORD_EXISTS(8020,'myLink')
-------------------------------------------
1
That works well, so now I'll add this feature to my procedure:
create or replace procedure test_insert(p_instance varchar2) IS l_sql varchar2(4000); begin l_sql := 'insert into EMP@'||p_instance||' (EMPNO, ENAME, JOB, MGR, SAL, DEPTNO) (Select EMPNO, ENAME, JOB, MGR, SAL, DEPTNO from EMP WHERE record_exists( EMPNO, '''||p_instance||''') = 0)'; execute immediate l_sql; END;
I test this situation as follows:
BEGIN test_insert('myLink'); END;
As a result:
Error report: ORA-02069: global_names parameter must be set to TRUE for this operation ORA-06512: at "FUSION.TEST_INSERT", line 6 ORA-06512: at line 2 02069. 00000 - "global_names parameter must be set to TRUE for this operation" *Cause: A remote mapping of the statement is required but cannot be achieved because global_names should be set to TRUE for it to be achieved *Action: Issue alter session set global_names = true if possible
I don't know why I'm getting this. The function works, the works of the procedure, but when I combine I get an error. If I set the global setting to true names and then run again I get:
02085. 00000 - "database link %s connects to %s" *Cause: a database link connected to a database with a different name. The connection is rejected. *Action: create a database link with the same name as the database it connects to, or set global_names=false.
All opinions are appreciated. I do not understand why I can run the procedure and function of each separately on the db connection, but they don't work together.
Thank you
John
The procedure depends on what how would you define failure and it should mean - error to the caller, sign and continue, just continue. Constraints are created to ensure if it receives no invalid data in a table. Generally, they provide the most effective mechanism for the verification of the invalid data and return useful exceptions that can deal with the appellant. You also double the workload of the checking uniqueness by adding your own control.
In general I would say use Exceptions, they are your friend
-
Information on ColdFusion 11:
Server details Server product ColdFusion Version 11,0,03,292480 Version of Tomcat 7.0.54.0 Edition Developer Operating system Windows 8 OS version 6.2 Update level C:/ColdFusion11/cfusion/lib/updates/chf11000003.jar Version of the Adobe driver 5.1.3 (build 000094) Sample error:
queryError [Macromedia] [SQLServer JDBC Driver] [SQL Server] Procedure or function 'ListClientDPReceiptFormat' expects the parameter '@idCient', which was not provided. where (param 1) = [type = 'IN', class = 'java.lang.Integer', value = '4', sqltype = "CF_SQL_INTEGER"] Stored procedure:
< procedure CFSTOREDPROC = "ListClientDPReceiptFormat" > "< CFPROCPARAM TYPE = 'IN' DBVARNAME ="@idClient"VALUE =" #Request.Client.Id # "" CFSQLTYPE = "CF_SQL_INTEGER" > < CFPROCRESULT NAME = "qryDPReceiptFormats" > < / CFSTOREDPROC > This stored procedure and other like it worked fine until the update from CF 11 3 has been applied.
Thank you!
It seems to be a typo here. Can clarify you...
The error "[Macromedia] [SQLServer JDBC Driver] [SQL Server] procedure or function 'ListClientDPReceiptFormat' expects the parameter '@idCient', which was not provided." the parameter defined as @idCient but your cfprocparam dbvarname = has ' @idClient'. .
These are spelled differently.
I think that this may be related to what is mentioned in this bug - Bug #3865064 - ColdFusion 11 3 CFPROCRESULT case update
Adam Cameron notes:
" Basically, then, it's a matter of the code in question was wrong, but the user has been getting away with it because the DBVARNAME was ignored. Now that it is not ignored, the code must actually be legitimate ;-). Very well, in that case. »
-
would you use a stored procedure or a function
Hello
I have a very long query. I reduced a large number of sections of it with views.
But now I have a section that is repeated several times, about 40 times. It is about 15 lines of SQL code.
The variation between these blocks are two fields which change their value and I always join the result of these blocks using the same ID.
Of course, I think I can extract in a central block (DRY) and call them from a main request, the question is how.
My first approach would be a stored procedure. But all the examples I found that you use some PL/SQL or Java, that I could also... but isn't it overkill?
The function?
Any recommendation?
Thank you!refer wrote:
who would do it, I guess that
now the newbie question: in the function block: how to assign select va1 and va2 from a query results in the attributes of the object? I couldn't find an example where this is demonstrated (if possible).I should have simplified:
create or replace function ma_fonction (a number, b varchar2) return my_type
as
my_type my_obj;
Start
-here:
Select val1, val2 from table1 - is always only one line
-my_obj: = my_type (a, b); -How can I assign those here?
Return my_obj;
end
;select my_type(val1,val2) into my_obj from table1;
Published by: Toon Koppelaars on February 24, 2011 10:16
-
Stored procedure and stored function
Greetings from a newbie,
Question about procedure and function:
When we use procedure and function? What is the difference between the two?
Kind regards
Valerie
Published by: Valerie debonair on August 24, 2009 21:27When we use procedure and function?
If you need to compute and value, good idea to use the function to return.
If you need data DML, good idea to use the procedure...What is the difference between the two?
A FUNCTION is always returns a value using the return statement.
A PROCEDURE can return one or more values through parameters or may not return at all. -
How to pass the value of an element in a function called by a procedure
Hello
I have a procedure named PROCEDURE AFFICHAGE_PLUVIO_VEILLE (sorry I don't know how to get in shape for the code):
{code: sql}create or replace PROCEDURE AFFICHAGE_PLUVIO_VEILLE AS
CURSOR curs1 is
Select the site, name, site_pluviometre clef_var
where EN_SERVICE = 'YES ';
number of stmt;
BEGIN
DELETE FROM PLUVIO_DATA;
for m loop curs1
stmt: = calc_pluvio (m.clef_var);
INSERT INTO pluvio_data values (m.clef_var, stmt);
end loop;
commit;
END AFFICHAGE_PLUVIO_VEILLE; {code}
This procedure calls a function:
{code: sql}create or replace function "CALC_PLUVIO" (station NUMBER)
return the number is the default number of 0 total.
BEGIN
WITH PRECIPITATION AS
(SELECT DATE1 RAINFALLDATE, VALUE
OF EVV_STPL
WHERE CLEF_VAR = station
AND TRUNC (DATE1) = TRUNC (sysdate-1))
SELECT SUM (TOTO) INTO CUMULATION
DE)
SELECT TRUNC (RAINFALLDATE) AS date,
VALUE,
(VALUE) AHEAD OF (TRUNC PARTITION (RAINFALLDATE)
ORDER BY RAINFALLDATE
) - VALUE AS TOTO
PRECIPITATION
)
WHERE TOTO > = 0
GROUP BY date;
DATE OF RETURN;
EXCEPTION
WHEN NO_DATA_FOUND THEN
TOTAL: = 0;
DATE OF RETURN;
END; {code}
You can see that the function uses 'sysdate-1' regarding the date. " In order to be more flexible with the date and to be able to use a date other than the date of the previous day, I would like to pass as a parameter to the function of the value of a page called P1_DATE.
But, how can I do? Function CALC_PLUVIO' is called by the stored procedure 'AFFICHAGE_PLUVIO_VEILLE of PROCEDURE' for which I can not transmit to any parameter as for example the P1_DATE element.
I use Application Express 5.0.1.00.06
Thank you for your help.
Chipniz wrote:
I have a procedure named AFFICHAGE_PLUVIO_VEILLE of PROCEDURE (sorry I don't know how to get in shape for the code):
Click on the link to the editor advanced usage in the top right of the edit box, select the code in the editor and choose the language desired from the syntax highlighting options in > toolbar button menu. (For SQL and PL/SQL code, use "SQL").
create or replace PROCEDURE AFFICHAGE_PLUVIO_VEILLE AS CURSOR curs1 is select site, nom, clef_var from site_pluviometre where EN_SERVICE = 'OUI'; stmt number; BEGIN DELETE FROM PLUVIO_DATA; for m in curs1 loop stmt := calc_pluvio (m.clef_var); INSERT INTO pluvio_data values (m.clef_var, stmt); end loop; commit; END AFFICHAGE_PLUVIO_VEILLE;
This procedure calls a function:
create or replace function "CALC_PLUVIO" (station in NUMBER) return number is cumul number default 0; BEGIN WITH RAINFALL AS (SELECT DATE1 RAINFALLDATE, VALEUR VALUE FROM EVV_STPL WHERE CLEF_VAR = station AND TRUNC (DATE1) = TRUNC (sysdate-1)) SELECT SUM (TOTO) INTO CUMUL FROM ( SELECT TRUNC (RAINFALLDATE) AS datte, VALUE, LEAD (VALUE) OVER ( PARTITION BY TRUNC (RAINFALLDATE) ORDER BY RAINFALLDATE ) - VALUE AS TOTO FROM RAINFALL ) WHERE TOTO >= 0 GROUP BY datte; RETURN CUMUL; EXCEPTION WHEN NO_DATA_FOUND THEN CUMUL := 0; RETURN CUMUL; END;
You can see that the function uses ' sysdate-1' regarding the date. " To be more flexible with the date and to be able to use a date other than the date of the previous day, I want to pass as a parameter to the function of the value of a page called P1_DATE.
But, how can I do? The CALC_PLUVIO function ' is called by the stored procedure 'AFFICHAGE_PLUVIO_VEILLE of PROCEDURE' for which I can not transmit to any parameter as for example the P1_DATE element.
What do you mean by "I can't pass any parameter"? That you cannot change the signatures of the procedure and function?
Passage of a parameter is the recommended approach. Including a default value will ensure that programs are backward compatible with existing code that does not it:
create or replace PROCEDURE AFFICHAGE_PLUVIO_VEILLE (p_rainfall_date in date default null) AS CURSOR curs1 is select site, nom, clef_var from site_pluviometre where EN_SERVICE = 'OUI'; stmt number; BEGIN DELETE FROM PLUVIO_DATA; for m in curs1 loop stmt := calc_pluvio (m.clef_var, p_rainfall_date); INSERT INTO pluvio_data values (m.clef_var, stmt); end loop; commit; END AFFICHAGE_PLUVIO_VEILLE;
create or replace function "CALC_PLUVIO" (station in NUMBER, p_rainfall_date in date default null) return number is cumul number default 0; rainfall_date date; BEGIN rainfall_date := trunc(coalesce(p_rainfall_date, sysdate-1)); WITH RAINFALL AS (SELECT DATE1 RAINFALLDATE, VALEUR VALUE FROM EVV_STPL WHERE CLEF_VAR = station AND TRUNC (DATE1) = calc_pluvio.rainfall_date) SELECT SUM (TOTO) INTO CUMUL FROM ( SELECT TRUNC (RAINFALLDATE) AS datte, VALUE, LEAD (VALUE) OVER ( PARTITION BY TRUNC (RAINFALLDATE) ORDER BY RAINFALLDATE ) - VALUE AS TOTO FROM RAINFALL ) WHERE TOTO >= 0 GROUP BY datte; RETURN CUMUL; EXCEPTION WHEN NO_DATA_FOUND THEN CUMUL := 0; RETURN CUMUL; END;
This code can be called APEX by:
AFFICHAGE_PLUVIO_VEILLE(p_rainfall_date => to_date(:p1_date, 'DD-MON-YYYY')); -- change format mask to that used in the P1_DATE item
Moreover, if the P1_DATE element is the only possible source of another value on the date of the rain, then the value can be referenced directly in the function:
create or replace function "CALC_PLUVIO" (station in NUMBER) return number is cumul number default 0; rainfall_date date; BEGIN rainfall_date := trunc(coalesce(v('P1_DATE'), sysdate-1)); WITH RAINFALL AS (SELECT DATE1 RAINFALLDATE, VALEUR VALUE FROM EVV_STPL WHERE CLEF_VAR = station AND TRUNC (DATE1) = calc_pluvio.rainfall_date) SELECT SUM (TOTO) INTO CUMUL FROM ( SELECT TRUNC (RAINFALLDATE) AS datte, VALUE, LEAD (VALUE) OVER ( PARTITION BY TRUNC (RAINFALLDATE) ORDER BY RAINFALLDATE ) - VALUE AS TOTO FROM RAINFALL ) WHERE TOTO >= 0 GROUP BY datte; RETURN CUMUL; EXCEPTION WHEN NO_DATA_FOUND THEN CUMUL := 0; RETURN CUMUL; END;
-
Difference of procedure &; function
Hi all
After citing some tutorials, I got to know that the difference between the procedure and the function is that the procedure may or may not return a value as the function must return a value to the calling program. Given below is my procedure. & He would compare the lower of the two numbers would be smaller than
create or replace procedure findmin
(
x in number,
there in numbers,
z series
)
is
Start
if(x<y) then
z: = x;
on the other
z: = y;
end if;
end;
declare
c number;
Start
findmin (23,45,c);
dbms_output.put_line (c);
end;
Here's my function even if it does the same thing.
create or replace function findmin_fun
(
x in number,
y number
)
Return number
is
number of z;
Start
if(x<y) then
z: = x;
on the other
z: = y;
end if;
Return z;
end;
declare
Start
dbms_output.put_line (findmin_fun (56,28));
end;
I would like to know under what are all the scenarios of the procedure and function would be used. And also I want to know could do dml as insert, update, and delete operations
If so, could you guys explain me with some examples to expose DML operations on functions
After citing some tutorials, I got to know the difference between the procedure & function is that the procedure may or may not return a value as the function must return a value to the calling program.
Not quite.
A procedure does NOT return a value - it can fill in the parameters OUT or INOUT but which is NOT considered to be "of return values.
A function ALWAYS returns a value that can be null. The only exception is if the function throws an exception.
My procedure is given below. It would be to compare the lower of the two numbers & would mean that smaller
Not quite - the procedure returns NO value. You use it to try to fill one OUT parameter, but it's NOT the same.
I would like to know under what are all the scenarios the procedure & function would be used.
Functions can be used in SQL; procedures cannot be used in SQL.
The functions return a value; procedures of does NOT return a value.
Use the functions when you need to return a value; Use the procedures when you do NOT need to return a value.
It is not possible to list 'all scenarios' for one or the other, because there may be ANY NUMBER of possible scenarios.
And also I want to know could do dml as insert operations, update & delete
What happened when you tried?
The best and fastest, to learn is to actually TRY THINGS. Don't be afraid to break the Oracle by actually writing code and tests of things yourself.
If so, could you guys explain me with some examples to expose DML operations on functions
The Oracle documentation have a LOT of examples of using functions and procedures and include the code of the example.
https://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/subprograms.htm#CHDBEJGF
The internet has even more examples of code.
-
How do you know that a spesific procedure or function has been run by the user who and when?
Hi allSuppose I have a procedure or a function whose name is MY_PROC. Is it possible to learn that the user who has been running this procedure and when?
Thank you
Hi NightWing,
You need VERIFICATION for operations.
11.2 docs: AUDIT
For example:
SQL> show parameter audit_trail; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ audit_trail string DB SQL> SQL> conn iarsov/iarsov Connected. SQL> create or replace function test_audit 2 return date 3 is 4 begin 5 return sysdate; 6 end; 7 / Function created. SQL> conn system Enter password: Connected. SQL> audit execute on iarsov.test_audit by access; Audit succeeded. SQL> select os_username,username,obj_name,owner from dba_audit_trail where obj_name = 'TEST_AUDIT'; no rows selected SQL> conn iarsov/iarsov Connected. --call the function and trigger audit operation SQL> select test_audit from dual; TEST_AUDI --------- 04-AUG-14 SQL> conn system Enter password: Connected. SQL> select os_username,username,obj_name,owner,timestamp from dba_audit_trail where obj_name = 'TEST_AUDIT'; OS_USERNAME USERNAME OBJ_NAME OWNER TIMESTAMP -------------------- ------------------------------ -------------------- -------------------- --------- oracle IARSOV TEST_AUDIT IARSOV 04-AUG-14
Kind regards
Ivica
-
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 -
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.
-
Using the values of default setting with the functions or procedures?
If you have a procedure or a function that has DEFAULT values reported for some parameters How do you call this function or procedure when you want to use some of the default values? I tried...
myProcedure(202,,);
myProcedure (202, ",");
myProcedure(202,null,null);
myProcedure (job_id = 202);
myProcedure (job_id = > 202);
None of the above worked.
PROCEDURE add_job (job_id IN jobs.job_id%TYPE
job_loc IN jobs.job_location%TYPE DEFAULT 145
mgr_id IN DEFAULT jobs.mgr_id%TYPE 30
);
Thank you.
EDIT: I will say that it is a simplified example. Imagine you please a parameter list much more great and perhaps half having DEFAULT values. Thank you.
PROCEDURE myProcedure (job_id IN jobs.job_id%TYPE
job_loc IN jobs.job_location%TYPE DEFAULT 145
mgr_id IN DEFAULT jobs.mgr_id%TYPE 30
init_id IN jobs.init_id%TYPE
sal_id IN jobs.sal_id%TYPE 100 by DEFAULT
, clock_id IN DEFAULT jobs.clock_id%TYPE "A".
shift_id IN jobs.shift_id%TYPE
, lot_id IN DEFAULT jobs.lot_id%TYPE «BACK»
);
Published by: davejjj on March 20, 2013 16:47Hi davejjj,
Here is an example of calling your myprocedure. This example uses default values for sal_id, clock_id, lot_id
declare procedure myprocedure ( job_id in jobs.job_id%type, job_loc in jobs.job_location%type default 145, mgr_id in jobs.mgr_id%type default 30, init_id in jobs.init_id%type, sal_id in jobs.sal_id%type default 100, clock_id in jobs.clock_id%type default 'A', shift_id in jobs.shift_id%type, lot_id in jobs.lot_id%type default 'BACK' ); begin myprocedure (job_id => your_job_id, job_loc => your_job_loc, mgr_id => your_mgr_id, init_id => null, shift_id => your_shift_id ); end; /
This, however, will NOT WORK, because myprocedure doesn't have a default value declared for init_id
begin myprocedure (job_id => your_job_id, job_loc => your_job_loc, mgr_id => your_mgr_id, shift_id => your_shift_id ); end; /
Concerning
Peter -
Send String [] [] type of pl/sql function in App.module procedure
Hello
I use jdveloper 11.1.1.3.0
I have a pl/sql procedure. entry type argument is array (TAR) 2 Dimensions:
types:
create or replace TYPE ARRAYWEB in the varray (160) of VARCHAR2 (200);
create or replace TYPE TAR as the ARRAYWEB table;
Procedure:
PROCEDURE of translations (info in TAR)
I want to send the String [] [] type to this procedure from a function in the Application module:
1: string [] [] str;
2: CallableStatement plsqlBlock = null;
3: string declaration = "BEGIN testi(:1); END; « ;
4: plsqlBlock is getDBTransaction () .createCallableStatement (statement, 0);.
5: plsqlBlock.setArray (1, str); Get the error
6: plsqlBlock.executeUpdate ();
but in line 5 I do not know what type should I use and this type (Array) does not work
HabibMaybe this can help: http://www.devx.com/tips/Tip/22034
Dario
-
Procedure or function for the possible combinations of numbers
Hello
Could someone please tell how interrogate maximum possible combinations of a number or a string using a procedure or a function.
For example:
I / p: 12
O/P:
12
21
Likewise for a shot too
I / P: A
O/P:
ONE
NA
I searched in the oracle forums and found a function but its very long and am not understand.
Someone help me please.I'm pretty sure that 9i supports the functions in pipeline (him below has been tested on 10.2.0.1), so using those who have a little recurrence...
create or replace type t_combs is table of varchar2(20) / create or replace function get_combinations(p_string in varchar2) return t_combs pipelined is v_chr varchar2(1); v_rem varchar2(20); begin for i in 1..length(p_string) loop v_chr := substr(p_string,i,1); v_rem := substr(p_string,1,i-1)||substr(p_string,i+1); if v_rem is not null then for x in (select column_value as comb from table(get_combinations(v_rem))) loop pipe row(v_chr||x.comb); end loop; else pipe row(v_chr); end if; end loop; return; end; / SQL> select * 2 from table(get_combinations('ABC')); COLUMN_VALUE -------------------- ABC ACB BAC BCA CAB CBA 6 rows selected. SQL> select * 2 from table(get_combinations('FRED')); COLUMN_VALUE -------------------- FRED FRDE FERD FEDR FDRE FDER RFED RFDE REFD REDF RDFE RDEF EFRD EFDR ERFD ERDF EDFR EDRF DFRE DFER DRFE DREF DEFR DERF 24 rows selected. SQL> select * 2 from table(get_combinations('HELLO')); COLUMN_VALUE -------------------- HELLO HELOL HELLO HELOL HEOLL HEOLL HLELO HLEOL HLLEO HLLOE HLOEL HLOLE HLELO HLEOL HLLEO HLLOE HLOEL HLOLE HOELL HOELL HOLEL HOLLE HOLEL HOLLE EHLLO EHLOL EHLLO EHLOL EHOLL EHOLL ELHLO ELHOL ELLHO ELLOH ELOHL ELOLH ELHLO ELHOL ELLHO ELLOH ELOHL ELOLH EOHLL EOHLL EOLHL EOLLH EOLHL EOLLH LHELO LHEOL LHLEO LHLOE LHOEL LHOLE LEHLO LEHOL LELHO LELOH LEOHL LEOLH LLHEO LLHOE LLEHO LLEOH LLOHE LLOEH LOHEL LOHLE LOEHL LOELH LOLHE LOLEH LHELO LHEOL LHLEO LHLOE LHOEL LHOLE LEHLO LEHOL LELHO LELOH LEOHL LEOLH LLHEO LLHOE LLEHO LLEOH LLOHE LLOEH LOHEL LOHLE LOEHL LOELH LOLHE LOLEH OHELL OHELL OHLEL OHLLE OHLEL OHLLE OEHLL OEHLL OELHL OELLH OELHL OELLH OLHEL OLHLE OLEHL OLELH OLLHE OLLEH OLHEL OLHLE OLEHL OLELH OLLHE OLLEH 120 rows selected. SQL>
He wrote to treat up to 20 strings and to be honest, it would be a helluva lot of combinations (around 38,535,430,022,369,280,000), so that has to deal with most of the cases you need.
Maybe you are looking for
-
Problem of evil of Safari fonts
Hi, guys. I recently installed Office 2016 on my mac. As it is stated on the microsoft Web site, I deleted all the files associated with the earlier versions of Office. However, now in Safari I get fonts badly on some sites, for example Arial or Time
-
Broken on my Qosmio laptop screen lines
I can see dotted red on my screen during startup and it boot completely doesn t.Can u attend to this problem?
-
Hello Im working with SCPI but I am having a few problems to clarify some points of the IEEE 488.2 and SCPI 99 folder, I hope someone here can have the knowledge to help. My questions concern mainly the separators of unit and command message headers
-
HP PAVILION G6-1107TX: improving the use of the battery
Hello I would like to know if it is safe to run my laptop with the charger permanently connected when I have access to the charger. Or is it necessary to unplug the charger when the battery is fully charged and let unload naturally and reconnect it.
-
Code 641 for Microsoft updates
I am running Vista Home Premium on my Dell laptop. Try to load Microsoft Updates and get Code 641 on two specific updates. This has happened a couple of weeks, and I finally did a total reload (OS) of the system, which seems to fix the problem. But n