Question packets and stored procedures

Been working with Oracle for a month now and I have a question about stored procedures/packages. I created 3 stored procedures and a search function to do some work as follows:
1 load the initial set of data into a table.
2. turn to day of the preceding table columns by using a specific search function.
3. put to update a single column with a value based on grouped subsets of the data in the table.

I divide the latter in separate proceedings to facilitate debugging and validation of each step, but now I want to put them all together and run them sequentially. In my view, there are two ways to do this:
1. create another stored procedure that will run the three in the right order.
2 create a package and move all procedures and functions and call each in the right order.

Don't know which approach is preferable, although I'm leaning towards the first option, any actual experience would be appreciated. Thanks in advance!

Dave

How about option 3:

3 create a package and move all procedures and functions, and then add an additional procedure in the package that calls each in the correct order and call this procedure.

PS. only this last procedure must be in the package spec. All others must be put into the body (and can remain hidden for the code outside the package).

Published by: Toon Koppelaars February 26, 2010 21:07

Tags: Database

Similar Questions

  • Privileges differ between SQL * more and stored procedure

    A user with the dba role can access dba_role_privs. But this is not possible in a stored procedure created by the same user.
    Normally, the example should work fine
    But with Oracle XE 11.02 - cost free database with some limitations - I get error 942

    I show a simple example in SQL * more:

    SQL > r
    1 * select distinct dba_role_privs recipient where the recipient as "SY %.

    DEALER
    ------------------------------
    SYSTEM
    SYS

    SQL > create or replace procedure x as
    2 start
    3 for rec in (select distinct dba_role_privs dealer where the beneficiary as 'SY %')
    4 loop
    5 zero;
    6 end of loop;
    7 end;
    8.

    Warnung: Prozedur wurde mit Kompilierungsfehlern standing.
    English translation: procedure created with compilation errors

    SQL > show error

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    3/14 PL/SQL: statement ignored
    3/43 PL/SQL: ORA-00942: table or view does not exist
    SQL >

    How can I fix?

    Why do you think the example should work properly?

    Normally, regardless of the version, the privileges granted through roles (such as DBA) not available for stored procedures. Stored procedure of a DEFINER rights can only take advantage of the privileges granted directly to the owner of the procedure. Stored procedure of the invoker rights can enjoy privileges granted by a role, but that requires that the appellant has independent privileges to query the table in question (and, in this case, would require dynamic SQL usage).

    Generally, the simplest approach would be to grant the privilege to CHOOSE ANY DICTIONARY to the owner of the procedure.

    Justin

  • Dashboard of the guests and stored procedures

    Hello

    I have 7 guests - 2 which are necessary and others are optional. I created guests from Dashboard and grouped 2 those required in a dashboard command prompt and more optional 5 in an another guest of dashboard. All the guests are assigned to the variables and used in calling a stored procedure in SQL Server. Because I have 2 groups there are 2 go buttons on the page. I found that the order in which I enter data and click on the questions of buttons and will disrupt the call to the proc (i.e. sometimes it brings back data but sometimes she will be not based on recorded fast values).

    I have 2 questions:
    1. is it possible to separate the optional and mandatory guests so I can put them in separate the dashboard sections, but to have only 1 'Go' button to send the data?

    2. among the guests, I would like to be a multiple selection. Is it possible to send the options of multiple selections in a stored procedure? I use the variables to other values, but I've read using a variable for multiple selection is not possible.

    Any help would be appreciated
    Thank you
    UNA

    Issues related to the:
    1. not in the standard, but with a bit of javascript, it is possible
    http://sranka.WordPress.com/2008/11/09/how-to-replace-multi-go-button-prompt-by-one/
    2. it is not possible in 10 g but possible normally as promised to 11 g. You must create camps prompt or a command prompt with the different possibilities to pass a string instead of an array or a list.

    Success
    Nico

  • ADF view object and stored procedure

    Hi all

    I am facing a problem with the view object, the case is, I created a stored procedure with an input and an output parameter

    view object I need to call this procedure inside the request object view and define the attribute transient output parameter

    could you please help me in this case, please give an example

    Thanks in advance

    Mohamed,

    Can you explain your use case to help you.

    Is it possible to convert the stored procedure in function (and change the output parameter to return the parameters) and create a display object using the function.

    Ex: Create a display object "read access only via the SQL query" for the query: SELECT HR. PLSQLTEST2 staff (first_name) OF

    K

  • DbDataAdapter and stored procedures with Oracle cursors,

    Because of the problems I've mentioned here ([PL/SQL stored procedure causes OracleException.. .but only sometimes | https://forums.oracle.com/forums/thread.jspa?threadID=2267290]), I am trying to replace a specific layer of data ODP.NET with the code that uses the related classes, independent provider and DbProviderFactory. Things seemed to go right up to the point where I'm trying to use a DbDataAdapter object to fill a DataSet. The stored procedure, I call looks like this...

    /* - - - - - - - - - - - - - - - - - - - - */
    PROCEDURE GET_SOME_DATA)
    IN_PARAM1 IN VARCHAR2,
    O_RESULTS TO SYS_REFCURSOR);
    /* - - - - - - - - - - - - - - - - - - - - */

    Normally, I could do something like this...

    /* - - - - - - - - - - - - - - - - - - - - */
    var adapter = new OracleDataAdapter (cmd);
    adapter. Fill (ds, cmd (OracleRefCursor). Parameters [1]. (Value);
    /* - - - - - - - - - - - - - - - - - - - - */

    .. .but that is not possible when you use DbProviderFactories since there is no equivalent of the Ref Cursor. I can use a DbDataAdapter instead of an OracleDataAdapter object, but I can't understand how to fill it with the cursor. All the examples I've seen (even the specific Oracle ones) seem to assume one is writing queries like "SELECT FOO FROM BAR" or something like that.

    Am I going about this all wrong? Or is it simply not possible to use a DbDataAdapter to fill a DataSet like this? I was really hoping to be able to use the provider-independent code I could use the System.Data.OracleClient provider with my 9i database and then switch to the Oracle. DataAccess.Client once we have upgrade to 11g. Looks like I'll have to completely replace the data layer code and references. I knew that the former was necessary, but I hope this could be managed by interfaces of independent provider with concrete implementation changed via the config and/or my IoC container.

    NOTE: I found this thread in the forums, but the posters to stop before the point at which they return the sliders and make use of them: [ODP.Net Ref Cursor and DbProviderFactory | https://forums.oracle.com/forums/thread.jspa?messageID=1278007]

    Thank you!

    I did yesterday a similar thing.

    The code was specific ODP.NET (that always, it is and should be), but I didn't rely on a reference to Oracle.DataAccess directly in my particular case:

    The code I ended up with is not very pretty, but it works.

    var refCursorType = Enum.Parse (((dynamic) plant.)) CreateParameter()). OracleDbType.GetType (), "RefCursor");
    dynamic oracleParameter4 = factory. CreateParameter();
    oracleParameter4.Direction = ParameterDirection.Output;
    var piInstance = oracleParameter4.GetType (). GetProperty ("OracleDbType");
    piInstance.SetValue (oracleParameter4, refCursorType, null);

  • Difference between function and stored procedure

    Hi guys, I don't understand the exact difference between a function and a stored procedure. I have a lot of google but still. Can someone explain in simple terms. Thank you.

    Hello

    Here is an example of a user-defined function:

    CREATE OR REPLACE FUNCTION     factorial
    (      in_num       IN     PLS_INTEGER
    )
    RETURN     PLS_INTEGER
    DETERMINISTIC
    IS
    BEGIN
         IF  in_num IS NULL
         THEN
              RETURN     NULL;
         ELSIF in_num <= 1
         THEN
              RETURN  1;
         ELSE
              RETURN  in_num * factorial (in_num - 1);
         END IF;
    END     factorial;
    /
    SHOW ERRORS
    

    This function returns an integer. You can use the function (or, more exactly, the integer returned) everywhere where a whole expression is allowed.
    For example

    SELECT     ROWNUM
    ,     factorial (ROWNUM)     AS f
    ,     loc
    ,     SUBSTR ( loc
                , 1
                , factorial (ROWNUM)
                )          AS s
    FROM     scott.dept;
    

    Output:

    `   ROWNUM          F LOC           S
    ---------- ---------- ------------- -------------
             1          1 NEW YORK      N
             2          2 DALLAS        DA
             3          6 CHICAGO       CHICAG
             4         24 BOSTON        BOSTON
    
  • Insert multiple records in a database using the DB adapter and stored procedure

    Hi all

    I want to insert multiple records in a database using a stored procedure. I wanted to insert these records using a data adapter and data adapter must be called by a mediator.

    Can anyone suggest me some ideas if it's possible with capabtilities OOB in SOA suite or not?

    Thank you for your help in advance.

    Thank you
    Shiv

    The trick is in the stored procedure. You must use a data type that will handle multiple records I use varray. An example can be found in this post.

    Re: Mutiple calls to AppsAdapter (pl/sql) when the payload has multiple records

    When you read the procedure stored in the db adapter wizard looks and xsd / xml if you have maps accordingly.

    see you soon
    James

  • apex_application.g_fxx and stored procedures

    Hi all

    In a block anonymous page process type pl/sql, I try to call a stored procedure that perform a few sentences SQL (update, insert, etc.). What I want is to pass as a parameter to the table that contains the data in a query of sql update report (apex_application.g_fxx ()).

    I created a new type in the database,
    create or replace type artbl in the varray (50) of VARCHAR2 (100);

    and I tried the plsql code:

    declare
    my_arr artbl;
    whole NUM;
    Start
    my_arr: = apex_application.g_f01;
    my_storedproc (my_arr, num);
    end;

    which give the error when you try to save

    1 error has occurred

    * ORA-06550: line 6, column 28: PLS 00382: expression is of the wrong type ORA-06550: line 6, column 4: PL/SQL: statement ignored

    and


    declare
    my_arr artbl;
    whole NUM;
    Start
    my_arr: = apex_application.g_f01 ();
    my_storedproc (my_arr, num);
    end;

    which give the error when you try to save:

    1 error has occurred

    * ORA-06550: line 6, column 11: PLS-00355: table using pl/sql not allowed in this context ORA-06550: line 6, column 4: PL/SQL: statement ignored

    The stored procedure is
    create or replace PROCEDURE my_storedproc
    (IN artbl, num ENTIRE tbl)
    AS
    BEGIN
    BECAUSE me IN 1.num
    LOOP
    -carry out a few sentences making reference to elements - tbl
    END LOOP;
    END MTO_PRUEBA;


    Can someone help me?


    Thank you

    jalba

    Jalba,

    The error is the result of incompatible types. It seems that you have created your types in SQL (in the database) rather than in PL/SQL. You should simply reuse the existing type used in the APEX (see wwv_flow_global spec).

    PROCEDURE my_storedproc
    (IN artbl, num ENTIRE tbl)

    should be

    PROCEDURE my_storedproc
    (IN wwv_flow_global.vc_arr2, num ENTIRE tbl)

    Now you can call it as

    declare
    whole NUM;
    Start
    my_storedproc (apex_application.g_f01 (), num);
    end;

    I hope this helps.

    Greg

  • CFPROCPARAM and stored procedure

    Hello

    I tried to use the MSSQL stored procedure in combination with ColdFusion 9. I use the cfprocparam to transmit data to the stored proc. If I do it in the order how they are declared in the stored procedure, it works fine. But how can I transmit the data with named variables? It was the 'dbvarname' function, but I guess it's obsolete now. Do I have to use the same order in my ColdFusion component? Which makes it quite difficult to manage. I hope there is a solution for transmitting data with named variables.

    Thanks for the replies.

    Does this mean I can't use variables for stored procedures?

    [shakes his head in disbelief]

    I guess that my previous announcement didn't know somehow.

    There is no attribute of CFPROCPARAM DBVARNAME.  It has been removed from the CF after CFMX6 (I think.  "It could have been deleted after CF5).

    So: no, you can't use it.  It does not exist.

    There are docs online for this kind of thing, btw:

    http://help.Adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d 52. html

    --

    Adam

  • disconnected rowset select CachedRowSet of a statement within the stored procedure?

    Hello everyone

    I'm using CachedRowSet returned from a parameterized select statement and it works very well.

    If I put the same select statement in a simple read only then stored procedure I get this exception: "a result set has been generated for the update.

    I'm not trying to update all lines in my code.

    I tried to make the CachedRowSet to be read-only, but this does not help, same error.

    Question 1: a stored procedure returns a single result set can be called to fill a CachedRowSet read-only? (in a similar way to a method of CallableStatement prepareCall with input/output settings).

    Question 2: in general is something to be encouraged for future development or are they deprecated or replaced with something else or better using CachedRowSet, FilteredRowSet (disconnected) and WebRowSet, JDBCRowSet (connected)?

    Thank you very much in advance

    It work? (be sure that your stored procedure done * nothing * before running this query)

    PreparedStatement p = conn.prepareStatement ("{call dbo.p_testCachedJDBCRowSet (?)}" ");

    p.setInt (1, 10);

    CRS CachedRowSetImpl = new CachedRowSetImpl();

    CRS. Populate (p.ExecuteQuery ());

  • Calling stored procedures with parameters with the database connectivity Toolkit

    Hi all

    I'm new to the forum and struggling to find a solution to a particular problem I have in this respect, using the LabVIEW Database Connectivity Toolkit on a project, I am currently working on my work.  I have a database in which I tables and stored procedures with parameters.  Some of these stored procedures have input, output and return parameters.

    I tried to follow this example, but to no avail: http://digital.ni.com/public.nsf/allkb/07FD130746083E0686257300006326C4?OpenDocument

    Such a stored procedure I am working on the implementation is named "dbo.getAllowablePNs", running "SELECT * from DeviceType" (DeviceType is the table).  In this case, it requires no input parameter, it has an output parameter that generates the table [cluster] and has a return parameter that returns an integer value (status code for execution) to show if an error occurred.  The DeviceType table has 3 columns; ID (PK, int not null), PN (nvarchar ((15), null) and NumMACAddresses (int, null).)  I have surpassed many examples and I talk to the support OR try to implement this and similar procedures stored in LabVIEW but have not been successful.  I am able to connect to the database with the VI of open connection without error, but spin in some confusion as a result of this step.  I then try to use the VI of parameter query create to call the stored procedure and set the parameters.  I guess I would then use the Set parameter value for each parameter that is connected to the entry of parameters on the previous query with parameters VI VI?  I am also having some confusion during and after these steps as well.  I would greatly appreciate advice or suggestions that anyone could have in this situation because I am not a SQL expert.  Also, I would be happy to provide more information that might be useful.

    Kind regards

    Jon

    Here's what I use to do this.  I think I had to change him create parameterized query VI for him to work.  There is a post on the forum about this somewhere.

  • Import data dictionary stored procedures

    It's the rewamp of an old archived thread:

    Re: import of data dictionary

    .. relevant even today with DataModeleter 4.1 (standalone) on Oracle 12 c: I seem not to be able to import any stored procedure / function of the well data dictionary that following the steps (see link) and reaching even to the summary confirming the detection of target objects:

    Capture.JPG

    However, at the time of the merger, previews DDL (to import/merge, no generation) says:

    -CREATE THE PROCEDURE0
    -CREATE FUNCTION0

    Am I missing a trivial step?

    THX

    Hello

    I think I know what is the cause of the problem.

    There is a bug in version 4.1 where different types of objects (including functions and stored procedures) do not appear in the tree view to compare if the property "include physical properties to compare the feature ' is not defined.

    So the solution is to ensure that this property is set.  It is on the Data Modeler > DOF > DDL/comparison of preferences page.

    This bug in the next version.

    David

  • Could not import the Pentecost Entity Framework stored procedures

    Hi, I have a problem with Entity Framework 5 and stored procedures. I can add stored procedures to mi with "Update Wizard" solution, but them does not show in the Model Explorer and I can't use my code. I have ODAC 12 c Release 2 installed in my pc.

    There is a bug in the database Oracle 12 c that occurs only with a snap-in database. It is fixed in the next group of patches from database. (bug #17448545)

    There are three workarounds in the meantime:

    (1) to re-create the database without the shared option (no plug-in database)

    (2) install your schema in the database of the container instead of a snap-in database. You will need a user name as C ##HR to do. It is not advisable on a production database.

    Add 3) the section of manually in in the edmx file. Note that this is deleted when you "Generate database from model" or "Update model from database".

    for example:

    ...

    ParameterTypeSemantics = "AllowImplicitConversion" scheme = "SCOTT" >

  • Can not see all the stored procedures in the Entity Data Model Wizard

    I hope it is a simple oversight on my part I try to use the new beta version of odp.net with entity framework support. I can open the Entity Data Model Wizard, give him my information database, and I can choose various tables to use successfully. But in the list where I select the tables, views and stored procedures, the wizard does not see my stored procs or my point of view.

    Does anyone know why he would see the tables but not views or stored procedures? My procs can be found under "packages" If that makes a difference. I tried to create a fictional stored procedure at the level above the title of 'procedures', but it is unclear whether.

    Is it possible for me to debug this from here? The log files, I could watch that would help me?

    Thank you
    Jim

    I belive your Oracle database 10 g such as 9iR2 predates.
    ODP/EF Beta does not list the stored procedures or functions when connect you to a database Oracle 10 g before.

    Readme.txt:
    4. the procedures are not compatible with the DB 9.2.
    Thus, there is no stored procedure listed by the EDM Wizard for 9.2 DBs.

  • Creating views, dynamic SQL within stored procedure

    I'm having a problem with the creation of dynamic views of in a stored procedure. The following declare block works fine:

    DECLARE
    parameter i_nom_table varchar2 (200): = 'abc ';
    xyz cursor script, SELECT step
    STARTING from scripts
    WHERE table_name = i_nom_table parameter
    ORDER BY step CAD;
    l_sql scripts.script%TYPE;
    l_step scripts.step%TYPE;
    l_error VARCHAR2 (200);
    l_code VARCHAR2 (200);
    Start
    XYZ OPEN;
    LOOP
    XYZ-FETCH INTO l_step, l_sql;
    OUTPUT WHEN xyz % NOTFOUND;
    immediately run l_sql;
    insert into ingest_log values (null, sysdate, i_nom_table, l_step, l_sql, 'Success' parameter);
    END LOOP;
    CLOSE XYZ;
    insert into ingest_log values (null, sysdate, parameter i_nom_table, 0, "Accomplished all the steps.", "Success");
    EXCEPTION WHEN OTHERS THEN
    l_error: = substr (SQLERRM, 1, 200);
    l_code: = SQLCODE;
    insert into ingest_log values (null, sysdate, parameter i_nom_table, l_step, l_sql, l_code |) ' - ERROR - ' | l_error);
    END;

    However, if I create a procedure with this block and try to run it I get an insufficient privileges error. Do not know why. All tables, views, procedures are under the same user, and the user that I'm connected as the runtime of the declare block. The user has the following privileges:

    Connect, resource, xdbadmin, s/n

    Any reason you can think of for this? Script values are generally "CREATE OR REPLACE VIEW As.... » ;

    Permissions in Oracle to do indirectly through roles are not available when compiling packages, functions, and stored procedures. Direct subsidies are required during the creation of these objects in the database.

    http://articles.TechRepublic.com.com/5100-10878_11-6183799.html

Maybe you are looking for