E_PS055B CREATE PROCEDURE: You may not create database procedure
'proc_name'
because database procedure 'proc_2' invoked by it is dormant.
Any database procedure attempting to invoke a dormant
database procedure is itself dormant, and it is illegal
to create dormant database procedures.
I get this error when was trying to create procedure, could you please explain me what does it mean, cant find any information on it
DB Ingres version 10
From the Ingres documentation:
The DROP PROCEDURE statement removes a database procedure definition from the database. Sessions that are executing the procedure are allowed to complete before the procedure's query plan is removed from memory.
If a procedure that is executed from another procedure is removed, the
calling procedure is retained but marked dormant, and cannot be executed
until the called procedure is restored.
In summary, proc_2 calls a procedure which has been dropped. This means proc_2 will be marked as dormant (as it cannot run) until such time as the dropped procedure is replaced. Any procedures which call proc_2 will also be marked as dormant. You will need to work out which procedure that proc_2 needs has been dropped and recreate it before you can create your new procedure.
Related
I have a stored procedure, which was written by another developer whi I have subsequently replaced. At the beginning of their store procedures they delete / drop the table using the following code:
EXEC DBA.usp_DeleteTableByName 'Customer_Import'
It appears though that the above line of the code is the only one, which gets executed as at the rest of the code within this stored procedure performs a SELECT INTO to recreate and populate the Customer_Import table.
Why would the stored procedure stop executing after the above line of code has been successfully executed?
We have recently encountered a strange problem on our staging and production environments. We have run an update script to a stored procedure on SQL Server 2005, verified the new change, and started using it on our products. After sometime the same stored procedure has gone missing from the DB. This stored procedure is not being used by any other tasks except the one we are intending to use. We have checked every bit of code and deployment script, but cannot find a trace for just dropping the stored procedure.
This issue doesn't occur on our DEV and QA environments, but on Staging and Production only.
Could anybody help on this?
Kind Regards,
Mafaz
If you've ruled out the obvious (e.g. deliberate sabotage), then I would suggest having a look through sys.sql_modules for a reference to the procedure - possibly there is an accidental slip like:
IF NOT EXISTS (SELECT 1 FROM SYS.PROCEDURES WHERE NAME = 'Proc1')
DROP PROCEDURE Proc1
GO
CREATE PROC dbo.Proc1
AS
...
<< MISSING GO!
IF NOT EXISTS (SELECT 1 FROM SYS.PROCEDURES WHERE NAME = 'Proc2')
DROP PROCEDURE Proc2
GO
CREATE PROC dbo.Proc2
AS
...
i.e. in the Above, the DROP PROCEDURE Proc2 code gets appended INTO the definition of the unrelated Proc1 because of a missing GO at the end of the Proc1 definition. Every time Proc1 is run, it will drop proc Proc2 (and the if exists will inconveniently hide an error if Proc2 is already dropped).
Similarly, another common issue is leaving GRANT EXEC at the bottom of the PROC - if permissions are lax, this can destroy the performance of a procedure.
The best advice here is to execute applications with minimal permissions, so that it is not able to execute DDL such as DROP or GRANT. This way, the app will break when Proc1 is executed, allowing you to quickly track down the offending code.
I have created a stored procedure and can see it under the stored procedure node, but when trying to execute it doesn't find the procedure.
Under stored procedure node it is called dbo.CopyTable
exec CopyTable
CopyTable is undefined in red saying it does not exist. Why?
Even if I right-click on the procedure and say script stored procedure as execute to - the code it generates is underlined in red and cant find stored procedure either.
Ensure that the database selected contains the stored procedure CopyTable
USE YourDatabase
EXEC CopyTable
Try adding dbo and selecting the right database,
USE databaseName
GO
EXEC dbo.CopyTable
GO
Execute a Stored Procedure
Most likely you are just in the wrong database in the query window, you can specify the database like this:
EXEC [yourDBName].dbo.CopyTable
Reading on how to Execute a Stored Procedure
Considering your updated question:
Even if i rightclick on the procedure and say script stored procedure
as execute to - the code it generates is underlined in red and cant
find stored procedure either.
This could happen if your stored procedure is invalid. Please double-check the validity of the SPROC and ensure the tables it references exist, etc.
Try running your CREATE PROCEDURE. Highlight it, f5 it, and then make sure it runs before you call it elsewhere.
Maybe in your procedure you've accidentally cut-pasted your script name (dbo.CopyTable), say something like...
SELECT * FROM dbo.CopyTable
WHERE ClientId = #ClientId
RETURN
Then when you call your proc you get 'invalid object name dbo.CopyTable' and assume sql is having trouble finding the stored-proc ... which isn't the problem, its finding and running the proc but its actually a problem within the proc.
I'm running a stored procedure on server1 from my application. The stored procedure does a bunch of stuff and populate a table on server2 with the result from the procedure.
I'm using linked server to accomplish this.
When the stored procedure is done running the application continues and tries to do some manipulation of the result from the stored procedure.
My problem is that the results from the stored procedure has not been completely inserted into the tables yet, so the manipulation of the tables fails.
So my question is. Is it possible to ensure the insert into on the linked server is done synchronous? I would like to have the stored procedure not return until the tables on the linked server actually is done.
You can use an output parameter of the first procedure. When the table is create on the second server the output parameter value will be return to your application and indicates the operation is ready.
If the things are difficult then this you can try setting a different isolation level of your store procedure:
http://msdn.microsoft.com/en-us/library/ms173763.aspx
I found the reason for this strange behavior. There was a line of code in my stored procedure added during debug that did a select on a temporary mem table before the data in the same table was written to the linked server.
When the select statement was run, the control was given back to my application and at the same time the stored procedure continued running. I guess the stored procedure was running synchronously from the start.
I'm writing stored procedures in SQL Server 2008. I need to create two procedures which will use each other.
Procedure A executes B and B executes A.
So I suppose I have to declare headers of procedures firstly. I've searched over internet but I can't find the answer how can I make it.
So, my question is: how can I declare header and body of stored procedure separately in SQL Server 2008?
You can't separate them but you can create a SP that calls another SP that not yet exist.
When you run this
create procedure TheFirst as
begin
exec TheSecond
end
and SP TheSecond does not exist you will get a message:
The module 'TheFirst' depends on the missing object 'TheSecond'. The
module will still be created; however, it cannot run successfully
until the object exists.
Update:
To avoid the messages you can first create an empty proc and add the code later in the script.
create procedure ProcB as
go
create procedure ProcA as
begin
exec ProcB
end
go
alter procedure ProcB as
begin
exec ProcA
end