Circular references between stored procedures

Hi, i need help about circular references. I have two stored procedures that references like that:
create or replace
procedure ciclico2 as
begin
ciclico1;
end;
create or replace
procedure ciclico1 as
begin
ciclico2;
end;
I can't compile both... so i want to know if there are ways to do that...
Thanks
Marcos (from Argentina... with a medium level english)

¡Hola, Marcos!
If the procedures are in packages (or the same package), you can compile the package specs first, and then the package bodies.
It's simpler if both procedures are in the same package:
CREATE OR REPLACE PACKAGE     pk_fubar
AS
PROCEDURE ciclico1;
PROCEDURE ciclico2;
END       pk_fubar;
SHOW ERRORS
CREATE OR REPLACE PACKAGE BODY     pk_fubar
AS
PROCEDURE ciclico1
IS
BEGIN
        ciclico2;
END        ciclico1
PROCEDURE ciclico2
IS
BEGIN
        ciclico1;
END        ciclico2
END     pk_fubar
SHOW ERRORSOr you could put just one of them in a package.
The important thing is that you can compile a package spec and a package body separately.
You can compile anything that references a function in a package if a valid package spec exists; the package body may be invalid, or it may not exist at all. The package body has to exist and be valid before you run the procedure that calls it, of course, but not necessarily when you compile it.

Similar Messages

  • Diif between Stored procedure and function

    HI
    I want all the differences between Stored procedure and function.
    Even the basic diff is Procedure does not return any value and Function must be...
    Thansk In advance...

    1) Functions are used for computations where as procedures can be used for performing business logic That's an opinion on usage not an actual difference.
    3) You can have DML(insert,update, delete) statements in a function. But, you can not call such a function in a SQL query.Not true. As User defind functons limitations we can use a function that issues DML in a SELECT statement, if it uses the PRAGMA AUTONOMOUS_TRANSACTION.
    4) Function parameters are always IN, no OUT is possibleEasily refutable...
    SQL> CREATE OR REPLACE FUNCTION my_f (p OUT NUMBER) RETURN DATE
      2  AS
      3  BEGIN
      4     p := to_number(to_char(sysdate, 'DD'));
      5     RETURN sysdate;
      6  END;
      7  /
    Function created.
    SQL> var x number
    SQL> var d varchar2(18)
    SQL> exec :d := my_f(:x)
    PL/SQL procedure successfully completed.
    SQL> print d
    D
    18-NOV-05
    SQL> print x
             X
            18
    SQL>
    Stored Procedure :supports deffered name resoultion Example while writing a stored procedure that uses table named tabl1 and tabl2
    etc..but actually not exists in database is allowed only in during creationNot sure what this one is about...
    SQL> CREATE PROCEDURE my_p AS
      2      n NUMBER;
      3  BEGIN
      4     SELECT count(*) INTO n
      5     FROM tab1;
      6  END;
      7  /
    Warning: Procedure created with compilation errors.
    SQL> sho err
    Errors for PROCEDURE MY_P:
    LINE/COL ERROR
    4/4      PL/SQL: SQL Statement ignored
    5/9      PL/SQL: ORA-00942: table or view does not exist
    SQL>
    7) A procedure may modifiy an object where a function can only return a value.An ounce of test is worth sixteen tons of assertion...
    SQL> CREATE OR REPLACE FUNCTION my_f2 RETURN VARCHAR2
      2  AS
      3  BEGIN
      4       EXECUTE IMMEDIATE 'CREATE TABLE what_ever (col1 number)';
      5      RETURN 'OK!';
      6  END;
      7  /
    Function created.
    SQL> exec :d :=  my_f2
    PL/SQL procedure successfully completed.
    SQL> desc what_ever
    Name                                      Null?    Type
    COL1                                               NUMBER
    SQL> I think there are only two differences between a procedure and a function.
    (1) A function must return a value
    (2) because of (1) we can use functions in SQL statements.
    There are some minor difference in allowable syntax but they are to do withj RETURN values.
    Cheers, APC

  • LEXICAL REFERENCES IN STORED PROCEDURES

    CAN I TO DO LEXICAL REFERENCES IN STORED FUNCTIONS AND STORED
    PROCEDURES ?
    THANK'S FOR ANY HELP.

    What is your application release?
    Not sure if I understand you correctly, but have you reviewed (How To Use Oracle.Apps.Fnd.Flex.Kff.Select To Retrieve Particular Segments And Not All Segments from a Flexfield [ID 1267032.1]) and see if it helps?
    Thanks,
    Hussein

  • DBA_FREE_SPACE reference in stored procedure

    Hi all,
    I tried googling around and could not find a solution.  I am referencing the DBA_FREE_SPACE system view in a stored procedure.  I received an error for insuffiient privileges for that particular piece of the stored proc.  I then explicity granted SELECT on the system view to the user schema which holds the stored proc.  I still am getting the insufficient privileges error and can not figure out why.  Has anyone experienced this or do you have any ideas I can try?
    Thanks in advance.

    andy_schnelle wrote:
    Hi all,
    I tried googling around and could not find a solution.  I am referencing the DBA_FREE_SPACE system view in a stored procedure.  I received an error for insuffiient privileges for that particular piece of the stored proc.  I then explicity granted SELECT on the system view to the user schema which holds the stored proc.  I still am getting the insufficient privileges error and can not figure out why.  Has anyone experienced this or do you have any ideas I can try?
    Thanks in advance.
    Maybe we should see your code and the exact error message, not your interpretation of the error.  Typically, not having SELECT privilge on a table or view will return 'ORA-00942: table or view does not exist'. 
    SQL> conn scott/tiger
    ERROR:
    ORA-28001: the password has expired
    Changing password for scott
    New password:
    Retype new password:
    Password changed
    Connected.
    SQL> select * from dba_free_space;
    select * from dba_free_space
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> conn / as sysdba
    Connected.
    SQL> grant select on dba_free_space to scott;
    Grant succeeded.
    SQL> conn scott/lion
    Connected.
    SQL> select * from dba_free_space;
    TABLESPACE_NAME   FILE_ID   BLOCK_ID  BYTES     BLOCKS
    RELATIVE_FNO

  • Difference between Stored Procedure & Stored Function

    I want to know the difference between Procedure Procedure & Stored Function in compiler in oracle 10g.
    Thanks in advance

    I've been guilty of doing that myself but you can put a when others exception in a procedure also :-)
    You can have an issue in forms triggers where it throws an exception for no known reason and the only way to throttle it is to have the everything exception. I think there is a bug in there that is exposed under some circumstances and everyone has run into it, that's my theory.  You're definitely right that having the everything exception in the code leads to impossible to debug problems. I think we could use some error handling enhancements.
    I'd like to see an all-purpose error function in forms. Instead of the customer having to program to catch all the various kinds of errors that can occur, plsql, database, forms, .... I'd like to be able to configure the form to have a built in error handling system show the error with an option to programatically handle the error unseen. The forms thing that it shows errors on the bottom of the screen does not work at all in my experience where we deploy forms. Windows by default has large icons and they cover up the error area. Even if you get the user to change the icons to small the users never see those messages. And they will not display errors in forms via the help menu either. (help,display error). I would like to be able to filter error messages, translate error messages with some kind of translation table (make user understandable), and have them pop up on the screen in a window.
    I think some of the database functions that are "error-happy" should be provided in additional constructs. It is a design decision to have this throw an exception when the record doesn't exist:
    select mycolumn into myfield from sometable where mykey = 'X';
    I think many of us would prefer to have it simply not throw an exception if the record doesn't exist, so we don't have to remember what on earth the exception was called,  and test the results of myfield and/or a status field.
    How else to do this? How about this?:
    minselect mycolumn into myfield, mystatus from sometable where mykey = 'X';
    Here we define a new form of select called minselect that is reluctant to throw exceptions, but puts a status code in
    the status field should someone have to know the difference of whether myfield was null in an existing record or if there was no qualifying record.
    What's with the minselect? Well we would have a minselect and a maxselect that would find ONE qualifying record, the min or the max to get around that exception problem #2, select returning multiple values. (We would have the status reflect the fact there were multiple values.)

  • Circular references between tables

    Good Morning...
    i was just wondering,
    assume i have two tables. each table has a foreign key that references the primary key of the other table.
    assuming the 2 tables are initially empty, how do i insert tuples into them?
    trying to insert a tuple into any table, will result in an integrity rule violation. how to execute the 2 insert statements at the same time?
    thank you very much..
    yours...
    Mohamed el Dawy

    Morning,
    there are two possible solutions of your problem:
    1) Define the dependent (FK) columns as nullable. Make your insert with
    NULL for these columns, and afterwards update them to the now existing value.
    2) With Oracle 8i or higher, you can define constraints as "initially deferred".
    Doing this, the constraints will be verified when committing, so you may
    insert your records in both tables without getting an error.

  • Get error message from a nested/encrypted stored procedure

    Hi,
    I have an encrypted procedure, that is used inside my 'own' complex procedure as:
    Begin try
    Begin tran
    Do a lot
    insert into #tmp exec xp_encryptedSP
    Do a lot more
    commit tran
    end try
    begin catch
    print ERROR_MESSAGE()
    rollback tran
    end catch
    Some error occur on the insert into #tmp exec xp_encryptedSP row, and in this case it's correct that the error occur, but:
    If I run only exec xp_encryptedSP in query analyzer, I can see the root cause error message,
    but in my complex procedure all I get is:
    Cannot use the ROLLBACK statement within an INSERT-EXEC statement.
    I have tried to enclose the insert into #tmp exec xp_encryptedSP in an own try block, but all I get is the message above.
    Please help
    /Magnus
    Magnus Burk

    No, the error message has nothing to do with the fact that the procedure obfuscated. It is a limitation of INSERT-EXEC. A quite silly one, since a consequence of the error is that the transaction is rolled back...
    There are better ways to share data between stored procedures, but most of them assumes that you can change the procedure you call, and obviously this is not possible since this is a vendor procedure.
    So it looks like you are in for heavy artillery, that is the CLR. See here for an example:
    http://www.sommarskog.se/share_data.html#CLR
    I should warn you in advance that error handling when the CLR is involved is also a very difficult thing.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to output value from stored procedure

    Hi folks, I need to output the OrderFK from a stored procedure not really sure how to achieve this any help or tips much appreciated.
    Sql code below
    USE [TyreSanner]
    GO
    /****** Object: StoredProcedure [dbo].[AddCustomerDetails] Script Date: 11/12/2014 20:56:34 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[AddCustomerDetails]
    /***********************Declare variables ***********************/
    /******tblCustomer******/
    @Forename nvarchar(50),
    @Surname nvarchar(50),
    @HouseNo nvarchar(50),
    @CustAddress nvarchar(50),
    @Town nvarchar(50),
    @Postcode nvarchar(50),
    @ContactNo nvarchar(50),
    @EmailAddress nvarchar(50),
    /******tblLink_OrderProduct******/
    @ProductQuantity int,
    @TotalProductSaleCost decimal,
    @ProductFK int,
    @FittingDate date,
    @FittingTime Time
    As
    DECLARE @CustomerFK int;
    DECLARE @OrderFK int;
    Begin TRANSACTION
    SET NOCOUNT ON
    INSERT INTO [TyreSanner].[dbo].[Customer](Forename, Surname, HouseNo, CustAddress, Town, Postcode, ContactNo, EmailAddress)
    VALUES (@Forename,@Surname,@HouseNo,@CustAddress,@Town,@Postcode,@ContactNo,@EmailAddress)
    Set @CustomerFK = SCOPE_IDENTITY()
    INSERT INTO [TyreSanner].[dbo].[Order] (CustomerFK)
    VALUES (@CustomerFK)
    SET @OrderFK = SCOPE_IDENTITY()
    INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
    VALUES
    (@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime)
    COMMIT TRANSACTION

    Hi brucey54,
    There’re several ways to capture the value from a Stored Procedure. In you scenario, I would suggest 2 options, by an output parameter or by a table variable.
    By an output Parameter, you need to make a little bit modification on your code as below:
    USE [TyreSanner]
    GO
    ALTER PROCEDURE [dbo].[AddCustomerDetails]
    @Forename nvarchar(50),
    @FittingDate date,
    @FittingTime Time,
    @OrderFK int output
    As
    DECLARE @CustomerFK int;
    --DECLARE @OrderFK int;
    Run the following code, Then @OrderFKvalue holds the value you’d like.
    DECLARE @OrderFKvalue int;
    EXEC AddCustomerDetails(your parameters,@OrderFKvalue output)
    Anyway if you don’t like to add one more parameter, you can get the value by a table variable as well. Please append “SELECT @OrderFK;” to your Procedure as below:
    USE [TyreSanner]
    GO
    ALTER PROCEDURE [dbo].[AddCustomerDetails]
    SET @OrderFK = SCOPE_IDENTITY()
    INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
    VALUES
    (@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime);
    SELECT @OrderFK;
    Then you can call the Stored Procedure as below:
    DECLARE @T TABLE (OrderFK INT);
    INSERT @T EXEC AddCustomerDetails(your parameters) ;
    SELECT OrderFK FROM @T;
    There’re more options to achieve your requirement, please see the below link:
    How to Share Data between Stored Procedures
    If you have any question, feel free to let me know.
    Best Regards,
    Eric Zhang

  • Prepared Statement and Stored Procedure difference?

    For SQL in my web applications I use PreparedStatement object alot in my JDBC working with Oracle 9i.
    I also heard the term Stored Procedure. What is the difference between Stored Procedure and Prepared Statement?

    I am new to java programming, can anybody explain
    what exactly precompiled means
    Thank you
    PalspaceWhat does you subject line have to do with your question?
    The difference between a stored proc and a prepared statement is mainly this.
    A stored proc is stored in the database server permanently and can be used and re-used from a different connections.
    A PreparedStatement is not valid across connections.
    Stored procs are almost always precompiled. (I am just hedging a bit here just in case but you can consider it 100%)
    PreparedStatements MAY be precompiled. Hard to say.
    Precompiling means at least one of and perhaps all of the following depending on the database
    - The parsing of the SQL statement
    - The checking of the SQL against the data dictionary to ensure that the tables and columns referenced actually exist
    - The preparation of a query plan
    Last but not least Stored procedures may (and often do) contain more than simple queries but are in fact relatively complex programs written in a DB specific language (an offshoot of SQL of some sort).

  • How to invoke a stored procedure by WSIF?

    If it can, how to do? what the WSDL looks like?
    Can anybody give me an example?
    Thanks.

    Thanks all for your replies. I will search the api for callable statements. I am curious though, the reply that suggests using a prepared statement - can I put the name of a stored procedure in a prepared statment or is this just suggestions an action query like Insert Into, Update, Delete? Like with ADO you can say
    cmdObject.CommandType = adStoredProcedure
    cmdObject.CommandText = "NameOfStoredProc"
    cmdObject.ExecuteNonQuery()
    Once I am calling/importing/implementing the proper libraries/interfaces in Java, can a prepared statement reference a stored procedure as above?
    Thanks

  • How to invoke a stored procedure on MS Sql Server with Java?

    I started writing Enterprise Java Beans and created an ODBC dsn with MS Sql Server 2000 which I can access using jdbc:odbc:mySqlDSN. This all works fine using Java Sql Statements. What kind of Java/Java Sql statement can I use to invoke a stored procedure on the Sql Server? Is it possible to use ADO/ADO command objects with Java? Is it possible to import/implement Mdac2.6 ActiveX data objects libary in Java?
    Thanks

    Thanks all for your replies. I will search the api for callable statements. I am curious though, the reply that suggests using a prepared statement - can I put the name of a stored procedure in a prepared statment or is this just suggestions an action query like Insert Into, Update, Delete? Like with ADO you can say
    cmdObject.CommandType = adStoredProcedure
    cmdObject.CommandText = "NameOfStoredProc"
    cmdObject.ExecuteNonQuery()
    Once I am calling/importing/implementing the proper libraries/interfaces in Java, can a prepared statement reference a stored procedure as above?
    Thanks

  • Stored Procedure VS Programs units VS Attached Libraries

    Hi all :)
    I would be happy if someone could tell me the difference between Stored procedures and programs units and atached Library in term of efficiency??? because i think that maybe if i convert all my programs units and Library to stored procedura i will gain a lot of time when i access to these procedure via my Forms, am i right please!!!!
    Best Regards,
    Reda.

    Stored procedures work on the database, program units/libraries on the application.
    So if you want to do calculations of 10million rows of data do it on the database (as a stored procedure) and pass the results back to Forms.
    If you want to do UI interation and application (rather than data) programming you would probably do this in the application as a program unit. (though you can share business logic by putting code in the database).
    Its a balancing act - if the code is intensive on on a particular tier (client, application or database) then consider moving the code there.
    Regards
    Grant Ronald
    Forms Product Management

  • Error executing a stored procedure from SSIS using the MERGE statement between databases

    Good morning,
    I'm trying to execute from SSIS a stored procedure that compares the content of two tables on different databases in the same server and updates one of them. To perform this action, I've created a stored procedure in the destination database and I'm
    comparing the data between tables with the MERGE statement. When I execute the procedure on the destination database the error that I obtain is:
    "Msg 916, Level 14, State 1, Procedure RefreshDestinationTable, Line 13
    The server principal "XXXX" is not able to access the database "XXXX" under the current security context."
    Some things to take in account:
    1. I've created a temporary table on the same destination database to check if the problem was on the MERGE statement and it works fine.
    2. I've created the procedure with the option "WITH EXECUTE AS DBO".
    I've read that it can be a problem of permissions but I don't know if I'm executing the procedure from SSIS to which user/login I should give permissions and which.
    Could you give me some tip to continue investigating how to solve the problem?
    Thank you,
    Virgilio

    Read Erland's article http://www.sommarskog.se/grantperm.html
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Stored procedure with multiple Reference Cursors

    In Sybase and SQLServer, result sets are returned to the application implicitly. Oracle emulates this by passing back weak reference cursors to the application through an IN OUT parameter.The number of reference cursors must match the number of results sets. For example, if 2 select statements are present in the stored procedure code, then 2 reference cursors are passed back.The Oracle Migration Workbench creates the correct number of reference cursors but assigns each select statement results to the first cursor created. Therefore only the last set of results are returned to the client.
    Before (SQLServer)
    CREATE PROCEDURE get_sch_associated_appointment_info (@piAcc_itn int) AS SELECT s.acc_itn, r.internal_key, r.mnemonic, r.descp, sh.start_dtime, sh.end_dtime FROM schdtl s, schdtlhdr sh, resource r WHERE s.acc_itn = @piAcc_itn and sh.acc_itn = @piAcc_itn and sh.resource_itn = r.internal_key SELECT sdcr.acc_itn, sdcr.rsch_dtime, sdcr.rsch_by_init, sdcr.rsch_code, sdcr.rsch_reason, sdcr.cncl_dtime, sdcr.cncl_by_init, sdcr.cncl_code, sdcr.cncl_reason, sdcr.prev_start_dtime, sdcr.prev_by_init FROM schdtl_canrsch sdcr WHERE sdcr.acc_itn = @piAcc_itn SELECT sdi.acc_itn, i.sched_notes, i.post_sched_notes, d.pre_sch_notes, d.post_sch_notes, i.detail_key, i.output_notes FROM schdtl_info sdi, extitem i, dept d WHERE sdi.acc_itn = @piAcc_itn and sdi.actual_dept = i.dept and sdi.actual_proc_no = i.proc_no and sdi.actual_dept = d.dept
    After (Migration Workbench) – Optional Section
    CREATE OR REPLACE PROCEDURE get_sch_associated_appointment_info (piAcc_itn int, RC1 IN OUT Omwb_emulation.globalPkg.RCT1) AS OPEN RC1 SELECT s.acc_itn, r.internal_key, r.mnemonic, r.descp, sh.start_dtime, sh.end_dtime FROM schdtl s, schdtlhdr sh, resource r WHERE s.acc_itn = piAcc_itn and sh.acc_itn = piAcc_itn and sh.resource_itn = r.internal_key; OPEN RC1 SELECT sdcr.acc_itn, sdcr.rsch_dtime, sdcr.rsch_by_init, sdcr.rsch_code, sdcr.rsch_reason, sdcr.cncl_dtime, sdcr.cncl_by_init, sdcr.cncl_code, sdcr.cncl_reason, sdcr.prev_start_dtime, sdcr.prev_by_init FROM schdtl_canrsch sdcr WHERE sdcr.acc_itn = piAcc_itn; OPEN RC1 SELECT sdi.acc_itn, i.sched_notes, i.post_sched_notes, d.pre_sch_notes, d.post_sch_notes, i.detail_key, i.output_notes FROM schdtl_info sdi, extitem i, dept d WHERE sdi.acc_itn = piAcc_itn and sdi.actual_dept = i.dept and sdi.actual_proc_no = i.proc_no and sdi.actual_dept = d.dept;
    After (Manual Change)
    CREATE OR REPLACE PROCEDURE get_sch_associated_appointment_info (piAcc_itn int, RC1 IN OUT Omwb_emulation.globalPkg.RCT1, RC2 IN OUT Omwb_emulation.globalPkg.RCT1, RC3 IN OUT Omwb_emulation.globalPkg.RCT1) AS OPEN RC1 SELECT s.acc_itn, r.internal_key, r.mnemonic, r.descp, sh.start_dtime, sh.end_dtime FROM schdtl s, schdtlhdr sh, resource r WHERE s.acc_itn = piAcc_itn and sh.acc_itn = piAcc_itn and sh.resource_itn = r.internal_key; OPEN RC2 SELECT sdcr.acc_itn, sdcr.rsch_dtime, sdcr.rsch_by_init, sdcr.rsch_code, sdcr.rsch_reason, sdcr.cncl_dtime, sdcr.cncl_by_init, sdcr.cncl_code, sdcr.cncl_reason, sdcr.prev_start_dtime, sdcr.prev_by_init FROM schdtl_canrsch sdcr WHERE sdcr.acc_itn = piAcc_itn; OPEN RC3 SELECT sdi.acc_itn, i.sched_notes, i.post_sched_notes, d.pre_sch_notes, d.post_sch_notes, i.detail_key, i.output_notes FROM schdtl_info sdi, extitem i, dept d WHERE sdi.acc_itn = piAcc_itn and sdi.actual_dept = i.dept and sdi.actual_proc_no = i.proc_no and sdi.actual_dept = d.dept;

    I believe you are using .NET(?). If that is the case, please post this query to the .NET Development - Crystal Reports  forum:
    SAP Crystal Reports, version for Visual Studio
    That forum is monitored by qualified technicians and you will get a faster response there.
    Thank you for your understanding,
    Ludek

  • Another schema reference in a stored procedure

    Hello -
    I need to call a stored procedure from another stored procedure in a different schema. Can this be done?
    For example:
    I am logged on as USER1 and I try to call these stored procedures from within a stored procedure:
    DO_STUFF (works - within one schema)
    USER2.DO_STUFF (does not compile)
    INSERT INTO USER2.SOME_TABLE VALUES(...) (does not run -table does not exist)
    Thanks!
    Peter

    Vinay,
    Spend some time online to read and search about your problem before blindly posting it on forum, if you would have done that you could have found out eaisly below two links which will explain you in deep
    http://stackoverflow.com/questions/3682821/difference-between-varchar500-vs-varcharmax-in-sql-server
    http://sqlhints.com/2013/03/10/difference-between-sql-server-varchar-and-varcharmax-data-type/
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

Maybe you are looking for