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...
Thanks

Thanks 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.

Similar Messages

  • 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.

  • 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;
    -----------------------------------------

  • 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

  • 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

  • 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 appreciated

    try 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;

  • 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
    thanks

    Did 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.

  • 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
    thanks

    As 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

  • Can I call a function in another package?

    Dear all,
    Can I call a function in another package?
    Say I have package A, and package B.
    Is it possible for me to call a function in inside package A, within a function inside package B?
    If yes, what's the syntax.
    Thanks in advance!

    The variable in the calling package that will receive the value of the function in the other package needs to be defined based on that type in the other package directly:
    sql>create or replace package pkg_a
      2  is
      3    type testTable is table of varchar2(10) index by binary_integer;
      4 
      5    function f_a return testTable;
      6  end;
      7  /
    Package created.
    sql>create or replace package body pkg_a
      2  is
      3    function f_a
      4      return testTable
      5    is
      6      v_table testTable;
      7    begin
      8      v_table(1) := 'One';
      9      v_table(2) := 'Two';
    10      return v_table;
    11    end; 
    12  end;
    13  /
    Package body created.
    sql>create or replace package pkg_b
      2  is
      3    procedure p_b;
      4  end; 
      5  /
    Package created.
    sql>create or replace package body pkg_b
      2  is
      3    procedure p_b
      4    is
      5      v_table pkg_a.testTable;  -- this variable has to be based on the type in pkg_a
      6    begin
      7      v_table := pkg_a.f_a;
      8      for i in 1..v_table.count loop
      9        dbms_output.put_line( v_table(i) );
    10      end loop;
    11    end;
    12  end; 
    13  /
    Package body created.
    sql>exec pkg_b.p_b
    One
    Two
    PL/SQL procedure successfully completed.

  • 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 appricitated

    Anil,
    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

  • Bind variable inside a package

    Can we declare a bind variable inside a package specification?
    CREATE OR REPLACE PACKAGE GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE);
    VARIABLE O VARCHAR2(20);
    END GET_EMPLOYEEDETAILS ;
    CREATE OR REPLACE PACKAGE BODY GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE)
    IS
    BEGIN
    SELECT FIRST_NAME INTO F_NAME FROM EMPLOYEES WHERE EMPLOYEE_ID = E_ID;
    DBMS_OUTPUT.PUT_LINE(F_NAME);
    END;
    END GET_EMPLOYEEDETAILS;
    Output:
    ERROR at line 4: PLS-00103: Encountered the symbol "VARCHAR2" when expecting one of the following:
      := . ( @ % ; not null range default character
    The symbol ":=" was substituted for "VARCHAR2" to continue.
    2. IS
    3. PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE);
    4. VARIABLE O VARCHAR2(20);
    5. END GET_EMPLOYEEDETAILS ;
    6. /
    or is there any alternative for bind variables inside an package
    Thanks in advance
    Message was edited by: 1009739

    The "VARIABLE O VARCHAR2(20);" syntax is the way SQLPlus declared bind variables - it is specific to the client. Because PL/SQL packages and procedures are server code that continue past sessions, its only access to the client environment is what the client gives it - it can't go and create a bind variable in the client.
    PL/SQL procedures, functions and packages run from lots of environments, so they cannot access bind variables inside their body - you have to pass any external variables as parameters.
    Anonymous PL/SQL blocks can access bind variables.
    You can declare package public global variables - just leave out that "VARIABLE". E.g.
    CREATE OR REPLACE PACKAGE GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMP.EMPNO%TYPE, F_NAME OUT EMP.ENAME%TYPE);
    O VARCHAR2(20);
    END GET_EMPLOYEEDETAILS ;
    For local variables in your procedure, just put them between the IS and BEGIN. Using them in SQL inside the PL/SQL automatically uses them as a bind variable.
    create or replace PROCEDURE GET_FIRSTNAME(E_ID IN EMP.EMPNO%TYPE, F_NAME OUT EMP.ENAME%TYPE)
    IS
      O VARCHAR2(20);
      O2 VARCHAR2(21);
    BEGIN
      O := 'FR%';
    SELECT ENAME INTO F_NAME FROM EMP WHERE EMPNO = E_ID and ENAME like O;
    O2 := F_NAME || '2';
    DBMS_OUTPUT.PUT_LINE(F_NAME);
    END;
    O is bound in the query.
    To access bind variables from anonymous PL/SQL, first declare them in the calling environment. In SQL Plus that's
    VARIABLE O VARCHAR2(20);
    In Pro*C it's
    EXEC SQL BEGIN DECLARE SECTION;
      char[21] O
    EXEC SQL END DECLARE SECTION;
    Then reference it in anonymous PL/SQL with a colon as prefix:
    BEGIN
    SELECT FIRST_NAME INTO :O FROM EMPLOYEES WHERE EMPLOYEE_ID = E_ID;
    END;
    This only works for anonymous blocks (starting with BEGIN or DECLARE). As I said, PL/SQL procedures, functions and packages cannot see bind variables from the calling environment

Maybe you are looking for

  • IPhoto 09 no longer importing photos

    My iPhoto 09 no longer accepts imported photos. It doesn't matter if I directly import them from my camera, or from other files. I tried to reset my iPhoto information by trashing com.apple.iphoto.plist but this did not help. This program worked the

  • Can you help?

    I'm on a Dell Dimension L1000R running XP. Flashplayer USED to work, but now it doesn't work & I have tried downloading it after uninstalling it with no success. When I download it I get no security warning or gold bar pop-up at the top of the screen

  • Configure a current clamp

    Hello I have a fluke model 80i-110S Current clamp which I want to acquire an analogue signal from. I have a NI-BNC-2111 interface hooked into a PXI 6289 DAQ card.  I have verified that my current clamp is outputting 100 mv / amp of current I have use

  • Update JAR failed with

    Dear all, I am working on J2ME with Forte CE 3.0, when I am trying to "update jar" of a simple "hello World" program, sometimes it works / execute, sometimes it fails with an error "cannot start preverifier". It normally works after I reboot the comp

  • Cron job error

    I get this message in my local mail: Subject: fcron <systab@morgana> /usr/sbin/run-cron /etc/cron.daily Date: Wed, 21 Dec 2011 00:02:47 +0200 (EET) From: [email protected] (fcron) Status: R col: Invalid or incomplete multibyte or wide character it's