Can we create a procedure inside a procedure

DB version:11g
hi ,
Just wanted to ask you guys like can we create a procedure inside a procedure...if not is there any alternative??
in db2 it is allowed so do oracle support this????
thanks

You probably would have been able to tell quicker if you'd just given it a go yourself.
As Justin showed it's perfectly possible, though I don't personally subscribe to Justin's view that it's rarely appropriate. I go on the principle that if the functionality of a procedure/function is to be used in more than one place then it should be declared independently, but if it's a case of writing a procedure that has to perform a lots of functionality, some of which may be re-used several time within that procedure, then breaking that down into nested procedures for modularity and re-use within it is good practice and makes for more readable and maintainable code.
So, I would say it's more a case of "it depends" and good design will dictate whether procedures should be nested or seperate.

Similar Messages

  • 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

  • How can I create stored procedure?

    I am new in this field, I was reading in this web site on how to create stored procedure,and this is what I did :
    SQL> CREATE PROCEDURE test.proc1 (n IN NUMBER)
    2 AS BEGIN
    3 select * from districts
    4 where doe = n;
    5 END;
    6
    Please direct me. I don't know if I am wrong or right, test is the name of the database, and proc1 is the stored procedure that I want to create, why when I hit Enter after END; I got the number 6.
    How can I call this stored procedure, if it works.
    Thanks in advance
    null

    Some reading and training might prove useful. Even if you are using Linux, this forum is no place for a question like that.

  • How can I create packages procedure & function in user-define Library

    hi.
    i am already created packages procedure & function in database and use so on.
    now i would like to create these in library file.
    please anyone give me example of any procedure or function to store in library.
    thanks
    Ali

    <FONT FACE="Arial" size=2 color="2D0000">> please send me one simple example for create library
    then create any function in library.
    2nd is any package can be create in library or not??
    Thanks S.K
    AliHave you checked the link?
    A simple example is provided.
    I think What I understood from your post is that, you want to put function/ Proc and want to call that as Library ..
    Which is not  possible.
    For exampel an external routine is a third-generation language procedure stored in a
    dynamic link library (DLL), registered with PL/SQL, and called by the DBA to perform
    special-purpose processing.
    In Unix a dynamic link library is known as a shared object (so).
    At run time, PL/SQL loads the library dynamically, then calls the routine as if it were a
    PL/SQL subprogram. To safeguard our database, the routine runs in a separate address
    space, but it participates fully in the current transaction. Furthermore, the routine can
    make a call back to the database to perform SQL operations.
    To identify a DLL we have to use CREATE LIBRARY command.
    The CREATE LIBRARY command is used to create a schema object, library, which
    represents an operating-system shared library, from which SQL and PL/SQL can call
    external third-generation-language (3GL) functions and procedures.
    Learn something more on External Procedures
    -SK
    </FONT>

  • How can i create stored procedures dynamically?

    I have tried to create a stored procedure building a string with the PL/SQL code needed to create the procedure. If i run the code using SQL+ works fine, but using the following code:
    Public Sub CreateStoredProcedure()
    Dim strSql As String
    strSql = "CREATE OR REPLACE PACKAGE OPSPRUEBAS AS " & vbCrLf
    strSql = strSql & vbTab & "PROCEDURE consulta (resultado OUT VARCHAR2); " & vbCrLf
    strSql = strSql & "END OPSPRUEBAS; " & vbCrLf
    strSql = strSql & "/ " & vbCrLf
    strSql = strSql & ". " & vbCrLf
    strSql = strSql & "CREATE OR REPLACE PACKAGE BODY OPSPRUEBAS AS " & vbCrLf
    strSql = strSql & "PROCEDURE consulta (resultado OUT VARCHAR2) IS " & vbCrLf
    strSql = strSql & "oc_ref" & vbTab & vbTab & "REF Content_Ontology; " & vbCrLf
    strSql = strSql & "oc" & vbTab & vbTab & "Content_Ontology; " & vbCrLf
    strSql = strSql & "ori" & vbTab & vbTab & "role_def; " & vbCrLf
    strSql = strSql & "ori_ref" & vbTab & vbTab & "ref role_def; " & vbCrLf
    strSql = strSql & "conce" & vbTab & vbTab & "concept; " & vbCrLf
    strSql = strSql & "conce_ref" & vbTab & "REF concept; " & vbCrLf
    strSql = strSql & "b" & vbTab & vbTab & "boolean; " & vbCrLf
    strSql = strSql & "BEGIN " & vbCrLf
    strSql = strSql & "b:=false; " & vbCrLf
    strSql = strSql & "select REF(oi) into ori_ref from rol_table oi where oi.name='Playing'; " & vbCrLf
    strSql = strSql & "select deref(ori_ref) into ori from dual; " & vbCrLf
    strSql = strSql & "select REF(oi) into oc_ref from c_ontologies oi where oi.web_source_prop=websource('FilmContentOntology'); " & vbCrLf
    strSql = strSql & "select deref(oc_ref) into oc from dual; " & vbCrLf
    strSql = strSql & "if oc.if_has_co_class('Film')='TRUE' AND " & vbCrLf
    strSql = strSql & "oc.if_has_co_class('theater')='TRUE' AND " & vbCrLf
    strSql = strSql & "oc.if_has_co_relationship('is_scheduled')='TRUE' AND " & vbCrLf
    strSql = strSql & "oc.if_has_co_attributes('Film', lista('is_scheduled', 'title', 'actor'))='TRUE' AND " & vbCrLf
    strSql = strSql & "oc.if_has_co_attributes('theater', lista('theatername', 'address', 'email'))='TRUE' " & vbCrLf
    strSql = strSql & "then resultado:='FilmContentOntology'; " & vbCrLf
    strSql = strSql & "else resultado:='No Existe'; " & vbCrLf
    strSql = strSql & "end if; " & vbCrLf
    strSql = strSql & "END consulta; " & vbCrLf
    strSql = strSql & "END OPSPRUEBAS; " & vbCrLf
    strSql = strSql & "/ " & vbCrLf
    strSql = strSql & ". " & vbCrLf
    strSql = strSql & "COMMIT;" & vbCrLf
    TextBox2.Text = strSql
    'Dim myConnectionString As String = "User Id=system;Password=daniel;Data Source=websogo;"
    'Dim oraConn As Oracle.DataAccess.Client.OracleConnection = New Oracle.DataAccess.Client.OracleConnection(myConnectionString)
    Dim myCmd As New System.Data.OleDb.OleDbCommand()
    Dim MyConnection As New System.Data.OleDb.OleDbConnection()
    MyConnection.ConnectionString = "Provider=MSDAORA;Data Source=websogo;password=daniel;User ID=system"
    MyConnection.Open()
    'oraConn.Open()
    myCmd.Connection = MyConnection
    myCmd.CommandType = CommandType.Text
    myCmd.CommandText = strSql
    myCmd.ExecuteNonQuery()
    'Dim e As Oracle.DataAccess.Client.OracleException
    'Try
    ' myCmd.ExecuteNonQuery()
    'Catch e
    ' Dim error1 As Oracle.DataAccess.Client.OracleError
    ' error1 = e.Errors.Item(0)
    ' Textbox3.Text = error1.Source & " " & error1.Message
    'End Try
    MyConnection.Close()
    End Sub
    I've tried using Microsoft ODP, OLEDB and Oracle's ODP.NET
    Also tried to catch any error but there are no errors!
    Has anybody achived a successful dynamically stored procedure creation using .net?
    thanks in advance
    Dan

    I'm trying to create Stored Procedures via .NET and able to do so but when I look in Oracle Enterprise Manager Console, the Stored Procedures are marked as INVALID... If I edit the Stored Procedure (i.e. delete a space or something minor) and SAVE then it compiles fine.....
    Any ideas ????
    will be using this against 9i & 10g db

  • Can not create a sequence inside procedure

    I have a procedure like this:
    CREATE OR REPLACE PROCEDURE P_reset_Sequences AS
    BEGIN
    execute immediate '
    DROP SEQUENCE ADMIN_AUTORESPONSES_SEQ';
    execute immediate '
    CREATE SEQUENCE ADMIN_AUTORESPONSES_SEQ
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    NOCYCLE
    NOCACHE
    ORDER
    END P_reset_Sequences;
    When I execute this procedure to reset sequence ADMIN_AUTORESPONSES_SEQ, there an erro: insufficient privileges. But owner of this procedure has DBA privilege.
    Pls, help me!

    There are two reasons to reset a sequence in code.
    You could run out of numbers or you think you can use sequences as a gap free counter.
    Running out of numbers is a problem every [3,000,000,000,000,000,000,000,000,000 years|Re: What kind of transaction in procedure? or thereabouts.
    Looking at the sequence definition with NOCACHE , ORDER and an INCREMENT by 1 it appears the OP mistakenly believes you can use a sequence as a gap free counter ignoring rollbacks, exceptions and shutdowns amongst other things, when all those setting have really done is [make the sequence as slow as possible|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6393918681776].

  • Can you create an assertion inside the current UI map you have already created and how?

    Hi all
    I have been following the best practice guideline of creating multiple UI maps. The problem is now when using the Code UI builder to create Assertions for my test methods, as soon as you create an assertion it creates and places it into a default UI map.
    I want it inside the UI map I created for that particular test. I could copy the code out of the designer into the UI map I have for the test but I fear this will create problems now and further down the line or not work.
    Is there a process for this?
    Cheers
    Rob

    Use the context (right-click) menu in solution explorer on the UI Map (ie on the ".uitest" file) where you want the assertions, then select "Edit with Coded UI test builder".
    When using multiple UI maps DO NOT right click in the source files and select the "Generate code for Coded UI test". If you do then, as you have found, the code will be added to the default "UImap.uitest" file, creating one if needed
    and with no warning that it is doing so. (See also
    http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3378897-choosing-the-uimap-when-recording-tests )
    Regards
    Adrian

  • Can not create a todo inside email message

    Recently I can't make any new to-do directly inside email message (see screenshot). The button is still clickable, but there are no to-do checkmark, only the yellow paper.
    http://img.skitch.com/20090724-tcr65xw2qht4sdmq4xhd3uun6q.png
    Usually this is my standard workflow for creatinga a todo, and then it will sync to my GTD app and iCal.
    Anyone have the same problem?

    Hi,
    Yes, I have the same problem. I posted a thread about this too (sorry I didn't see your thread until now!).
    http://discussions.apple.com/message.jspa?messageID=9905859#9905859
    Absolutely nothing happens when I click on the To Do button, or when I use the contextual menu on some highlighted text.
    I haven't received any feedback yet.
    FP

  • Cannot create stored procedure in Azure SQL database

    When I try to create a stored procedure using Management Studio
    (Snippet follows
    use
    PPSC_Sky_Data
    go
    /****** Object:  StoredProcedure [dbo].[sp_RegisterProd]    Script Date: 17-02-2015 17:52:50 ******/
    SET
    ANSI_NULLS
    ON
    GO
    SET
    QUOTED_IDENTIFIER
    ON
    GO
    CREATE
    proc [dbo].[sp_RegisterProd]
    @inputMachid nvarchar(50),@inputDomainname
    nvarchar(255),@inputwsid
    nvarchar(255),@inputipv4
    nvarchar(50),
    @custno
    as
    nvarchar(50),@email
    as 
    nvarchar(50),@telephone
    as
    nvarchar(50),@RegType
    as
    int
    (end of snippet)
    It fails with message 40508 - (not allowed to switch between databases) then tells me I am not authorized to create an SP in the Master db.
    So....
    How can I create a procedure in AZURE Sql?
    Thanks
    Murray
    M Whipps

    Hi 9gwcycn,
    Creating stored procedures is not allowed in Master Database. You have to switch to Database
    PPSC_Sky_Data manually, use statement is not supported. After that could you please confirm again? As Creating and altering Stored procedures work fine from my SSMS.
    If you have any feedback on our support, please click
    here.
    Eric Zhang
    TechNet Community Support

  • Can we create pl/sql code over database link?

    Hi All,
    We are using Oracle 9i database.
    I want to know if we can create or modify pl/sql code (procedue, package, etc) over the database link? That means - can we create a procedure in remote database using the db link?
    Thanks,
    Dnyanesh

    yes, I can connect to the remote database directly and create/modify the packages.
    But I want the users not to create them using the db link.
    Is there any way to create the pl/sql package over database link?
    Thanks,
    Dnyanesh

  • How can I create a method with throws  instruction

    Hello Everybody!
    How can I create this method inside WebDynpro.
    I enter "throws CloneNotSupportedException" manually an it removes always.
    What is wrong ?
    public java.lang.Object clone( ) throws CloneNotSupportedException{
        //@@begin clone()
         __Tdag__Is_Charactconfig that= (__Tdag__Is_Charactconfig)super.clone();
           return that;
        //@@end
    Regards
    sas

    I only checked in my 7.1 IDE and there this section exists.
    If it does not exist in your IDE, just create the method manually in the //@@begin others ... //@@end user-coding-area at the end of the controller class. This solves the issue for methods that are called from inside the controller. For public methods to be called from other controllers, this will not help.
    Armin

  • Can we call a package inside a package

    Dear Sir
    Can we create a package inside a package or can we call a a package inside a package?.If yes.How we can create and call a package inside a package?
    Regards
    Thakur Manoj

    [email protected] wrote:
    Dear Sir
    Can we create a package inside a package NO, you cant do that.
    or can we call a a package inside a package?.YES, you can do that. Just call it. <package_name>.<procedure_or_function_name>

  • Creating a method inside a constructor

    Can we create a method inside a Constructor??

    Encephalopathic wrote:
    uj_ wrote:
    Pascal doesn't have classes so it has no constructors either.Its latest incarnation, object pascal / Delphi did. I was working with that in the early '90s.Isn't the relation between Pascal and Object Pascal like that of C to C++?
    C didn't become C++. It stays C. And Pascal didn't become Object Pascal. It stays Pascal.
    So Pascal doesn't have classes or constructors. A company driven Pascal derivate called Object Pascal has.

  • Display results from dynamic query created and executed inside procedure

    Hi;
    I have created this code:
    CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, VAR3 IN VARCHAR2) AS
    -- Do something
    -- That ends up with a variable holding a query.... (just an example)
    MainQuery :='select sysdate from dual';
    end RunDynamicQuery;
    How can I run this procedure and see the result on the dymanic query generated inside it?
    BEGIN
    compare_tables_content('VAR1','VAR2','VAR3');
    END;
    Expected Output for this given example:
    20-05-2009 11:04:44 ( the result of the dymanic query inside the procedure variable MainQuery :='select sysdate from dual';)
    I tested with 'execute immediate':
    CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, filter IN VARCHAR2) AS
    -- Do something
    -- That ends up with a variable holding a query.... (just an example)
    MainQuery :='select sysdate from dual';
    execute immediate (MainQuery );
    end RunDynamicQuery;
    BEGIN
    compare_tables_content('VAR1','VAR2','VAR3');
    END;
    Output:"Statement processed'' (no sysdate displayed ! )
    Please consider that the collums in the query are always dynamic... PIPELINE Table would not work because I would need to define a container, example:
    CREATE OR REPLACE TYPE emp_tabtype AS TABLE OF emp_type;
    FUNCTION RunDynamicQuery (p_cursor IN sys_refcursor)
    RETURN emp_tabtype PIPELINED
    IS
    emp_in emp%ROWTYPE;
    BEGIN
    LOOP
    FETCH p_cursor
    INTO emp_in;
    EXIT WHEN p_cursor%NOTFOUND;
    PIPE ROW (...)

    That would be a nice solution, thanks :)
    ''For now'' I implemented like this:
    My dynamic query now returns a single string ( select col1 || col2 || col3 from bla)
    This way I don't have dynamic collumns issue, and from business side, this ''string'' format works for them.
    This way I can use the pipelines to get the result out...
    OPEN myCursor FOR MainQuery;
    FETCH myCursor
    INTO myRow;
    WHILE (NOT myCursor%notFound) LOOP
    PIPE ROW(myRow);
    FETCH myCursor
    INTO myRow;
    END LOOP;
    CLOSE myCursor;

  • Can I create a table in a procedure submitted to job queue?

    I have created a package (with AUTHID CURRENT_USER) where some of the procedures create temporary tables to facilitate processing. These procedures run just fine when executed directly from within an anonymous block at the SQL*PLUS level. However, when I submit the procedures to the job queue (via DBMS_JOB.SUBMIT), the job is submitted successfully but fails when run. Investigating the Alert Log shows an error of insufficient privilege on the CREATE TABLE command in the procedure.
    QUESTION:
    Can I create a table from a procedure running in the Job Queue? If so, then how to get it to work? Does the job run in a different environment that needs Create Table privileges set to my schema?
    Thanks for any info you can provide.
    John

    FYI: Found the problem. In the Administrator's Guide (of course not in the supplied packages documentation about DBMS_JOB) I found:
    "How Jobs Execute
    SNP background processes execute jobs. To execute a job, the process creates a session to run the job.
    When an SNP process runs a job, the job is run in the same environment in which it was submitted and with the owner's default privileges.
    When you force a job to run using the procedure DBMS_JOB.RUN, the job is run by your user process. When your user process runs a job, it is run with your default privileges only. Privileges granted to you through roles are unavailable."
    And of course we had set up our users to get all privileges through Roles, so CREATE TABLE wasn't one of my DEFAULT PRIVILEGES!
    It sure would be nice if Oracle documentation could get its act together and provide ALL information about a topic in a logical place. The effort to find the information about privileges occurred after it took me 1/2 hour to figure out why my submissions were failing - I didn't have the ';' included in the quoted string for the procedure to be called - which I only figured out after looking at the code for DBMS_JOB where it made the note to make sure you include the ';'. Wouldn't it be good to have that MINOR DETAIL mentioned in the description of DBMS_JOB.SUBMIT?????

Maybe you are looking for

  • Java.util.NoSuchElementException Error

    when i am executing my servlet program tha i got this error java.util.NoSuchElementException      at Scanning.scan(googlewsd.java:262)      at googlewsd.doGet(googlewsd.java:67)      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) wha

  • ITunes CD Burn error (media too fast)??

    I upgraded to the latest iTunes version and now Im getting errors when I try to burn a playlist. I havent burned a cd off this computer in a long time, so Im not sure if it's iTunes. However, the error, if I remember correctly,said iTunes is unable t

  • Clearing of impersonal account items

    Hello, how can I clear impersonal account items vs. another impersonal account? Is it possible with FB05 in RFBIBL00? Regards Norbert

  • How to establish the connection - Best Practice

    Following is my code for database connection import java.sql.Connection; import java.sql.DriverManager; import oracle.jdbc.driver.OracleDriver; public class DBConnect      private static Connection connection = null;      static           try        

  • BAPI execution in webdynpro returns only a few records

    Hi,         I'm executing a BAPI in my webdynpro application and it is returning only a few records from backend table. When i execute the BAPI in R/3 with the same input i'm getting all the records. In webdynpro i'm getting only 22 records for diffe