Toplink storedProcedure/funtion + PL/SQL Procedure with cursor
Hi,
I am working on Toplink storedProcedure but, I am not getting any output. I go through the Oracle Tutorial but, still I am not getting any alternative.
please, anyone help out....
Thanking You,
regards,
sufian
Hello Sufian,
You seem to have a few threads trying to get a Stored proc working. In How to work with Toplink + PL/SQL Procedure + Cursor
you mention you get an error when executing, have you gotten past this exception? You may want to turn on TopLink logging to see the statement TopLink is creating and sending to the driver. Please see
http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/sescfg004.htm
If you are not familar with how to turn on logging.
Also, are you able to get results from a stored procedure that returns data instead of a cursor?
Best Regards,
Chris
Similar Messages
-
Excution of a PL/SQL procedure with CURSOR for big tables
I have prepared a proceudre that uses CURSOR to make a complex query for tables with big number of records, something like 900'000. And the execution failed; ORA-01652:impossible to extend the temporary segment of 64 in the space of storage TEMP.
Any sugestion.This brings us to the following question: How could I calculate the bytes required by a cursor?. It is a selection of certain fields of very big tables. Let's say that the fields are NUMBER(4), NUMBER(8) and CHAR(2). The fields are in 2 relational tables of 900'000 each. What size is required for a procedure like this.
Your help is really appreciated. -
Stored procedure with cursor as out parameter
Can any one help me by showing how to write a procedure with cursor as out parameter and caputuring it in java using jdbc.
Thanks in advance,
shravan bharadwajI know that in the SQLJ distribution (which is also downloadable) there is an example in the demo directory called RefCursDemo that shows the SQL code and how to call it - albeit from SQLJ and not JDBC. There may also be a demo in the JDBC distribution, though I am not sure about that.
-
PL/SQL Procedures with the same name
Hi,
I have some PL/SQL procedures with the same name but different arguments.
If I try to catalog the second or third ALBPM always catalogs the first and I don't want to use this. ALBPM only catalogs the first one.
ALBPM Studio Logs:
Introspecci?n en curso...
Agregando procedimiento 'ADM_SGI.UGDIASINOI'
Agregando procedimiento 'ADM_SGI.UGDIASINOI'
Agregando procedimiento 'ADM_SGI.UGDIASINOI'
[Advertencia] No se puede agregar procedimiento 'UGDIASINOI'. Motivo: Duplicar nombre del componente (M?dulo DatabaseRoot.ADM_SGI - Componente UGDIASINOI)..
[Advertencia] No se puede agregar procedimiento 'UGDIASINOI'. Motivo: Duplicar nombre del componente (M?dulo DatabaseRoot.ADM_SGI - Componente UGDIASINOI)..
Analizando componentes
Any solution or idea??
Thanks!I need to retrive data from PL/SQL stored procedures. I am using the DynamicSQL component (2nd workaround) to retrive data from PL/SQL stored procedures. <br><br>
I am having some problems.<br><br>
This is the code I am running in Fuego Studio 5.5 SP 11 Build #71108:<br><br>
dynamicSQL as Fuego.Sql.DynamicSQL<br>
iterator as Iterator(Any[Any])<br>
sentence as String<br>
implname as String<br><br>
dynamicSQL = Fuego.Sql.DynamicSQL()<br>
implname = "conexionORBPAU"<br>
sentence = "var result REFCURSOR; " + <br>
"exec :result_cursor := pkg_audbpm_bpaasig_indicador.prgetsingle(9999);";<br>
iterator = executeQuery(DynamicSQL, sentence, implname, inParameters : []);<br><br>
And, this is the error:<br><br>
java.sql.SQLException: Falta el parametro IN o OUT en el indice:: 1 <br>
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)<br> at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)<br>
oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)<br>
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)<br>
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)<br>
at fuego.jdbc.FaultTolerantPreparedStatement.executeQuery(FaultTolerantPreparedStatement.java:579)<br>
at fuegoblock.sql.DynamicSQL.executeQuery(DynamicSQL.java:340)<br>
...<br><br>
This is the code of the PL/SQL in the Oracle DB:<br><br>
CREATE OR REPLACE PACKAGE PKG_AUDBPM_BPAASIG_INDICADOR IS<br>
TYPE cursor_type IS REF CURSOR;<br>
FUNCTION prGetSingle<br>
(<br>
p_ID_ASIG_INDICADOR IN NUMBER<br>
)<br>
RETURN cursor_type;<br><br>
END PKG_AUDBPM_BPAASIG_INDICADOR;<br><br>
is my code OK? Any ideas?<br><br>
Thanks in advance.<br> -
Creating Web service for PL/SQL Procedure with Complex Data Types
I need to created web service for PL/SQL Procedure with Complex Data types like table of records as parameters, how do we map the pl/sql table type parameters with web service, how to go about these?
Hello,
When you are creating a service from a Stored Procedure, the OracleAS WS tools will create necessary Java and PL wrapper code to handle the complex types (table of record) properly and make them compatible with XML format for SOAP messages.
So what you should do is to use JDeveloper or WSA command line, to create a service from your store procedure and you will see that most of the work will be done for you.
You can find more information in the:
- Developing Web Services that Expose Database Resources
chapter of the Web Service Developer's guide.
Regards
Tugdual Grall -
How to call sql procedure with parameter from java
Hello,
i am trying to call one sql procedure with two parameters from java.
the first parameter is In parameter, the second is OUT.
the return value of this java method should be this second parameter value.
the following is my java code:
protected String getNextRunNumber() {
String runnumber=null;
String sql = "{call APIX.FNC_SST_EXPORT.GET_NEXT_RUNNUMBER (?,?)}";
CallableStatement state = null;
try{
Connection con= getDatabaseConnection();
state = con.prepareCall(sql);
state.setString(1, m_appKeyExport);
state.registerOutParameter(2,Types.NUMERIC,0);
state.execute();
ResultSet resultR = (ResultSet)state.getObject(2);
while (resultR.next()) {
runnumber=resultR.getBigDecimal(1).toString();
catch (SQLException e){System.out.println("You can not get the export next run number properly");}
return runnumber;
i got error message like:
java.lang.ClassCastException: java.math.BigDecimal
As far as i knew, if the parameter is number or decimal, we should give also the paramer scale to the method: state.registerOutParameter(), but i still get this error message.
Please help me to solve this problem.
Thanks a lot.state.execute();
i try to use debug to find the problem, in this line, i saw
OracleCallableStatement(OraclePreparedStatement).execute() line: 642 [local variables unavailable]
is this the problem? -
Stored procedure with cursor as output param
It's the first time for me to test a stored procedure with a cursor as output parameter. I executed the following:
SQL> VARIABLE user_cur REFCURSOR; VARIABLE ret_code VARCHAR2; exec TEST_API.SEARCH_USER( :ret_code, '', '', 'john', '', :user_cur); print ret_code;print user_cur;
I got the following error:
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR ] ]
May I know what's the problem?
The purpose of the stored procedure is to search for user with the name "john".
The stored procudure input/output params declaration is as follows:
PROCEDURE SEARCH_USER
RETURN_CODE OUT VARCHAR2,
USER_ID_IN IN VARCHAR2,
POSITION_IN IN VARCHAR2,
USERNAME_IN IN VARCHAR2,
STATUS_IN IN VARCHAR2,
USER_CUR_OUT OUT REFCURSOR
Edited by: user7383310 on Oct 19, 2008 9:05 PM
Edited by: user7383310 on Oct 19, 2008 9:05 PMfor the usage of refcursors in pl/sql refer here..
http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10807/06_ora.htm#sthref808
You can code like..
SQL> create or replace procedure p1(id number,csr out sys_refcursor) is
2 begin
3 open csr for select ename from emp where deptno = id;
4 end;
5 /
Procedure created.
SQL> var csr1 refcursor
SQL> var n number
SQL> exec :n := 30;
PL/SQL procedure successfully completed.
SQL> exec p1(:n,:csr1);
PL/SQL procedure successfully completed.
SQL> print csr1
ENAME
ALLEN
WARD
MARTIN
BLAKE
TURNER
JAMES
6 rows selected. -
Running SQL Procedure with dg4msql errors: Function sequence error HY010
I am trying to execute a stored procedure on a SQL database and get the error Function sequence error HY010.
A simple query on a table returns teh expected result.
I have a single Win2008R2 server with MSSQL Express 2008 and Oracle 11gR2 (32bit not 64bit version of Oracle)
Below is the gateway init, listener and tnsnames files and the query I am trying to run:
-- initORIONWASP.ora --
HS_FDS_CONNECT_INFO=INGRDB//waspForGIS
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
HS_CALL_NAME=dbo.spTest;dbo.spQueryAsset;dbo.spQueryAssetDetails
HS_FDS_PROC_IS_FUNC=TRUE
HS_FDS_RESULTSET_SUPPORT=TRUE
-- Listener.ora -- (partial)
(SID_DESC =
(SID_NAME = ORIONWASP)
(ORACLE_HOME = C:\Oracle\product\11.2.0\dbhome_1)
(PROGRAM=dg4msql)
-- tnsnames.ora -- (partial)
ORIONWASP =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=INGRDB)(PORT=1521))
(CONNECT_DATA=(SID=ORIONWASP))
(HS=OK)
-- Simple Query --
Running select "Asset_ID" from asset@ORIONWASP; returns the correct result
Running select * from sys.procedures@ORIONWASP; returns a list of procedures including the procedure I want to run
-- This pl/sql block returns the error ******* identifier 'spTest@ORIONWASP' must be declared *******
declare
begin
"spTest"@ORIONWASP;
end;
-- This passthrough pl/sql block returns ******** [Oracle][ODBC SQL Server Driver]Function sequence error {HY010} ********
DECLARE
CRS BINARY_INTEGER;
RET BINARY_INTEGER;
v_COL1 VARCHAR2(50);
v_COL2 VARCHAR2(50);
BEGIN
CRS := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@ORIONWASP;
DBMS_HS_PASSTHROUGH.PARSE@ORIONWASP(CRS, 'exec spTest');
BEGIN
RET := 0;
WHILE (TRUE)
LOOP
ret := DBMS_HS_PASSTHROUGH.FETCH_ROW@ORIONWASP(CRS, FALSE);
DBMS_HS_PASSTHROUGH.GET_VALUE@ORIONWASP(CRS, 1, v_COL1);
DBMS_HS_PASSTHROUGH.GET_VALUE@ORIONWASP(CRS, 2, v_COL2);
DBMS_OUTPUT.PUT_Line('Col1:'||v_COL1||' Col2:'||v_COL2);
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
DBMS_OUTPUT.PUT_LINE('End of Fetch');
DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@ORIONWASP(CRS);
END;
END;
END;
/The gateway configuration file contains:
HS_FDS_PROC_IS_FUNC=TRUE
HS_FDS_RESULTSET_SUPPORT=TRUE
This setting commonly causes problems and you need to set
HS_FDS_PROC_IS_FUNC=TRUE
HS_FDS_RESULTSET_SUPPORT=FALSE
for normal procedure calls and
HS_FDS_PROC_IS_FUNC=FALSE
HS_FDS_RESULTSET_SUPPORT=TRUE
when calling the procedure with ref cursors.
There's a note in My Oracle Support that gives you examples how to call remote SQl Server procedures
Note.197192.1 Different Methods How To Call MS SQL Server Procedures Using TG4MSQL - DG4MSQL
and another one for the Sybase gateway but this code is similar for the SQL Server:
Article-ID: Note 351400.1
Title: How to Call a Remote Sybase Procedure Using TG4SYBS -
Debugging PL/SQL procedures with JDeveloper ?
Hi,
does anyone know if it is possible to debug PL/SQL procedures and packages with JDeveloper ? I'm using a 9.0.1.2.0 database but JDeveloper returns the error "The target VB_TEST could not be started because the database version does not support debugging." when I try to debug a PL/SQL procedure.
If it is not possible, does anyone know a good alternative ?Oracle Script Debugger is not available anymore at technet.I need to retrive data from PL/SQL stored procedures. I am using the DynamicSQL component (2nd workaround) to retrive data from PL/SQL stored procedures. <br><br>
I am having some problems.<br><br>
This is the code I am running in Fuego Studio 5.5 SP 11 Build #71108:<br><br>
dynamicSQL as Fuego.Sql.DynamicSQL<br>
iterator as Iterator(Any[Any])<br>
sentence as String<br>
implname as String<br><br>
dynamicSQL = Fuego.Sql.DynamicSQL()<br>
implname = "conexionORBPAU"<br>
sentence = "var result REFCURSOR; " + <br>
"exec :result_cursor := pkg_audbpm_bpaasig_indicador.prgetsingle(9999);";<br>
iterator = executeQuery(DynamicSQL, sentence, implname, inParameters : []);<br><br>
And, this is the error:<br><br>
java.sql.SQLException: Falta el parametro IN o OUT en el indice:: 1 <br>
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)<br> at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)<br>
oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)<br>
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)<br>
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)<br>
at fuego.jdbc.FaultTolerantPreparedStatement.executeQuery(FaultTolerantPreparedStatement.java:579)<br>
at fuegoblock.sql.DynamicSQL.executeQuery(DynamicSQL.java:340)<br>
...<br><br>
This is the code of the PL/SQL in the Oracle DB:<br><br>
CREATE OR REPLACE PACKAGE PKG_AUDBPM_BPAASIG_INDICADOR IS<br>
TYPE cursor_type IS REF CURSOR;<br>
FUNCTION prGetSingle<br>
(<br>
p_ID_ASIG_INDICADOR IN NUMBER<br>
)<br>
RETURN cursor_type;<br><br>
END PKG_AUDBPM_BPAASIG_INDICADOR;<br><br>
is my code OK? Any ideas?<br><br>
Thanks in advance.<br> -
Select clause inside a Procedure with cursor
Good Moring guys,
I run into a problem that is giving me serious troubles.... I have a Select clause:
SELECT count(*)
FROM TD004_ENT_ORGAO_UO TD004
WHERE TD004.CODG_ENTIDADE = 1121742
AND TD004.NUMR_ANO_EXERCICIO = 2011
AND TD004.CODG_ORGAO = 02
AND TD004.CODG_UO = 001
My table is empty and this query returns a count = 0, so far so good but, when I'm using this same query inside a Procedure that implements a cursor, I'm implementing a way of controling when to or not insert the records of this cursor in my table:
OPEN cDIMENSAO;
LOOP
FETCH cDIMENSAO INTO EXERCICIO, CODG_ORGAO, NOME_ORGAO, CODG_UO, NOME_UO, CODG_ENTIDADE, SK_ENTIDADE;
EXIT WHEN cDIMENSAO%NOTFOUND;
begin
v_count := 0;
SELECT count(*) into V_COUNT
FROM TD004_ENT_ORGAO_UO TD004
WHERE TD004.CODG_ENTIDADE = CODG_ENTIDADE
AND TD004.NUMR_ANO_EXERCICIO = EXERCICIO
AND TD004.CODG_ORGAO = CODG_ORGAO
AND TD004.CODG_UO = CODG_UO;
IF V_COUNT = 0 THEN
INSERT INTO APLIC.TD004_ENT_ORGAO_UO(SK_ENT_ORGAO_UO, NUMR_ANO_EXERCICIO, CODG_ORGAO, NOME_ORGAO, CODG_UO, NOME_UO, CODG_ENTIDADE, SK_ENTIDADE, DATA_CARGA)
VALUES (APLIC.SK004_ENT_ORGAO_UO.NEXTVAL, EXERCICIO, CODG_ORGAO, NOME_ORGAO, CODG_UO, NOME_UO,CODG_ENTIDADE,SK_ENTIDADE,v_data_carga);
COMMIT;
END IF;
The problem occurs here, my v_count controler just returns 1 even if the record isnt inside my table, is like the Where clasue is being ignored. What can be done ??
I'm using the Oracle XE 11g.
Thnks all.See below. Where clause will never ignore any condition
Note: you need handle null values specially
SQL>
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL>
SQL> set serveroutput on;
SQL>
SQL> DECLARE
2 CURSOR c1
3 IS
4 WITH dmn
5 AS (SELECT 1 col1, 'TEST' col2, NULL col3 FROM DUAL
6 UNION ALL
7 SELECT 2 col1, 'TESTING' col2, 'COL3' col3 FROM DUAL
8 UNION ALL
9 SELECT 3 col1, 'TESTING123' col2, 'COL3' col3 FROM DUAL
10 )
11 SELECT *
12 FROM dmn;
13
14 v_col1 VARCHAR2 (10);
15 v_col2 VARCHAR2 (10);
16 v_col3 VARCHAR2 (10);
17 v_count NUMBER;
18 BEGIN
19 OPEN c1;
20
21 LOOP
22 FETCH c1
23 INTO v_col1, v_col2, v_col3;
24 EXIT WHEN c1%NOTFOUND;
25
26 WITH txn
27 AS (SELECT 1 col1, 'TEST' col2, NULL col3 FROM DUAL
28 UNION ALL
29 SELECT 2 col1, 'TESTING' col2, 'COL3' col3 FROM DUAL
30 )
31 SELECT COUNT (*)
32 INTO v_count
33 FROM txn
34 WHERE col1 = v_col1
35 AND col2 = v_col2
36 AND nvl(col3,'##') = nvl(v_col3, '##');
37
38 DBMS_OUTPUT.put_line ('V_count = ' || v_count);
39 IF v_count = 0
40 THEN
41 DBMS_OUTPUT.put_line ('Insert is processed for ' || v_col1);
42 ELSE
43 DBMS_OUTPUT.put_line ('Insert is Ignored for ' || v_col1);
44 END IF;
45 v_count := 0;
46 END LOOP;
47 END;
48 /
V_count = 1
Insert is Ignored for 1
V_count = 1
Insert is Ignored for 2
V_count = 0
Insert is processed for 3
PL/SQL procedure successfully completed.
Thanks,
GPU -
Pl/sql procedure with shell script
Hi Guys,
I will be updating some of the columns in the database thru SQL UPDATE stament. I want to make this process automatic. I.e instead of running manually this uodate process, i want to write a unix script which run on cron job. In the update stament I have to compare date like e_create_date > to_date (........, 'yymmdd') and date should be 2 days previous then to date and I would ike to create the spool file which I would like to send through mail.the script will run automatically.
I am confused how to write shell script & sql procedure and how to call it inside the shell script. How can this be done.
Help Appreciated.
Thanks
sonusave the Store procedure as a create_SP.sql in OS
save another testrun.sql
as follows
begin
sp_test('&p_test');
end;
If you are on a Unix or Solaris OS then
open a Shell Script as follows :
and name as test.sh or test.ksh
var='SYSTEM'
export var
sqlplus username/password
@create_SP.sql
-- this created a store procedure on the database
@testrun.sql $var
This will execute the SP with parameter from OS Variable. -
FND_REQUEST PL/SQL procedure with parameters
Hi guys
I have created a concurrent program, using PL/SQL procedure which has 2 in parameters. I am trying to call the concurrent program using
v_req_id :=FND_REQUEST.SUBMIT_REQUEST('INV','OMS_POP_INVVALUES_P',
NULL,SYSDATE,FALSE,l_on_date, l_org_id,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
COMMIT;
However, the concurrent program always failing with
**Starts**26-AUG-2013 14:02:31 ORACLE error 6550 in FDPSTP Cause: FDPSTP failed due to ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'OMS_POP_INVVALUES_P' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
and I doubt it is because the database procedure call is not proper.
I have set four parameters with the concurrent program, as they were with the procedure itself, which are
p_on_date IN DATE, p_org_id IN NUMBER, errbuff OUT VARCHAR2,retcode OUT VARCHAR2
Please help
regards,
rajOkay I fixed the problem by
1. Changing the order of parameters with Procedure like following
CREATE OR REPLACE PROCEDURE OMS_POP_INVVALUES_P (
errbuff OUT VARCHAR2,retcode OUT NUMBER, p_on_date IN DATE, p_org_id IN NUMBER)
IS
and then changing the concurrent program call like following
l_req_id :=
fnd_request.submit_request('INV','OMS_POP_INVVALUES_P',
NULL,SYSDATE,FALSE,l_in_date, l_org_id,CHR(0));
:SYSTEM.Message_Level := '25';
COMMIT;
after removing all the parameters from the program parameter list. No need to pass any value for errbuff and retcode, just pass other parameters and end the parameter list with CHR(0). Hope this is useful for somebody else out there.
Regards,
raj -
I was trying to create a PL/SQL block where I am trying to call all the SQL Plans and then drop them one by one. Here is how I am doung -
SET SERVEROUT ON;
DECLARE
EXECSTR VARCHAR2(50);
v_plans_dropped pls_integer;
CURSOR C1 IS SELECT SQL_HANDLE FROM DBA_SQL_PLAN_BASELINES;
BEGIN
FOR I IN C1 LOOP
EXECSTR := ''''||I.SQL_HANDLE||'''';
v_plans_dropped:=dbms_spm.drop_sql_plan_baseline(sql_handle=>EXECSTR);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('ERROR while dropping SQL PLAN: ' || SQLCODE || ' : ' || SQLERRM);
END;
This is giving me error like - ERROR while dropping SQL PLAN: -38131 : ORA-38131: specified SQL handle
'SYS_SQL_1470897e7b72c982' does not exist
Whereas this SQL Plan is there in the baseline - SELECT sql_handle FROM dba_sql_plan_baselines;
SQL_HANDLE
SYS_SQL_1470897e7b72c982
SYS_SQL_75ac336a8071cb06
SYS_SQL_269cdcd4862f8685
SYS_SQL_269cdcd4862f8685
SYS_SQL_0ffdb3bddbe422e2
SYS_SQL_14d81bbae4a7cc93
SYS_SQL_5c512b58e7795ba2
SYS_SQL_33515785e80b75d0
Above PL/SQL block should be same as like deleting it one by one -
DECLARE
v_plans_dropped pls_integer;
BEGIN
v_plans_dropped:=dbms_spm.drop_sql_plan_baseline(sql_handle=>'SYS_SQL_1470897e7b72c982');
END;
If I run this then it will be sucessul but when I run under a PL/SQL block using cursor then it is giving me error ORA-38131.
Can you please tell me where I am going wrong here.
Thanks for your time!I have this PL/SQL block -
DECLARE
v_plans_dropped pls_integer;
CURSOR C1 IS SELECT SQL_HANDLE FROM DBA_SQL_PLAN_BASELINES;
BEGIN
FOR I IN C1 LOOP
v_plans_dropped:=dbms_spm.drop_sql_plan_baseline(sql_handle=>I.SQL_HANDLE);
END LOOP;
END;
Requirement - This PL/SQL block should read all the records from DBA_SQL_PLAN_BASELINES table and drop all the plans one by one.
Problem - It gives me error like this -
SQL> 2 3 4 5 6 7 8 9 DECLARE
ERROR at line 1:
ORA-38131: specified SQL handle SYS_SQL_45c1170505dda9a9 does not exist
ORA-06512: at "SYS.DBMS_SPM", line 2444
ORA-06512: at line 6
Analysis: When I ran it 4 times, it showed me that the remaining records after the pl/sql run was like -
SQL> SELECT COUNT(*) FROM DBA_SQL_PLAN_BASELINES;
After First Run -
COUNT(*)
33429
After Second Run -
COUNT(*)
33255
After Third Run -
COUNT(*)
33228
After Fourth Run -
COUNT(*)
32988
So, it deletes records but errors out in between. Is it because the PL/SQL block/cursor is not structured properly?
Thanks for your advice! -
OCCI call PL/SQL Procedure with 2 IN/OUT Parameters..BUS ERROR!!
Hi~ All,
I am new user for using OCCI. Util now, I encountered a problem with OCCI when I call a procedure with 2 IN/OUT parameters. Then,I got an error(core dump), Why?
CREATE OR REPLACE PROCEDURE demo_proc (v1 in integer, v2 in out varchar2, v3 in out varchar2);
==== OCCI Code ========
stmt = conn->createStatement
("BEGIN demo_proc(:v1, :v2, :v3); END;");
cout << "Executing the block :" << stmt->getSQL() << endl;
stmt->setInt (1, 10);
stmt->setString (2, "Test1");
stmt->setString (3, "First");
int updateCount = stmt->executeUpdate ();
cout << "Update Count:" << updateCount << endl;
cout << "Printing the INOUT & OUT parameters:" << endl;
string c1 = stmt->getString (2);
cout << c1 << endl;
string c2 = stmt->getString (3);
==== RUN RESULT ====
Bus error(coredump)
But, If i just only got one of string from v1 or v2,I could get correct result!! Why? Does some one know how to avoid this two IN/OUT parameters issue?Hi~ Amoghavarsha,
Thanks for your response! I solved the problem by myself. I found the root cause, it seems very strange in
initializing environment variable.
=== FAILED ===
Environment *env;
=== SUCCESS ===
Environment *env = NULL; <---Why??
cout << "occidml - createEnvironment" << endl;
env = Environment::createEnvironment (Environment::OBJECT);
Eventually, I fixed this issue in Win2K and HP-UX 11.
Best Regards, -
Using FOR .. LOOP counter in handling of PL/SQL procedures with nest. table
Hi all!
I'm learning PL/SQL on Steve Bobrovsky's book (specified below sample is from it) and I've a question.
In the procedure of specified below program used an integer variable currentElement to get reference to the row of nested table of %ROWTYPE datatype.
Meanwhile, the program itself uses a common FOR .. LOOP counter i.
DECLARE
TYPE partsTable IS TABLE OF parts%ROWTYPE;
tempParts partsTable := partsTable();
CURSOR selectedParts IS
SELECT * FROM parts ORDER BY id;
currentPart selectedParts%ROWTYPE;
currentElement INTEGER;
PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS
BEGIN
DBMS_OUTPUT.PUT_LINE(' ');
DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT);
currentElement := p_collection.FIRST;
FOR i IN 1 .. p_collection.COUNT
LOOP
DBMS_OUTPUT.PUT('Element #' || currentElement || ' is ');
IF tempParts(currentElement).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.');
ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(currentElement).id || ' DESCRIPTION: ' || tempParts(currentElement).description);
END IF;
currentElement := p_collection.NEXT(currentElement);
END LOOP;
END printParts;
BEGIN
FOR currentPart IN selectedParts
LOOP
tempParts.EXTEND(2);
tempParts(tempParts.LAST) := currentPart;
END LOOP;
printParts('Densely populated', tempParts);
FOR i IN 1 .. tempParts.COUNT
LOOP
IF tempParts(i).id is NULL THEN tempParts.DELETE(i);
END IF;
END LOOP;
FOR i IN 1 .. 50
LOOP
DBMS_OUTPUT.PUT('-');
END LOOP;
printParts('Sparsely populated', tempParts);
END;
/When I've substituted an INTEGER global variable with such FOR .. LOOP counter, an APEX have returned an error "ORA-01403: no data found".
DECLARE
TYPE partsTable IS TABLE OF parts%ROWTYPE;
tempParts partsTable := partsTable();
CURSOR selectedParts IS
SELECT * FROM parts ORDER BY id;
currentPart selectedParts%ROWTYPE;
PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS
BEGIN
DBMS_OUTPUT.PUT_LINE(' ');
DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT);
FOR i IN 1 .. p_collection.COUNT
LOOP
DBMS_OUTPUT.PUT('Element is ');
IF tempParts(i).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.');
ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(i).id || ' DESCRIPTION: ' || tempParts(i).description);
END IF;
END LOOP;
END printParts;
BEGIN
FOR currentPart IN selectedParts
LOOP
tempParts.EXTEND(2);
tempParts(tempParts.LAST) := currentPart;
END LOOP;
printParts('Densely populated', tempParts);
FOR i IN 1 .. tempParts.COUNT
LOOP
IF tempParts(i).id is NULL THEN tempParts.DELETE(i);
END IF;
END LOOP;
FOR i IN 1 .. 50
LOOP
DBMS_OUTPUT.PUT('-');
END LOOP;
printParts('Sparsely populated', tempParts);
END;
/When I've tried to handle this code in SQL*Plus, the following picture have appeared:
Densely populated elements: 10
Element is an empty element.
Element is ID: 1 DESCRIPTION: Fax Machine
Element is an empty element.
Element is ID: 2 DESCRIPTION: Copy Machine
Element is an empty element.
Element is ID: 3 DESCRIPTION: Laptop PC
Element is an empty element.
Element is ID: 4 DESCRIPTION: Desktop PC
Element is an empty element.
Element is ID: 5 DESCRIPTION: Scanner
Sparsely populated elements: 5
DECLARE
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at line 14
ORA-06512: at line 35What's wrong in code(or what I have not understood)? Help please!942736 wrote:
What's wrong in code(or what I have not understood)? Help please!First code. You have collection of 10 elements:
1 - null
2 - populated
3 - null
4 - populated
5 - null
6 - populated
7 - null
8 - populated
9 - null
10 - populated
Then you delete null elements and have 5 element collection
2 - populated
4 - populated
6 - populated
8 - populated
10 - populated
Now you execute:
printParts('Sparsely populated', tempParts);Inside procedure you execute:
currentElement := p_collection.FIRST;
This assingns currentElement value 2. Then procedure loops 5 times (collection element count is 5). Element 2 exists. Inside loop procedure executes:
currentElement := p_collection.NEXT(currentElement);
which assigns currentElement values 4,6,8,10 - all existing elements.
Now second code. Everything is OK until you delete null elements. Again we have:
2 - populated
4 - populated
6 - populated
8 - populated
10 - populated
Again you execute:
printParts('Sparsely populated', tempParts);Now procedure loops 5 times (i values are 1,2,3,4,5):
FOR i IN 1 .. p_collection.COUNT
Very first iteration assingns i value 1. And since collection has no element with substript 1 procedure raises no data found.
SY.
Maybe you are looking for
-
My ipod wont work with this other computer
my computer that had my ipod music and information on it crshed so i went to go use my ipod on my moms computer. she also has an ipod but doesnt use it much so i uninstalled itunes the re-insatlled it under my information. but every time i plug it in
-
NLS support problems when using AL32UTF8 in dads.conf
Hello, Following a post by Joel Kallman, in one of the forum threads, about the mandatory use of AL32UTF8 in dads.conf, when running HTML DB v2.0, I changed my PlsqlNLSLanguage parameter accordingly. Prior to the change, I experienced some problems w
-
I am a photography student in Peru and want to use CC LR & PS in English and I can not get an answer either from customer service in the US or here in Peru. I want to avail myself of the student price in Peru but want to use the software in English.
-
SQ01 Result aftect exporting to Excel not displaying
Dear Friends, When I click on Mircosoft Excel button (Next to Print Preview button), the result of SQ01-SAP Query result is not exporting to Excel. I can able to save the result as Excel when I click on Local File and select Spreadsheet. Any idea whe
-
I am having a problem with typing messages on my 9300 curve in any application. Example: trying to type message in bbm and cursor bounces all over screen, and when you are finally able to type a letter, sometimes wierd accent marks appear above the l