Running a function inside a package
This is kind of a noob question: I have a function. I want to use this function inside a package. The function is not created inside the package.
Here is an example;
1 create or replace function test_func(v_one number, v_two number)
2 return number
3 as
4 begin
5 return v_one + v_two;
6* end;
SQL> /
Function created.
SQL> select test_funct(10,20) from dual
2 /
select test_funct(10,20) from dual
ERROR at line 1:
ORA-00904: "TEST_FUNCT": invalid identifier
SQL> select test_func(10,20) from dual
2 /
TEST_FUNC(10,20)
30
SQL> create or replace package test_pkg as
2 procedure test_proc(v_name varchar2, v_one number, v_two number);
3 end test_pkg;
4 /
Package created.
SQL>
1 create or replace package body test_pkg as
2 procedure test_proc(v_name varchar2, v_one number, v_two number) is
3 begin
4 dbms_output.put_line(v_name || ' ' || test_func(v_one, v_two));
5 end;
6* end test_pkg;
SQL> /
Package body created.
SQL> set serveroutput on
SQL> exec test_pkg.test_proc('Krystian',10,20)
Krystian 30
PL/SQL procedure successfully completed.With kind regards
Krystian Zieja
Similar Messages
-
Call a function inside a package from a stored procedure
Hello:
I am kind of new to the stored procedure. Does anyone know how to call a function inside a package from another stored procedure?
I have a existing function (func_b) inside a package (pack_a) and it returns a cursor. I want to call this function from a stored procedure (proc_c) so that I use the data inside the cursor.
can I do the following in proc_c:
my_cursor1 SYS_REFCURSOR;
begin
my_cursor1 := exec pack_a.func_b
end
It will be very helpful if anyone can point me to any reading or example. Thank you very much for your information.guys:
Thank you for your information so far. I need some more help here. I was able to run the function in my stored procedure. However, I was not able to print the result on the screen to view the cursor result, although I am using dbms_output.put_line statement inside my stored procedure.
I use the following statement to execute my stored procedure on sql*plus. I can tell the stored procedure is executed successfully, but I did see anything printed:
DECLARE TEMP VARCHAR2(100);
BEGIN PROC_LAWS_CAD_NAME_SEARCH('LPD', 'TEST DEVICE ID', 'TEST LAST NAME', 'TEST FIRST NAME', 'F', '11112009', TEMP); END;
I tried to use 'set serveroutput on' and got the following error:
ERROR:
ORA-06502: PL/SQL: numeric or value error: host bind array too small
ORA-06512: at line 1
I am kind of confused now. thank you for your help.
Jack
Here is my procedure:
create or replace
PROCEDURE PROC_SEARCH
( AGENCY_ID IN VARCHAR2,
DEVICE_ID IN VARCHAR2,
L_NAME IN VARCHAR2,
F_NAME IN VARCHAR2,
SEX IN VARCHAR2,
DOB IN VARCHAR2,
CAD_NAME_SCH_RESULT_STR OUT VARCHAR2)
AS
v_agy_id varchar2(10);
v_device_id varchar2(20);
v_l_name varchar2(25);
v_f_name varchar2(15);
v_sex varchar2(1);
v_dob date;
-- this cursor is going to be used to store a list of warrant matching
-- name search criteria
cad_srch_cursor sys_refcursor;
objSrch SEARCH_RESULT_TEMP%ROWTYPE;
BEGIN
cad_srch_cursor := SEARCH_PKG.SEARCH('TESTING', 'TESTER', null, null,null, null, getPhonetic('TESTING'));
LOOP
FETCH cad_srch_cursor INTO objSrch;
EXIT WHEN cad_srch_cursor%NOTFOUND;
--insert into SEARCH_RESULT_TEMP (name_last) values (objSrch.name_last);
CAD_NAME_SCH_RESULT_STR := objSrch.name_last;
dbms_output.put_line('First:'||objSrch.name_first||':Last:'||objSrch.name_last||':Middle:'||objSrch.name_middle);
end LOOP;
END PROC_LAWS_SEARCH;
----------------------------------------- -
How to find out list of procedures and functions inside a package
How I can find out the list of Procedures and Functions inside a Package.
Look at ALL_PROCEDURES and ALL_ARGUMENTS.
-
Custom aggregate function inside a package.
Hi there,
I'm trying to write a custom aggregate function and group that function inside a package together with some other functions that I have. As an example (to simulate the problem I have) suppose my custom aggregation to do a summation of numbers looks like:
CREATE OR REPLACE TYPE SUM_AGGREGATOR_TYPE AS OBJECT (
summation NUMBER,
STATIC FUNCTION ODCIAggregateInitialize(agg_context IN OUT
SUM_AGGREGATOR_TYPE) RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateIterate(self IN OUT SUM_AGGREGATOR_TYPE,
next_number IN NUMBER) RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateMerge(self IN OUT SUM_AGGREGATOR_TYPE,
para_context IN SUM_AGGREGATOR_TYPE) RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateTerminate(self IN SUM_AGGREGATOR_TYPE,
return_value OUT NUMBER, flags IN NUMBER) RETURN NUMBER
CREATE OR REPLACE TYPE BODY SUM_AGGREGATOR_TYPE IS
STATIC FUNCTION ODCIAggregateInitialize(agg_context IN OUT
SUM_AGGREGATOR_TYPE)
RETURN NUMBER IS
BEGIN
agg_context := SUM_AGGREGATOR_TYPE(NULL);
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateIterate(self IN OUT SUM_AGGREGATOR_TYPE,
next_number IN NUMBER)
RETURN NUMBER IS
BEGIN
IF self.summation IS NULL THEN
self.summation := next_number;
ELSIF summation IS NOT NULL THEN
self.summation := self.summation + next_number;
END IF;
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateMerge(self IN OUT SUM_AGGREGATOR_TYPE,
para_context IN SUM_AGGREGATOR_TYPE)
RETURN NUMBER IS
BEGIN
self.summation := self.summation + para_context.summation;
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateTerminate(self IN SUM_AGGREGATOR_TYPE,
return_value OUT NUMBER, flags IN NUMBER)
RETURN NUMBER IS
BEGIN
return_value := self.summation;
return ODCIConst.Success;
END;
END;
If I write the following function definition:
CREATE OR REPLACE FUNCTION MY_SUM(input NUMBER)
RETURN NUMBER PARALLEL_ENABLE AGGREGATE USING SUM_AGGREGATOR_TYPE;
and corresponding type declaration to test:
CREATE OR REPLACE TYPE VECTOR
IS
TABLE OF NUMBER;
this statement:
select my_sum(column_value) from table(vector(1, 2, 1, 45, 22, -1));
gives the correct result of 70. However, creating a package with the function definition:
CREATE OR REPLACE PACKAGE MY_FUNCTIONS AS
FUNCTION MY_SUM(input NUMBER)
RETURN NUMBER PARALLEL_ENABLE AGGREGATE USING SUM_AGGREGATOR_TYPE;
END;
and calling it via:
select MY_FUNCTIONS.my_sum(column_value) from table(vector(1, 2, 1, 45, 22, -1));
explodes with:
ORA-00600: internal error code, arguments: [17090], [], [], [], [], [], [], [], [], [], [], []
Is it possible to have custom aggregate functions nested inside package declarations?
I'm using Oracle 11g, Release 2 (11.2.0.1.0).HiddenName wrote:
Is it possible to have custom aggregate functions nested inside package declarations?Yes, it is possible, you have succesfuly created your function. Your problem is that the database throws ORA-600 on execute. And with ORA-600 you can do 2 things: 1) google ORA-600 17090 or 2) contact your Oracle Support.
You could also try to declare the function without PARALLEL_ENABLE - just to try to see if it changes anything. You can also try to call your function against a regular table with rows and columns - not against an collection type with table() operator.
Anyway - these 2 tests should be usefull for Oracle Support.
I never tried to put a custom aggregate function into a package. First - the cases when you need a custom aggregate function to be written for your system are very rare. Second - even if I needed 1 then I never needed 2 or more custom aggregate functions on my system. And as I do not like to make my life more complex than necessary, I have created it as a stand-alone function. And it is works (slowly).I tried using a standard table as you suggested:
CREATE TABLE TEST_DATA
test_value NUMBER
INSERT INTO TEST_DATA
(SELECT column_value test_value from TABLE(vector(1, 2, 1, 45, 22, -1)));
COMMIT;
select my_sum(test_value) from test_data;
select my_functions.my_sum(test_value) from test_data;
I also tried removing the PARALLEL_ENABLE clause to create the package as follows:
CREATE OR REPLACE PACKAGE MY_FUNCTIONS AS
FUNCTION MY_SUM(input NUMBER)
RETURN NUMBER AGGREGATE USING SUM_AGGREGATOR_TYPE;
END;
And unfortunately it still breaks with the following error: SQL Error: ORA-00600: internal error code, arguments: [17090]. This looks like an Oracle bug to me as the PL/SQL parsing engine should have disallowed me to even create this if it is not supported in Oracle. Instead, it allows me to create the package, and breaks when I call the function with this weird error (additionally cutting my connection from the database) instead of disallowing me to do this altogether and printing a nice error message telling me that Oracle doesn't support this. How would I go about logging a ticket for this?
Edited by: wcmatthysen on Dec 1, 2010 12:51 PM -
Stragg Function inside a Package
Hi Experts,
When i tried to use Stragg Function inside package, it throws error
CREATE OR REPLACE PACKAGE PKG_TEST AS
FUNCTION STRAGG(INPUT VARCHAR2) RETURN VARCHAR2;
END PKG_TEST;
CREATE OR REPLACE PACKAGE BODY PKG_TEST AS
FUNCTION STRAGG (INPUT VARCHAR2) RETURN VARCHAR2 PARALLEL_ENABLE AGGREGATE USING string_agg_type;
END PKG_TEST;
SHOW ERRORS
Package created.
Warning: compiled but with compilation errorsAny Suggestions...
ThanksThanks Frank.
>
Why do you need (or even want) STRAGG to be in a package? If it's a stand-alone function, you can call it from within a package whne you want to.
>
Actually my requirement is to have all code inside package and not in open.
>
The second example is not referencing pkg_test. Maybe you have two functions called STRAGG, one inside pkg_test (which has a bug) and one that is not in any package (which works correctly).
>
No...just only one function.
>
Whenever you have problems with a user-defined function, post the code that creates the user-defined function. (Make sure it's formatted.)
Even if you just copied the function from AskTom, post exactly what's on your system. There may be a editing error of which you're not aware.
>
Here is what i have with me,
Type Object and Body.
CREATE OR REPLACE TYPE string_agg_type
AS OBJECT
total varchar2(4000),
STATIC FUNCTION
ODCIAggregateInitialize (sctx IN OUT string_agg_type )
RETURN NUMBER,
MEMBER FUNCTION
ODCIAggregateIterate
( self IN OUT string_agg_type
, value IN VARCHAR2)
RETURN NUMBER,
MEMBER FUNCTION
ODCIAggregateTerminate
( self IN string_agg_type
, returnValue OUT VARCHAR2
, flags IN NUMBER
RETURN NUMBER,
MEMBER FUNCTION
ODCIAggregateMerge
( self IN OUT string_agg_type
, ctx2 IN string_agg_type
RETURN NUMBER
CREATE OR REPLACE TYPE BODY string_agg_type
IS
STATIC FUNCTION
ODCIAggregateInitialize
( sctx IN OUT string_agg_type
RETURN NUMBER
IS
BEGIN
sctx := string_agg_type ( NULL );
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION
ODCIAggregateIterate
( self IN OUT string_agg_type,
value IN VARCHAR2
RETURN NUMBER
IS
BEGIN
self.total := SUBSTR(self.total || value, 1, 4000);
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION
ODCIAggregateTerminate
( self IN string_agg_type
, returnValue OUT VARCHAR2
, flags IN NUMBER
RETURN NUMBER
IS
BEGIN
returnValue := self.total;
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION
ODCIAggregateMerge
( self IN OUT string_agg_type
, ctx2 IN string_agg_type
RETURN NUMBER
IS
BEGIN
self.total := self.total || ctx2.total;
RETURN ODCIConst.Success;
END;
END;
SHOW ERRORSMy Package
CREATE OR REPLACE PACKAGE PKG_TEST AS
FUNCTION STRAGG(INPUT VARCHAR2) RETURN VARCHAR2 PARALLEL_ENABLE;
END PKG_TEST;
CREATE OR REPLACE PACKAGE BODY PKG_TEST AS
FUNCTION STRAGG (INPUT VARCHAR2) RETURN VARCHAR2 PARALLEL_ENABLE AGGREGATE USING string_agg_type;
END PKG_TEST;
/Any way ....i just looked in to Solomon Code and tried it similarly. Not getting the expected and i believe it is a bug.
Thanks a lot for your time to analyze and reply to my post. -
Question about Table Function inside a Package
Hi … I am new in PL/SQL, I am trying to use a table function to create depending on a value passed to it (I am using 10g). Everything works great but the moment I add a parameter everything explode, I am creating it on a package.
SQL that work
CREATE OR REPLACE PACKAGE BODY financial_reports AS
FUNCTION Fund_Amount
RETURN financial_reports.Fund_Amount_Table
pipelined parallel_enable IS
cur_row financial_reports.Fund_Amount_Record;
BEGIN
FOR cur_row IN
SELECT
to_number(substr(bu5.usrdata, 1, 1)) As SECTION_ID
,to_number(substr(bu5.usrdata, 2, 1)) As SUB_SECTION_ID
,to_number(substr(bu5.usrdata, 4, 2)) AS LINE_NUMBER
,to_number(substr(bu5.usrdata, 7, 2)) As FUND_ID
,sum(be.amt) AS AMOUNT
FROM
linc.budgetdb_usr5@stjohnsfp bu5
JOIN linc.budgetdb_event@stjohnsfp be ON
bu5.keyvalue = be.acctno
WHERE
bu5.keyvalue like '__-__-__-____-____-_____'
AND bu5.usrdata like '__-__-__'
AND bu5.fieldnum = 1
AND bu5.ispecname = 'GLMST'
AND to_number(substr(bu5.usrdata, 7, 2)) = 1
GROUP BY
bu5.usrdata
ORDER BY
bu5.usrdata
LOOP
PIPE ROW(cur_row);
END LOOP;
END Fund_Amount;
END financial_reports;
SQL that do not work …
CREATE OR REPLACE PACKAGE BODY financial_reports AS
FUNCTION Fund_Amount (Fund_Id IN NUMBER)
RETURN financial_reports.Fund_Amount_Table
pipelined parallel_enable IS
cur_row financial_reports.Fund_Amount_Record;
fund_id_int NUMBER;
BEGIN
fund_id_int := Fund_Id;
FOR cur_row IN
SELECT
to_number(substr(bu5.usrdata, 1, 1)) As SECTION_ID
,to_number(substr(bu5.usrdata, 2, 1)) As SUB_SECTION_ID
,to_number(substr(bu5.usrdata, 4, 2)) AS LINE_NUMBER
,to_number(substr(bu5.usrdata, 7, 2)) As FUND_ID
,sum(be.amt) AS AMOUNT
FROM
linc.budgetdb_usr5@stjohnsfp bu5
JOIN linc.budgetdb_event@stjohnsfp be ON
bu5.keyvalue = be.acctno
WHERE
bu5.keyvalue like '__-__-__-____-____-_____'
AND bu5.usrdata like '__-__-__'
AND bu5.fieldnum = 1
AND bu5.ispecname = 'GLMST'
AND to_number(substr(bu5.usrdata, 7, 2)) = fund_id_int
GROUP BY
bu5.usrdata
ORDER BY
bu5.usrdata
LOOP
PIPE ROW(cur_row);
END LOOP;
END Fund_Amount;
END financial_reports;
Error … (This works without the parameter)
Error starting at line 43 in command:
select * from table(financial_reports.Fund_Amount(1) )
Error at Command Line:1 Column:14
Error report:
SQL Error: ORA-22905: cannot access rows from a non-nested table item
Any help would be greatly appreciatedtry renaming your parameter so as not to confuse with what you are using in your column " to_number(substr(bu5.usrdata, 7, 2)) AS FUND_ID":
CREATE OR REPLACE PACKAGE BODY financial_reports AS
FUNCTION Fund_Amount (pFund_Id IN NUMBER)
RETURN financial_reports.Fund_Amount_Table
pipelined parallel_enable IS
cur_row financial_reports.Fund_Amount_Record;
fund_id_int NUMBER;
BEGIN
fund_id_int := pFund_Id;
FOR cur_row IN ( SELECT to_number(substr(bu5.usrdata, 1, 1)) As SECTION_ID,
to_number(substr(bu5.usrdata, 2, 1)) As SUB_SECTION_ID,
to_number(substr(bu5.usrdata, 4, 2)) AS LINE_NUMBER,
to_number(substr(bu5.usrdata, 7, 2)) As FUND_ID,
sum(be.amt) AS AMOUNT
FROM linc.budgetdb_usr5@stjohnsfp bu5
JOIN linc.budgetdb_event@stjohnsfp be ON bu5.keyvalue = be.acctno
WHERE bu5.keyvalue like '__-__-__-____-____-_____'
AND bu5.usrdata like '__-__-__'
AND bu5.fieldnum = 1
AND bu5.ispecname = 'GLMST'
AND to_number(substr(bu5.usrdata, 7, 2)) = fund_id_int
GROUP BY bu5.usrdata
ORDER BY bu5.usrdata ) LOOP
PIPE ROW(cur_row);
END LOOP;
END Fund_Amount;
END financial_reports; -
Need help running a function in a package
Hi,
I am trying to execute a function called "IsGuest" which is stored in a package called "PK_USER_ROLE". This procedure returns a boolean as a result. Here is the PHP code in the web page I am using:
echo "<br/>Test to execute a stored procedure";
$s = oci_parse($conn, "begin :ret := PK_USER_ROLE.IsGuest(:userid); end;") or die ('Can not parse query');
$myid = "huppe";
oci_bind_by_name($s, ':ret', $r, 40);
oci_bind_by_name($s, ':userid', $myid);
oci_execute($s);
echo "<br/>result=".$r;
echo "<br/>Completed<br/><br/>";
oci_free_statement($s);
oci_close($conn);
In Oracle, here is the package definition:
create or replace
PACKAGE PK_USER_ROLE IS
function IsGuest (i_unique_id in varchar2) return boolean;
END;
All I get back when I view the PHP file in the browser is:
Test to execute a stored procedure
result=
Completed
PHP 5.3.8
Oracle 11g
OCI8 extension
Any help would be appreciatedI find it helpful to turn on errors and warnings in php.ini during
development.
display_errors = On
error_reporting = E_ALL | E_STRICTor use the ini_set() equivalents in your script. For production,
make sure errors are logged but not displayed to users.
Your script then gives:
$ php54 t.php
Test to execute a stored procedurePHP Warning: oci_execute(): ORA-06550: line 1, column 15:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored in /tmp/t.php on line 10
Warning: oci_execute(): ORA-06550: line 1, column 15:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored in /tmp/t.php on line 10See the comment below the table in
http://docs.oracle.com/cd/E11882_01/appdev.112/e10646/oci03typ.htm#CEGIEEJI
+"The following two types are internal to PL/SQL and cannot be returned as values by OCI:+
+Boolean, SQLT_BOL+
+Record, SQLT_REC"+
Since PHP OCI8 is written in OCI, this limitation is inherited.
Try something like:
$s = oci_parse($conn, "begin if (IsGuest(:userid) = true) then :ret := 1; else :ret := 0; end if; end;") or die ('Can not parse query'); -
Procedures/functions inside a package
Hi
Is there any database table when you can see the procedures/functions ids for each package? I mean a table similar to dba_objects
thanksDid you try
SQL> desc <package name> -
Toad- See functions inside packages.
I use Toad for my Oracle data bases. So here i have oracle packages which i can see by clicking 'Packages' button in Toad. I have functions in those packages but i can't see those functions. When i scroll over to 'Functions' button its all empty. I get "insufficient privileges" note if i am locked to it but that not the case i am assuming. How do i see the code in for a particular function inside a package. Help me. Thanks in advance.
>
I use Toad for my Oracle data bases. So here i have oracle packages which i can see by clicking 'Packages' button in Toad. I have functions in those packages but i can't see those functions. When i scroll over to 'Functions' button its all empty. I get "insufficient privileges" note if i am locked to it but that not the case i am assuming. How do i see the code in for a particular function inside a package.
>
You don't. You can see the entire package code by expanding the package body in the navigation tree. Then you can select your function in the tree and double-click it and in the editor you will be positioned at that function.
The functions and procedure tabs are for standalone objects. -
Call function inside running class
Hey All,
i have a two question in classes.
1- i have class and i called its before and its running on runtime. i need to call function inside this class from another class, but without call the first one again, because if i called it, it will run default class function again
is this doable ?
2- What super() mean ?
Thanks a lot.this is the default call, and when i call the method by this way its will run the default class function before call the method.
here my example:
i need to call checkboxes function in ChannelsMain class without pass by the grey script.
Note: the call_cb is working and the trace is working
so i now the class is running, i need to call the checkboxes without ( var ci:YourClass = new YourClass(); )
package com.link
import fl.controls.CheckBox;
import flash.events.*;
public class ChannelsMain
var cbLength:uint = Main.PV.channel_id.length;
public function ChannelsMain()
// constructor code
for (var i:int = 0; i < cbLength; i++)
var cb:CheckBox = new CheckBox;
cb.name = Main.PV.channel_id[i];
cb.label = Main.PV.channel_name[i];
cb.x = 50;
cb.y = 50 + i * 30;
cb.addEventListener(Event.CHANGE,call_cb);
Main.MS.addChild(cb);
//call xml function
if(i == cbLength - 1)
new ChannelsXML();
private function call_cb(evt:Event)
trace(evt.currentTarget.name,evt.currentTarget.selected);
public function checkboxes(evt)
trace(evt); -
Can i create any procedure or function inside a oracle reserve package?
Hi!
Can i create any procedure or function inside a oracle reserve package. Suppose, I want to create a function called x in the dbms_output package. Can i do that? Or can i extend the features of this package and create/derived a function from it like we extend any class in JAVA. I'm not sure - whether this is at all possible. I'll be waiting for your reply.
Thanks in advance.
Satyaki De.No, but you can write a wrapper package and use that instead of using the Built-In package directly. So, instead of calling DBMS_OUTPUT, you call your own Package.
Steven Feuerstein wrote a wrapper for DBMS_OUTPUT, called P:
Re: DBMS_OUTPUT.PUT_LINE -
Use a package function inside a select of the same package
Hi.
How can i use a function defined inside a package, with a select used inside that same package ?
Example
... package example
CREATE OR REPLACE PACKAGE BODY pkg_example
AS
FUNCTION sum_two_values(p_val1 NUMBER,p_val2 NUMBER) RETURN NUMBER
IS
BEGIN
RETURN p_val1 + p_val2;
END sum_two_values;
FUNCTION use_another_function_example RETURN VARCHAR2
IS
v_value NUMBER;
BEGIN
SELECT sum_two_values(2,2) INTO v_value FROM dual;
RETURN 'waaaazzzzupppppp'
END use_another_function_example;
END pkg_example;
This will not work
-- SELECT sum_two_values(2,2) INTO v_value FROM dual;
How can i call a function inside a select statement, a function of the same package where the query is being called.
(i have Oracle 9.2x)
Cheers.are you sure? you are not using package1, you are using pack1
SQL> CREATE OR REPLACE PACKAGE package1
2 IS
3 FUNCTION f1
4 RETURN NUMBER;
5
6 FUNCTION f2
7 RETURN NUMBER;
8 END;
9 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY package1
2 IS
3 a NUMBER;
4
5 FUNCTION f1
6 RETURN NUMBER
7 IS
8 BEGIN
9 RETURN 1;
10 END;
11
12 FUNCTION f2
13 RETURN NUMBER
14 IS
15 BEGIN
16 SELECT package1.f1
17 INTO a
18 FROM DUAL;
19
20 RETURN a;
21 END;
22 END;
23 /
Package body created.
Why not just this
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE PACKAGE BODY package1
2 IS
3 a NUMBER;
4 FUNCTION f1
5 RETURN NUMBER
6 IS
7 BEGIN
8 RETURN 1;
9 END;
10 FUNCTION f2
11 RETURN NUMBER
12 IS
13 BEGIN
14 a:= f1;
15 RETURN a;
16 END;
17* END;
SQL> /
Package body created.formatted
Message was edited by:
devmiral -
Query for getting all function and procedure inside the packages
hi All
Please provide me Query for getting all function and procedure inside the packages
thanksAs Todd said, you can use user_arguments data dictionary or you can join user_objects and user_procedures like below to get the name of the packaged function and procedure names.
If you are looking for the packaged procedures and functions source then use user_source data dictionary
select a.object_name,a.procedure_name from user_procedures a,
user_objects b
where a.object_name is not null
and a.procedure_name is not null
and b.object_type='PACKAGE'
and a.object_name=b.object_name -
Multiple SQL task objects inside a package object is not generating proper DTSX
I am programmatically adding multiple ExecuteSQLtask objects inside a package. I am specifying all the required properties to the ExecuteSQLtask objects. However, when I save the package object to dtsx, the package looses the properties of some
of the ExecuteSQLtask object.
In the below example, I have created 3 ExecuteSQL task objects using the function AddSqlTask. However, once you run it, one of the objects will loose its properties. What makes it more weird is the fact that sometimes, object 1 looses the properties,
some times, its object number 2. Its random. I know that these objects are COM objects. Is there something I need to careful of when setting the properties ? Why are the values lost when I save them to DTSX ?
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.FileSystemTask;
using Microsoft.SqlServer.Dts.Tasks.BulkInsertTask;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask;
using Microsoft.SqlServer.Dts.Tasks.ExecutePackageTask;
namespace PackageCreator
class Program
static void Main(string[] args)
#region Package 1
Package package1 = new Package();
#region ConnectionString
AddSqlConnection(
package1,
ConfigurationManager.AppSettings["ServerHostName"],
ConfigurationManager.AppSettings["SqlServerDefaultDB"]
#endregion
AddSqlTask(package1, "P1 - Task1");
AddSqlTask(package1, "P1 - Task2");
AddSqlTask(package1, "P1 - TaskFinal");
#region Add Dependencies
package1.PrecedenceConstraints.Add(
package1.Executables[0] as TaskHost,
package1.Executables[1] as TaskHost
package1.PrecedenceConstraints.Add(
package1.Executables[1] as TaskHost,
package1.Executables[2] as TaskHost
#endregion
#endregion
#region Package 2
Package package2 = new Package();
#region ConnectionString
AddSqlConnection(
package2,
ConfigurationManager.AppSettings["ServerHostName"],
ConfigurationManager.AppSettings["SqlServerDefaultDB"]
#endregion
AddSqlTask(package2, "P2 - TaskFinal");
#region ExecutePackageTaskClass
Executable exec1 = package2.Executables.Add("STOCK:ExecutePackageTask");
TaskHost th = exec1 as TaskHost;
ExecutePackageTask myTask = th.InnerObject as ExecutePackageTask;
myTask.PackageID = package1.ID;
#endregion
#region Add Dependencies
package2.PrecedenceConstraints.Add(
package2.Executables[0] as TaskHost,
package2.Executables[1] as TaskHost
#endregion
#endregion
//new Ispac(package1, package1.ID).DeployAndRun();
SavePackage(package1);
SavePackage(package2);
var packageList = new List<Package>();
packageList.Add(package1);
packageList.Add(package2);
new IspacPackageCollections(packageList).DeployAndRun();
Console.Read();
private static void AddSqlTask(Package package, string component)
//Thread.Sleep(5000);
package.Executables.Add("STOCK:SQLTask");
ExecuteSQLTask executeSQLTask = (package.Executables[package.Executables.Count - 1]
as TaskHost).InnerObject
as ExecuteSQLTask;
executeSQLTask.Connection = package.Connections[0].ID;
executeSQLTask.SqlStatementSource = "insert into [dbo].[SupersetPackageDependencies] (Component) values ('" +
component + @"')";
private static void SavePackage(Package package)
string packageNetworkLocation = @""
+ ConfigurationManager.AppSettings["packageNetworkLocation"]
+ @"\" + package.ID + ".dtsx";
new Application().SaveToXml(
packageNetworkLocation,
package,
null
//new Application().SaveToSqlServer(
// package,
// null,
// "ANUPN8470P",
// null,
// null
#region AddConnectionManager
private static ConnectionManager AddSqlConnection(Package package, string server, string database)
return AddConnection(
package,
"OLEDB",
String.Format(
CultureInfo.InvariantCulture,
"Provider=SQLOLEDB.1;Data Source={0};Persist Security Info=False;Initial Catalog={1};Integrated Security=SSPI;",
server,
database)
private static ConnectionManager AddConnection(Package package, string type, string connectionString)
ConnectionManager manager = package.Connections.Add(type);
manager.ConnectionString = connectionString;
manager.Name = String.Format(
CultureInfo.InvariantCulture,
"{0} Connection",
type);
return manager;
#endregion
public static void AddExecuteSqlTask(
Package _package,
string _componentId
_package.Executables.Add("STOCK:SQLTask");
// Get the task host wrapper
ExecuteSQLTask executeSQLTask = (_package.Executables[_package.Executables.Count - 1]
as TaskHost).InnerObject
as ExecuteSQLTask;
#region Set required properties
executeSQLTask.Connection = _package.Connections[0].ID;
executeSQLTask.SqlStatementSource = "insert into [dbo].[SupersetPackageDependencies] (Component) values ('" +
_componentId + @"')";
#endregion
//return executeSQLTask;Why you do not tell what properties get lost?
And why is the same get repeated (you want parallel?):
package1.Executables[0] as TaskHost,
package1.Executables[1] as TaskHost
package1.PrecedenceConstraints.Add(
package1.Executables[1] as TaskHost,
package1.Executables[1]
And why not to add them
like
package1.PrecedenceConstraints.Add(
package1.Executables[0] as TaskHost);,
package1.PrecedenceConstraints.Add( package1.Executables[1] as TaskHost
Arthur
MyBlog
Twitter -
How to call PL/SQL function inside column in entity
Hello,
How can I do next:
- Crete entity from existing table in database, but one column in the table gets value from function. Function is written in oracle PL/SQL language and it is located inside some package on database.
Application should run LCDS3 and tomcat.
All help is appricitatedAnil,
I'm using LCDS3, and here is what I trying to do (for example):
- I have on Oracle DB table REGION, with columns: Code, State, Population.
- I want to create entity that contains same columns as table REGION (Code, State, Population) and to have addition column RegionName witch get value from PL/SQL function (loacated in package "common" on DB) "common.fgetRegionName(Code)".
Can you explain me how to create that entity.
Thanks
Almir
Maybe you are looking for
-
G/L Account Asignment to Valuation calss
Hi all , Where do we assign G/L A/c assignment to valuation class and ex : during goods reciept for 101 , how are posting keys determined ? what is the relevance of feild status group in Account determination 89 for Inventory 86 for GR/IR... etc than
-
Using OCX, OLE or DDE with forms
Hi, In the near future, I will have to interface with a program written in Visual Basic. This program will have to send me a command to a form already open. My form will have to capture the parameters and do an action (ex. calling another form). If s
-
Just bought the 80 gig Classic and have already had issues. See http://discussions.apple.com/thread.jspa?threadID=1243711. Finally got this resolved and synched the iPod to iTunes. Now, I can't get the d**n thing to connect again. The screen says CON
-
Problem inserting record using INSERT INTO
I am an amateur web builder using some ColdFusion functionality to access information on an Access database. I know very little about ColdFusion syntax, but I'm using Dreamweaver CS3 to help generate most of the code. I'm working on an insert record
-
Hi All, in our bw sysytem the fiscal period text is not displaying correctly.i.e for period 11.2006 it is displaying as feb 2006.it should display feb 2007. my fiscal variant is V3. can any body help me. Regards, sekhar