Stored Procedure freezing on execution
Hi all
I have an SP in the production system which intermittently freezes upon execution. The only thing which seems to fix this is to halt execution and to run the ALTER PROCEDURE command on the SP - then it is fixed. Two questions:
why would this SP freeze? The SP is run from a .net application so I don't know if this is one of the reasons why?
How can I refresh the SP automatically when it freezes?
Thanks in advance.
"Freezing" can be due to two things: a) blocking b) "bad" execution plan.
From what you describe, I would guess for the latter. Then again, if there is blocking and you wait long enough the problem goes away.
Next time the procedure "freezes", use sp_who to see if there is blocking. Look in the Blk column. If there is a value, this is the spid that is blocking the spid on this line. If there is blocking, you should investigate what the blocker is up
to.
Once blocking has been ruled out, it is time to look at the execution plan. There can be a number of reasons why this happen. But the key is always that SQL Server caches execution plan, which sometimes is a very good thing, and sometimes it works against
you.
I have a longer article on my web site, that may help you to troubleshoot the problem:
http://www.sommarskog.se/query-plan-mysteries.html
Erland Sommarskog, SQL Server MVP, [email protected]
Similar Messages
-
Calling stored procedure from session bean method
I have a situation like this :
I have one method on a stateless session bean (and I mark this method as container managed transaction). For database related stuff, I am not using entity beans, I am using my own layer of OR mapping. This method does a lot of stuff and it involves many trips to the database, as a result of which the performance is very poor. I have identified certain pieces of functionality from this method which I think can be moved to stored procedures, while some of the functionality can still remain in the session bean method. So my scenario is like this :
session bean method start
store some data in tables(using my OR layer)
call the stored procedure
session bean method end
My question is :
Will the data that I am storing in tables from within the session bean method, be available to the code executing inside stored proc.
secondly, how do I sync the transcation which is being initiated by the container with the transaction under which the stored proc is executing or is it that the stored procedure code will also be executing under the container managed transcation.
Thanks
VimalHi Vimal,
Will the data that I am storing in tables from within
the session bean method, be available to the code
executing inside stored proc.There's only one way to find out (isn't there?)
secondly, how do I sync the transcation which is
being initiated by the container with the transaction
under which the stored proc is executing or is it
that the stored procedure code will also be executing
under the container managed transcation.Again, why not just "suck it and see!"
[Or is there some reason why you can't?]
As I interpret the EJB specification, if the transaction attribute for your session bean method is such that it starts a transaction, then that transaction will be terminated when the method completes -- and every operation that occurs within the framework of that method will be in the one transaction.
In other words, your database stored procedure should execute within the same transaction as your O/R mapping layer.
However, how OC4J behaves may not exactly follow what is written in the (EJB) specification. Hence I repeat, "try it and see for yourself".
Put it this way: as far as I know, the only way that your stored procedure would NOT see the changes made by your O/R mapping layer is if they both executed in separate transactions and the O/R mapping layer did not commit its changes before the stored procedure began its execution.
Hope this has helped.
Good Luck,
Avi. -
Oracle stored procedure works in toad but lots of error in java
I've tested this stored procedure in toad 7.3 and it completes ok.
I do pass the same IN parameters and OUT parameters.
I registered the out parameter as a OracleTypes.CURSOR
if it works in toad or pl/sql, what is wrong? how can this be fixed.
however, when i execute this in java, this is the exception and garbage i receive:
java.sql.SQLException: ORA-06550: line 1, column 22:
PLS-00103: Encountered the symbol "" when expecting one of the following:
:= . ( @ % ;
The symbol "(" was substituted for "" to continue.
ORA-06550: line 1, column 33:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( ) , * @ % & | = - + < / > at in mod not range rem => ..
<an exponent (**)> <> or != or ~= >= <= <> and or like
between is null is not || indicator is
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
my stored procedure is as follows:
CREATE OR REPLACE PROCEDURE getUserByLogin (
arg_subscriptionName IN varchar,
arg_loginName IN varchar,
arg_password IN varchar,
arg_rec_userinfo_valLanguage OUT types.rec_userinfo_valLanguage
) AS
var_userNum int;
BEGIN
select
u.userNum into var_userNum
from
userInfo u,
subscription s
where
s.subscriptionName = arg_subscriptionName AND
s.subscriptionNum = u.subscriptionNum AND
u.loginName = arg_loginName AND
u.password = arg_password;
if (var_userNum is null) then
var_userNum := 0;
end if;
getUser(var_userNum, arg_rec_userinfo_valLanguage);
END;
/I'm using a callable statement.
The strange thing is that, when i remove all IN and OUT paramters in the java code and the stored procedure, both the call to the stored procedure and teh execution of the stored procedure works.
The moment I add in just a IN parameter (in the stored procedure, and setting it in the java code) it stops working, and i receive this error.
java.sql.SQLException: ORA-06550: line 1, column 23:
PLS-00103: Encountered the symbol "" when expecting one of the following:
:= . ( @ % ;
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
heres the java code and stored procedure
CREATE OR REPLACE PROCEDURE sampleProcedure(tax out number)
is
BEGIN
tax := 10 *.15;
/END;
CallableStatement statement =conn.prepareCall("{call sampleprocedure ?}");
statement.registerOutParameter(1,java.sql.Types.INTEGER);
statement.execute();
ResultSet rs = statement.getResultSet();
if((rs = statement.getResultSet()) != null){ -
Stored Procedure error in Java
My Java application is invoking stored procedure(Oracle 10g). The stored procedure is opening a cursor for a SQL query that is created dynamically in side the procedure. Whenever there is an error while opening the cursor (i.e. executing the SQL query), I get the following exception message in Java application logs irrespective of what error has caused during SQL execution.
SQLException for SQL [{call PRC_TEST(?, ?, ?, ?, ?, ?, ?, ?)}]; SQL state [60000]; error code [604]; ORA-00604: error occurred at recursive SQL level 1
ORA-01003: no statement parsed
; nested exception is java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01003: no statement parsed
e.g. If the query is like select * from tableA and I dont have proper privlieges. I should get error message while opening the cursor :- insufficient privileges.
Is there any way where we can get more precise(or exact!) error message (in Java application logs) that stopped SQL execution while opening the cursor?I'm using a callable statement.
The strange thing is that, when i remove all IN and OUT paramters in the java code and the stored procedure, both the call to the stored procedure and teh execution of the stored procedure works.
The moment I add in just a IN parameter (in the stored procedure, and setting it in the java code) it stops working, and i receive this error.
java.sql.SQLException: ORA-06550: line 1, column 23:
PLS-00103: Encountered the symbol "" when expecting one of the following:
:= . ( @ % ;
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
heres the java code and stored procedure
CREATE OR REPLACE PROCEDURE sampleProcedure(tax out number)
is
BEGIN
tax := 10 *.15;
/END;
CallableStatement statement =conn.prepareCall("{call sampleprocedure ?}");
statement.registerOutParameter(1,java.sql.Types.INTEGER);
statement.execute();
ResultSet rs = statement.getResultSet();
if((rs = statement.getResultSet()) != null){ -
Cursor Not working stored Procedure but it working in anonymous Procedure
Hi Gurus....
My problem looks different.....my code was working as anonymous block where as it was not working as stored Procedure
Declare
cursor c_tblspace is
select fs.tablespace_name TBL_SPC_NAME
, round((100 *((sum(fs.bytes)) / df.bytes)), 2) PCT_Free
from sys.dba_data_files df
, sys.dba_free_space fs
,partition_tables ms
where df.file_id(+) = fs.file_id
and fs.tablespace_name =ms.tbspc_nam
group by fs.file_id, df.bytes, fs.tablespace_name;
begin
for rec_tblspace in c_tblspace
loop
if ( rec_tblspace.PCT_Free > 5 )
then
insert into t_space (tbspc_nm,ftr_spc)
values(rec_tblspace.TBL_SPC_NAME,'full');
dbms_output.put_line(rec_tblspace.TBL_SPC_NAME||' is full');
end if;
end loop;
end;where as it working while i want to create a stored Procedure...
create or replace procedure p_upd_space is
cursor c_tblspace is
select fs.tablespace_name TBL_SPC_NAME
, round((100 *((sum(fs.bytes)) / df.bytes)), 2) PCT_Free
from sys.dba_data_files df
, sys.dba_free_space fs
,partition_tables ms
where df.file_id(+) = fs.file_id
and fs.tablespace_name =ms.tbspc_nam
group by fs.file_id, df.bytes, fs.tablespace_name;
begin
for rec_tblspace in c_tblspace
loop
if ( rec_tblspace.PCT_Free > 5 )
then
insert into t_space (tbspc_nm,ftr_spc)
values(rec_tblspace.TBL_SPC_NAME,'full');
dbms_output.put_line(rec_tblspace.TBL_SPC_NAME||' is full');
end if;
end loop;
end;It was throwing following error...
PL/SQL: ORA-00942: table or view does not existJustin is right. You are creating definer right stored procedure.
Roles are disabled during definer rights stored procedure compilation and execution.
Here is the test case:
#1. Anonymous Procedure
HRDEMO@fmw//scripts> conn / as sysdba
SYS@fmw//scripts> create user todd identified by oracle;
SYS@fmw//scripts> grant dba to todd; --DBA role granted
SYS@fmw//scripts> conn todd/oracle
TODD@fmw//scripts> declare
2 cursor c is select * from dba_data_files;
3 begin
4 null;
5 end;
6 /
PL/SQL procedure successfully completed.
#2. Stored Procedure
TODD@fmw//scripts> create or replace procedure p1
2 is
3 cursor c is select * from dba_data_files;
4 begin
5 null;
6 end;
7 /
Warning: Procedure created with compilation errors.
TODD@fmw//scripts> show error
3/27
PL/SQL: ORA-00942: table or view does not exist -
Execution Times of Stored Procedures Called from Other Stored Procedures
If I execute sys.dm_exec_procedure_stats, it will produce execution times of my stored procedures executed recently.
However, stored procedures called from other stored procedures do not show up.
Is there code that can return the execution times of stored procedures even though they are called from other stored procedures.Look at the example. It is counting nested execution.
CREATE PROC z1SP AS SELECT * FROM Production.Product;
GO
CREATE PROC z2SP AS SELECT * FROM Production.Product WHERE Color is not null; EXEC z1SP;
GO
SELECT object_name(2002822197), object_name(2034822311);
--z1SP z2SP
EXEC z1SP; EXEC z2SP;
GO 10
SELECT * from sys.dm_exec_procedure_stats
database_id object_id type type_desc cached_time last_execution_time execution_count
16 2002822197 P SQL_STORED_PROCEDURE 2014-12-16 13:02:45.170 2014-12-16 13:02:46.717 20
16 2034822311 P SQL_STORED_PROCEDURE 2014-12-16 13:02:45.460 2014-12-16 13:02:46.687 10
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
SQL stored procedure execution takes 5x as long using PS 3.0
I have a stored procedure that populates some reporting table, does not return any results, and is very expensive. However it completes in 5 minutes when executed using SSMS. When the same stored procedure is executed though PS 3.0 it runs in
almost 25 minutes. The condensed code is shown below. The $Connection is defined elsewhere and is already open at this point.
$Command = New-Object Data.OleDb.OleDbCommand
$Command.CommandTimeout = 600
$Command.CommandText = "dbo.usp_extract_exact_target_user @in_all_flg = 1"
$Command.Connection = $Connection
$Command.ExecuteNonQuery()
Can anyone tell me where I'm going wrong, or what could be causing the 5x execution times?
Thanks in advance for help; you can offer.Not Powershell. Powershell does nothing but hand the command to the database server.
Why are you using OldDB? You should be using the SQLClient.
system.data.sqlclient.sqlconnection
system.data.sqlclient.sqlcommand
Everything else should be the same.
You should also prep and bind your arguments.
¯\_(ツ)_/¯ -
Shell script execution from stored procedure
I am working on a project thallt requires a shell script be executed upon the execution of a stored procedure with Oracle 10g. I have researched the matter, but there does not seem to be much out there on how to execute lines of UNIX commands by use of a stored procedure. If anybody has ever gotten this to work, any information would be appreciated. If the task is impossible, let me know, I just could not confirm that it was not something that could be done.
A combination of things can help you out here - none of which are easy or particularily secure.
1) From plain PL/SQL, you can call 'external procedures'. That is basically a DLL or .so that the listener can load on demand, and that external procedure (EXTPROC) can run whatever you need from the C program. C can, in turn, call a shell.
This is fairly well documented, but be aware that 1/2 of the info is in the PL/SQL docco and the other half in the Networking docco.
A fair bit of info is available in metalink as well - if you have access, simply search on extproc.
2) You can call a Java stored procedure which in turn has hooks to the outside world. That will probably require a PL/SQL to Java wrapper to make it available in your environment. Oracle has been using this one successfully for a while.
3) Write the script using UTL_FILE and have a daemon look for, and execute, the script.
4) Since you are using 10g, use the new job scheduler. It has excellent capability to interact with the OS, and it is available as a PL/SQL package (DBMS_SCHEDULER). I find the interface a bit heavy, but that could be wrapped by a library tailored to your specific needs.
Let us know what you decide to do in the end (and why) - it is an interesting topic. -
Why execution status of stored procedure in shell script is returning same?
Hi Friends,
My shell script has below code to execute Pl/Sql procedure.depending on pl/sql procedure status i need to execute the script further.
i am testing error condition.So i kept exe instead of exec for executing procedure.it suppose to return non zero.But iam not getting the correct status in shell script using $?.
even for error condition also status is returning zero(0).How to catch execution status of stored procedure in shell script?
can you please me suggest whats is wrong in below code?
echo "*************************************************************"
echo " cleaning replica tables"
echo "*************************************************************"
sqlplus -s migrat/****@dotis01<<ENDOFSQL
WHENEVER SQLERROR EXIT 1;
exe PKG_OTU_HELPER.SP_CLEANUPREPLICA;
Commit;
exit;
ENDOFSQL
status=$?
echo $status // showing 0 always.
+if [ $status -ne 0 ]+
then
echo "issues in cleaning in replica tables"
exit;
fi
+#Loading of data from flat files to migration tables using sqlldr programs+
echo "*************************************************************"
echo " Loading of data from flat files to migration tables"
echo "*************************************************************"
sh /opt/finaclesoftware/UBS_10.4.02_AIX/AIX/DB/CRM/Oracle/OTU/Retail/ControlFiles/LoadData1.com
Thanks,
Venkat VadlamudiThe whenever sqlerror clause is a sqlplus command. When Oracle (that is, the sql engine of the pl/sql engine) raises and error in a sql statement, the whenever sqlerror command determines what happens.
Exec is also a sqlplus command, exec <procedure> is shorthand for begin <procedure> end;, that is, it creates an anonymous block.
Your misspelling of exec as exe is not an Oracle error, it is a sqlplus error. The command never actually gets to Oracle, so there has not been a sqlerror for whenever sqlerror to respons to.
Consider, I do not have a procedure called p
SQL> desc p
ERROR:
ORA-04043: object p does not existI try to call it with exe as in your code:
SQL> exe p;
SP2-0042: unknown command "exe p" - rest of line ignored.Note the error message is form sqlplus (SP2).
But, if I call it correctly usinf exec:
SQL> exec p;
BEGIN p; END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'P' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignorednow I have a sql error, and whenever sqlerror exit 1 would quit sqlplus with a return value of 1.
John -
Stored Procedure delay execution
Good Afternoon,
I am trying to execute 4 separate stored procedures, however I want to put a 10 second delay in between executing each procedure. The stored procedures are called SP_1, SP_2 etc.. Is there a really simple way of doing this with a SQL script?.
Thanks in advance.
Steveuse WAITFOR DELAY '00:00:10' option put this for every sp.
example :
create PROCEDURE dbo.testtotal
AS
exec test1;
WAITFOR DELAY '00:00:10'
exec test2;
WAITFOR DELAY '00:00:10'
exec test3
WAITFOR DELAY '00:00:10'
exec test4
GO
Pls mark as answer if this helpful to you -
Audit stored procedure execution details in sql server
Hi All,
how to find stored procedue details and which parameters passed in stored proceduer and out put details in sql server.
how can we audit stored procedure details.
/Raghavendrahttp://technet.microsoft.com/en-us/library/ms189751.aspx
In SQL Server, requires ALTER ANY LOGIN permission on the server or membership in the securityadmin fixed server role.
In SQL Database, only the server-level principal login (created by the provisioning process) or members of the loginmanager database role in the master database can create
new logins.
If the CREDENTIAL option is used, also requires ALTER ANY CREDENTIAL permission on the server.
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 -
Remote execution of DTS packages from Java Stored Procedures
I'm an Oracle 10G DBA and Linux/Unix Sysadmin looking for a Java guru to help me find a reusable template or locate a solid programming methodology (examples) that will enable me to connect via JDSI to SQL Server 2000/2005 and remotely execute DTS packages from within Oracle. I am working at office that's absolutely addicted to MicroSlop products and the DBA team cannot conceive of giving up their precious DTS packages. I've already converted their MS SQL Server 2000 database to Oracle 10G on RHEL4 via SQLDeveloper but I am unschooled in the art of java programming and would like to locate some sort of rudimentary template or examples or java class that can easily be loaded into the Oracle 10G database instance via the loadjava utility. These java classes/methods/stored procedures need to be executable from within embedded PL/SQL code and able to connect to SQL Server 2000 to execute DTS packages via passing dtsrun commands ... Any help or direction would be greatly appreciated.
Hi Ilford:
Sure you can use fully package notation in your Java classes.
Look at this Java source code:
http://dbprism.cvs.sourceforge.net/dbprism/cms-2.1/src/com/prism/cms/core/
All of them are Java Stored procedures.
Best regards, Marcelo. -
System command execution from stored procedure
Hello World,
How to run System command from stored procedure ?
For example :
Delete a file
running a programm,
Is it possible ?
H.MYears ago I did this by writing an output file with commands into a directory and had a cron job looking for this file. At the end of the run the file was removed.
Never checked if there are other possibilities nowadays.
cu
Andreas -
Stored procedure execution problem
hi guys
I am having problems running a stored procedure where i am using two input parameters
my stored procedure is as follows
ALTER procedure [dbo].[enterdhbnameDhbService]
@dhb_service char, @dhbname char
as
SELECT dbo.DHBMappingTable.[DHB Name], dbo.Agency.DHB_service, dbo.PurchaseUnitMappingTable.PU,
SUM(dbo.[NMDS Data for IDF Report].[Number of caseweighted discharges]) AS Expr1, dbo.AdmissionMappingTable.Admission
FROM dbo.DomicileCodes INNER JOIN
dbo.[NMDS Data for IDF Report] ON dbo.DomicileCodes.[Domicile code] = dbo.[NMDS Data for IDF Report].[Domicile Code] INNER JOIN
dbo.PurchaseUnitMappingTable ON dbo.[NMDS Data for IDF Report].[Purchase Unit] = dbo.PurchaseUnitMappingTable.PU INNER JOIN
dbo.AdmissionMappingTable ON
dbo.[NMDS Data for IDF Report].[Admission Type Description] = dbo.AdmissionMappingTable.[Admission Type Description] INNER JOIN
dbo.Agency ON dbo.[NMDS Data for IDF Report].[Agency Name] = dbo.Agency.Agengy INNER JOIN
dbo.DHBMappingTable ON dbo.DomicileCodes.[DHB area] = dbo.DHBMappingTable.[DHB Code]
WHERE (dbo.[NMDS Data for IDF Report].[Financial Year] = '20062007')
GROUP BY dbo.DHBMappingTable.[DHB Name], dbo.Agency.DHB_service, dbo.PurchaseUnitMappingTable.PU, dbo.AdmissionMappingTable.Admission
HAVING (dbo.Agency.DHB_service = @dhb_service) and
AND (dbo.DHBMappingTable.[DHB Name] = @dhbname )
The values of " @dhb_service" and "@dhbname" need to be entered when the stored procedure is executed. Now when I execute the stored procedure through the following statement:
exec enterdhbnameDhbService
@dhb_service = 'canterbury' ,@dhbname = 'south canterbury'
SQL does not give me any results, only empty table gets displayed. I have checked the combination.. This combination does exist in my table
pls help guysIncrease the size of the stored procedure parameters as "mitasid" suggested.
Remove HAVING clause,
SELECT dbo.DHBMappingTable.[DHB Name], dbo.Agency.DHB_service, dbo.PurchaseUnitMappingTable.PU,
SUM(dbo.[NMDS Data for IDF Report].[Number of caseweighted discharges]) AS Expr1, dbo.AdmissionMappingTable.Admission
FROM dbo.DomicileCodes INNER JOIN dbo.[NMDS Data for IDF Report]
ON dbo.DomicileCodes.[Domicile code] = dbo.[NMDS Data for IDF Report].[Domicile Code]
INNER JOIN dbo.PurchaseUnitMappingTable
ON dbo.[NMDS Data for IDF Report].[Purchase Unit] = dbo.PurchaseUnitMappingTable.PU
INNER JOIN dbo.AdmissionMappingTable
ON dbo.[NMDS Data for IDF Report].[Admission Type Description] = dbo.AdmissionMappingTable.[Admission Type Description]
INNER JOIN dbo.Agency
ON dbo.[NMDS Data for IDF Report].[Agency Name] = dbo.Agency.Agengy
INNER JOIN dbo.DHBMappingTable
ON dbo.DomicileCodes.[DHB area] = dbo.DHBMappingTable.[DHB Code]
WHERE
dbo.[NMDS Data for IDF Report].[Financial Year] = '20062007'
AND (dbo.Agency.DHB_service = @dhb_service)
AND (dbo.DHBMappingTable.[DHB Name] = @dhbname)
GROUP BY
dbo.DHBMappingTable.[DHB Name],
dbo.Agency.DHB_service,
dbo.PurchaseUnitMappingTable.PU,
dbo.AdmissionMappingTable.Admission
Regards, RSingh -
Dynamic Execution of Stored Procedure
Hi Everybody!
I have two questions for you. All my questions are pertaining PL/SQL programming with Oracle 8i. But before that, I would like to introduce a bit about the background.
We have .NET based application, which calls some 80 odd Oracle stored procedures one after one. The input parameters for all these stored procedure are same i.e. two IN parameters of Integer type and a OUT parameter of cursor type. The name of these stored procedures are listed in table (let say tblSPTable). We use to get the list of stored procedures from this table and execute them one after one.
Sooner or later we realized that, this way of calling the stored procedures is causing a performance issue. So, we thought of moving the call to all these stored procedures to a new stored procedure. We thought of giving a call to this new stored procedure, which will in turn execute all these stored procedures one after one (by using the tblSPTable), and return us the all the cursors at one shot. But here is where we got stuck:
How can I declare a OUT parameter for a list of cursors? Because I need to store the output of all the 80 odd calls in different cursors and have to get it back. I have tried to declare VARRAY of cursors or TABLE of cursors but it is not supported. One way of doing this is to declare all the 80 cursors as OUT parameters in the new stored procedure, but that is absolutely a bad programming practice. Apart from that, in future if we want to modify the order of the stored procedure, OR if we want to add or remove few stored procedures listed in tblSPTable, we have to modify this new procedure every time. My question is how can I declare or use a variable which can hold the list of cursors, which I can use from a .NET base application.
Secondly, I will get the name of all the stored procedure by querying the tblSPTable, and will execute them dynamically. I have tried out something like this but not succeeded
declare
cur_result some_package.some_cursor;
var_spname varchar;
begin
var_spname:=’pr_some_procedure’;
execute immediate 'begin ‘ || var_spname || ‘(:2); end;' using out cur_result;
end;
Bur, I am getting an error saying “Error while trying to retrieve text for error ORA-03113”. I have scanned through few docs available over net, but none of them are really helpful. My question is how can I dynamically execute a stored procedure which has a cursor as a OUT parameter.
Please help me out if you people have any idea regarding this. Please let me know whether my approach is correct or not. I am waiting for your valuable suggestions.
Thanking you
Ayan Mitra
Message was edited by:
user588628your solution will work out only in case all the functions returning you a cursor which holds same number of columnNot so. It is unfortunate that my example does not make that clear.
The UNION ALL is of a single column which is of type weak refcursor.
By way of example the below changes the p_dept procedure so it returns two columns rather than three.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> CRE ATE OR REPLACE PROCEDURE p_dept (
2 p_deptno IN dept.deptno%type,
3 p_resultset OUT SYS_REFCURSOR)
4 IS
5 BEGIN
6 OPEN p_resultset FOR
7 SELECT d.deptno, d.dname
8 FROM dept d
9 WHERE d.deptno = p_deptno;
10 END p_dept;
11 /
Procedure created.
SQL> VARIABLE p_resultset REFCURSOR;
SQL> BEGIN
2 :p_resultset := f_all (
3 p_deptno => 30,
4 p_functions => varchar2_table ('F_DEPT', 'F_EMP'));
5 END;
6 /
PL/SQL procedure successfully completed.
SQL> PRINT p_resultset;
RN FN RS
1 F_DEPT CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
DEPTNO DNAME
30 SALES
2 F_EMP CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
EMPNO ENAME JOB
7499 ALLEN SALESMAN
7521 WARD SALESMAN
7654 MARTIN SALESMAN
7698 BLAKE MANAGER
7844 TURNER SALESMAN
7900 JAMES CLERK
6 rows selected.
SQL>[pre]
Maybe you are looking for
-
Problem using default value of report parameter 1 to validate parameter 2 passed in to report
I am having a problem with an SSRS report using the default value of report parameter 1 to validate parameter 2 passed in to report (via C#) instead of using the value of parameter 1 that is also passed into the report. Here are the simplified detai
-
Hi, I have one colourfullfirework is a FLA file and Documnet is a AS file, I want to import document class in FLA, How can i do this?? Plz help me Thanks, JaxNa
-
Can't add artwork for WAV file?
It's true. I tried. Is that supposed to happen? Why can't I put artwork on a WAV file in iTunes?
-
How do I setup a drum track to play a triggered sound
I read somewhere that Logic Pro 9 would allow me to, for instance replace a poor snare drum with a prerecorded sample. Can someone point me in the right direction?
-
HI I am Mahesh How many static blocks can i have in a class?