Migration Issues--Stored Procedure
Hi,
After migrating sql server procedures into oracle using SQL DEVELOPER tool, I observed following things.
In sql server procedure was having follo. syntax at the end to denote its completion
select "ENDED dbo.s_p_fund_aff_ins_pers_seq_no : " , getdate()
return
This got converted into following,
OPEN cv_2 FOR
SELECT 'ENDED dbo.s_p_fund_aff_ins_pers_seq_no : ',
SYSDATE
FROM DUAL WHERE ROWNUM <= 1;
RETURN;
cv_2 is IN OUT SYS_REFCURSOR.
My question is
1) Is it ok to keep the converted code as it is?
2) Do I need to close the cursor?
It's all to do with scope - when a cursor* goes out of scope, then it will be closed automatically. So, your cursors defined within a procedure will automatically close when you exit that procedure and therefore you don't need to explicitly close them.
Ref cursors have scope outside the procedure / package though, so they must be closed explicitly when the process that's using them no longer needs them. (That's how I think of it, anyway!)
Edited by: Boneist on 07-Apr-2009 11:40
* actually, this applies to other things, such as variables, parameters, etc; once they've gone out of scope, they are trashed as they can't be accessed any more.
Similar Messages
-
How to migrate MySQL stored procedure to Oracle
Hi All,
I migrated mysql 5.1.42-enterprise-gpl-advanced DB to oracle using sqldeveloper 3.1.07 tool.
DB objects migrated successfully except Stored Procedures.
I verified .sql and Out files.. Capture process not captured stored procedures SQL.
Could you please suggest, where I can verify exact error or how to fix this issue.
Thanks in advance.Hi,
The SQL*Developer version you are using is an old one and you should use the latest version available from this link -
Oracle SQL Developer
However, even the v4 version does not support the migration of MySQL stored procedures as shown in this link -
http://www.oracle.com/technetwork/developer-tools/sql-developer/supportedmigplatforms-086703.html
You will have to manually convert the MySQL stored procedures to an Oracle format, as even the 'Scratch Editor' under 'Tools - Migration' - does not have an option for MySQL conversion.
The documentation has details of the difference between MySQL and Oracle stored procedures -
Oracle® SQL Developer Supplementary Information for MySQL Migrations
in the chapter Triggers and Stored Procedures
Regards,
Mike -
How to Migrate Stored procedure on Sql server 2008 to Oracle Database
Guys, I need help vey badly as I am new in this field.
Problem is that, I have to migrate stored procedure on Sql server 2008 to oracle Oracle database:
Whole scenario--
1. Sql Server 2008 application on Windows server (source machine)
2. I have to migrate 70 Stored Procedure
3. To Oracle Database on Linux machine (Target machine)
Any method (no problem)
Please, help me or give me any reference as I don't know which keyword is differ in both database.
Thanks in advanceHi,
You could the free Oracle SQL*Developer to do this.
There is information and a download link here -
Oracle SQL Developer</title><meta name="Title" content="Oracle SQL Developer"><meta n…
and information on using it for migrations here -
http://www.oracle.com/technetwork/database/migration/index-084442.html
You could use it in 2 ways -
1. Go through a migration but just pull the stored procedure code from the file created after you generate the SQL from the SQL*Server database
2. Use the scratch editor accessed from -
- Tools - Migration - Scratch Editor
and paste the SQL*Server stored procedure code into the window and it will convert it to Oracle code. The tool is very good but may have problems if you have very complicated procedures that use SQL*Server specific utilities.
Regards,
Mike -
Visual Basic, DAO, Temp tables in stored procedures
Client code currently uses DAO with SQLPassthrough option in VB to connect to SQl 6.5 db.
I migrated all stored procedures with default options except Oracle 8i temp tables. For every procedure a package and a procedure was created. We use SQL server temporary tables extensively in a few hundred stored procedures. The ref cursor created refers to the temporary table. While migratiing, Create table statement is commented. How are SQL6.5 equivalent of temp tables handled in Oracle? Is there an alternative to temp tables?
I also migrated to another oracle db using the INOUT type for stored procedures. This time only procedures were created. Can these procedures return a record set in DAO with SQLPAssthrough?
How do you call a procedure using DAO in VB to get recordsets?
What is the best way to migrate to Oracle with minimal client code changes?
Thank you in advance.
Umesh
nullKarthick_Arp wrote:
BluShadow wrote:
I agree with Karthick, there's no need for a temporary table in this situation.
And to add, temporary tables should not be created at runtime, they should be part of the initial design of the database, created once and used as needed. Creating them at runtime is just wrong.The problem is the name oracle has given to GTT. The word Temporary mislead lot of SQL Server developers and they think its something same as the temporary table used in SQL Server :)Yeah, Ingres does something similar to SQL Server too, in that you can create a temporary table (Ingres assigned it a unique name and tells you what it is), and you set an expiry time on it (i.e. set it to expire in 1 days time), and then a background process is supposed to clean up the tables that have expired. Unlike Oracle, they are not session specific, but become visible to all once created.
I think there's room for both types of temporary table, but Oracle's does the job (except when you want to use them from a stateless application front end). -
Issue with calling a stored procedure as an url in APEX 4.x
We are migrating from APEX 3.2.1 running oracle 10g and using the oracle http server to APEX 4.02 using the embedded pl/sql (xdb) gateway on Oracle 11g R2. On the old server, we were able to execute a stored procedure call that returned custom xml to an anychart. We granted the procedure execute to apex_public_user.
However, the exact same code base is not running on the new installation. I am thinking that it is a rights/grant/execute issue but have been unsuccessful in finding the correct resolution anywhere on the web.
Anyone have any suggestions for my administrators to help resolve this issue?
Thanks,
MarkAlso review this post: 11g EPG - wwv_flow_epg_include_modules - 403 Forbidden
-
Issue while invoking a stored procedure in DB2 from Oracle OSB flow
oracle.tip.adapter.sa.api.JCABindingException: oracle.tip.adapter.sa.impl.fw.ext.org.collaxa.thirdparty.apache.wsif.WSIFException: servicebus:/WSDL/Test_Project/Application/Project1/TestSP [ TestSP_ptt::TestSP(InputParameters,OutputParameters) ] - WSIF JCA Execute of operation 'TestSP' failed due to: Stored procedure invocation error.
Error while trying to prepare and execute the NED.LOGIN_MODULE API.
An error occurred while preparing and executing the NED.LOGIN_MODULE API. Cause: java.lang.NullPointerException
; nested exception is:
BINDING.JCA-11811
Stored procedure invocation error.
Error while trying to prepare and execute the NED.LOGIN_MODULE API.
An error occurred while preparing and executing the NED.LOGIN_MODULE API. Cause: java.lang.NullPointerException
Check to ensure that the API is defined in the database and that the parameters match the signature of the API.This forum is for issues about WebLogic Connector container itself. You may need to post your issue to other forums such as SOA.
Thanks -
Issue with sending mail through java stored procedure in Oracle
Hello
I am using Oracle 9i DB. I created a java stored procedure to send mail using the code given below. The java class works fine standalone. When its run from Java, mail is sent as desired. But when the java stored procedure is called from pl/sql "Must issue a STARTTLS command first" error is thrown. Please let me know if am missing something. Tried the same code in 11.2.0.2 DB and got the same error
Error:
javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. va6sm31201010igc.6
Code for creating java stored procedure: (T1 is the table created for debugging)
==================================================
create or replace and compile java source named "MailUtil1" AS
import java.util.Enumeration;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class MailUtil1 {
public static void sendMailwithSTARTTLS(String host, //smtp.projectp.com
String from, //sender mail id
String fromPwd,//sender mail pwd
String port,//587
String to,//recepient email ids
String cc,
String subject,
String messageBody) {
try{
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "True"); // added this line
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", fromPwd);
props.put("mail.smtp.port", port);
props.put("mail.smtp.auth", "true");
#sql { insert into t1 (c1) values ('1'||:host)};
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
#sql { insert into t1 (c1) values ('2')};
InternetAddress[] toAddress = new InternetAddress[1];
// To get the array of addresses
for( int i=0; i < toAddress.length; i++ ) { // changed from a while loop
toAddress[i] = new InternetAddress(to);
//System.out.println(Message.RecipientType.TO);
for( int i=0; i < toAddress.length; i++) { // changed from a while loop
message.addRecipient(Message.RecipientType.TO, toAddress);
if (cc!=null) {
InternetAddress [] ccAddress = new InternetAddress[1];
for(int j=0;j<ccAddress.length;j++){
ccAddress[j] = new InternetAddress(cc);
for (int j=0;j<ccAddress.length;j++){
message.addRecipient(Message.RecipientType.CC, ccAddress[j]);
message.setSubject(subject);
message.setText(messageBody);
message.saveChanges();
#sql { insert into t1 (c1) values ('3')};
Enumeration en = message.getAllHeaderLines();
String token;
while(en.hasMoreElements()){
token ="E:"+en.nextElement().toString();
#sql { insert into t1 (c1) values (:token)};
token ="ConTyp:"+message.getContentType();
#sql { insert into t1 (c1) values (:token)};
token = "Encod:"+message.getEncoding();
#sql { insert into t1 (c1) values (:token)};
token = "Con:"+message.getContent();
#sql { insert into t1 (c1) values (:token)};
Transport transport = session.getTransport("smtp");
#sql { insert into t1 (c1) values ('3.1')};
transport.connect(host, from, fromPwd);
#sql { insert into t1 (c1) values ('3.2')};
transport.sendMessage(message, message.getAllRecipients());
#sql { insert into t1 (c1) values ('3.3')};
transport.close();
#sql { insert into t1 (c1) values ('4')};
catch(Exception e){
e.printStackTrace();
String ex= e.toString();
try{
#sql { insert into t1 (c1) values (:ex)};
catch(Exception e1)
Edited by: user12050615 on Jan 16, 2012 12:18 AMHello,
Thanks for the reply. Actually I have seen that post before creating this thread. I thought that I could make use of java mail to work around this problem. I created a java class that succesfully sends mail to SSL host. I tried to call this java class from pl-sql through java stored procedure. That did not work
So, is this not supported in Oracle ? Please note that I have tested this in both 9i and 11g , in both the versions I got the error. You can refer to the code in the above post.
Thanks
Srikanth
Edited by: user12050615 on Jan 16, 2012 12:17 AM -
Stored Procedure issue in receiver JDBC synchronous scenario
Dear Experts,
Below is the description of the Stored Procedure for my requirement which has 1 input and 7 output.
CREATE OR REPLACE PROCEDURE emp_det_proc
p_emp_id IN NUMBER,
cur_det OUT sys_refCURSOR
aS
BEGIN
OPEN cur_det FOR
SELECT * FROM EMP_PERSON_VIEW
WHERE id = p_emp_id;
END emp_det_proc;
Inside the procedure , we can see that Select query is done on a VIEW which has some 7 column and these are the output. The data type description of the ID is VARCHAR2 in Oracle Database 11g VIEW, that's why I maintained VARCHAR in Constant mapping at SAP-PI side.
I am maintaining all the column name present in the view for my JDBC request structure with isOutput and type.
Below is my JDBC request.
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MT_ECCJDBC_EmpStrdProc_JDBCReq xmlns:ns0="urn:empdet:sap:jdbc:storedprocedure">
- <Statement>
- <emp_det_proc action="EXECUTE">
<table>emp_det_proc</table>
<ID isInput="true" type="VARCHAR">200178</ID>
</emp_det_proc>
</Statement>
</ns0:MT_ECCJDBC_EMPStrdProc_JDBCReq>
I tested with other XSD type like INT/CHAR/ but with the same error.
Unable to execute statement for table or stored procedure. 'emp_det_proc' (Structure 'Statement') due to java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'EMP_DET_PROC'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
1. I observed that the Key field ID is maintained as NUMBER in Stored Procedure but in the VIEW it is maintained as VARCHAR2.
Could anyone help me to solve the issue with any suggestions?
Regards
RebeccaDear Ramesh,
There are change in the datatype of the Stored Procedure Input parameter. Below is the correct procedure description now.
Select query of the View
My JDBC structure
Observation and querry:
1. In the SP declaration, there is 1 IN parameter which I have created in JDBC structure as p_moi_id and gave the type as INTEGER.
Error : JDBC message processing failed; reason Error processing request in sax parser: Error when executing statement for table/stored proc. 'moi_det_proc' (structure 'Statement'): java.lang.NumberFormatException: For input string: "2*********&49"
I assume since the range of the number is limited . Integers are values up to 2147483647 and the number I am using is greater than this values.
2. I assume I have not included the parameter cur_det as OUT. Instead I have maintained the COLUMN names of Select query of the view. Should I remove all the Out parameters which represents inside the View.
3. What could be the Data type equivalent to Oracle sys_refCURSOR in SAP PI?
Please share you suggestion.
Regards
Rebecca -
Issue when calling Stored procedure from application
Dear all,
Oracle DB version: 11.2.0.3
OS : RHEL 5.9 64-bit version
We are trying to execute one of the stored procedure (belonging to oracle DB schema) from our Dotnet application(recites in application server) but it takes more than 30 seconds to fetch the records. The stored procedure is called from application. When we try the same procedure from SQL developer or TOAD it completes within a second. Could anyone suggest on the issue?
Note: we are calling a remote DB view from our DB.
No. of records in the view : 49484929 rows
Thanks in advance,
Imran KhanThanks Billy for the reply. The following is the function of the .net application which calls the procedure:
public DataSet ResourceMonitor(String Date, String DateTime, String starttime, String endtime, String Assstarttime, String Assendtime)
try
cLog.StartMethod(this, System.Reflection.MethodInfo.GetCurrentMethod().Name);
Database dbResourceMonitor = null;
DataSet Resourceset = new DataSet();
dbResourceMonitor = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = dbResourceMonitor.GetStoredProcCommand("SP_RESOURCEMONITOR1");
dbResourceMonitor.AddInParameter(dbCommand, "P_Date", DbType.String, Date);
dbResourceMonitor.AddInParameter(dbCommand, "P_DateTime", DbType.String, DateTime);
dbResourceMonitor.AddInParameter(dbCommand, "P_Starttime", DbType.String, starttime);
dbResourceMonitor.AddInParameter(dbCommand, "P_Endtime", DbType.String, endtime);
dbResourceMonitor.AddInParameter(dbCommand, "P_AssStarttime", DbType.String, Assstarttime);
dbResourceMonitor.AddInParameter(dbCommand, "P_AssEndtime", DbType.String, Assendtime);
//dbCommand.Parameters.Add(BuildRefCursorParameter("DEPRECSET"));
dbCommand.Parameters.Add(BuildRefCursorParameter("RECORDSET1"));
dbCommand.Parameters.Add(BuildRefCursorParameter("RECORDSET2"));
dbCommand.Parameters.Add(BuildRefCursorParameter("RECORDSET3"));
dbCommand.Parameters.Add(BuildRefCursorParameter("RECORDSET4"));
return Resourceset;
catch (Exception ex)
cLog.LogMessages(this, ex.Message, cLog.eWiproMessageTypes.ErrorType);
throw ex;
finally
cLog.EndMethod(this, System.Reflection.MethodInfo.GetCurrentMethod().Name);
The stored procedure SP_RESOURCEMONITOR1 has the following DDL:
CREATE OR REPLACE PROCEDURE SP_RESOURCEMONITOR1
( P_Date IN VARCHAR2,
P_DateTime IN VARCHAR2,
P_Starttime IN VARCHAR2,
P_Endtime IN VARCHAR2,
P_AssStarttime IN VARCHAR2,
P_AssEndtime IN VARCHAR2,
P_Mode IN NUMBER,
RECORDSET1 OUT SYS_REFCURSOR,
RECORDSET2 OUT SYS_REFCURSOR,
RECORDSET3 OUT SYS_REFCURSOR,
RECORDSET4 OUT SYS_REFCURSOR
)AS
BEGIN
OPEN RECORDSET1 FOR
Select ROLEMASTER.ROLEID,ROLEMASTER.ROLENAME as ResourceGroup,departmentmaster.DEPARTMENTNAME,departmentmaster.departmentid from Rolemaster
INNER JOIN departmentmaster ON Rolemaster.DEPTID=departmentmaster.DEPARTMENTID
WHERE 1=1 AND sysdate >=Rolemaster.START_DATE AND sysdate<=Rolemaster.END_DATE AND Upper(RoleMaster.Rolename) not like '%HIGHLOADER%' AND displayinlist=1
ORDER BY ROLENAME;
OPEN RECORDSET2 FOR
select ROM.ROLENAME as ResourceGroup, fn_get_resource_status(p_starttime, p_endtime,RM.Resourceid,RM.DeptID) AS Status,upper(RM.Resourceid)as Resourceid,RM.RoleID,RM.DeptID,TRIM(RM.RESOURCENAME) AS RESOURCENAME,'Detail'As Details,'ResChng'As ResChng,'Calender' As Calender FROM ResourceMaster RM
--INNER JOIN DEPARTMENTMASTER DM ON RM.DEPTID = DM.DEPARTMENTID
INNER JOIN ROLEMASTER ROM ON RM.ROLEID = ROM.ROLEID
where --UPPER (DM.DEPARTMENTNAME) IN ('DISPATCH','TRANSPORT','TRANSPORT RAMP')
RM.DEPTID in (select DEPARTMENTID from DEPARTMENTMASTER where displayinadmin=1 and active=1) ;
if (P_Mode =2) THEN
OPEN RECORDSET3 FOR
select * from mobility_attendance_info_v where TRANSACTIONDATE >= TO_DATE(Substr(p_starttime,1, 9) ,'dd-MON-rr') - 1 order by staffno,TRANSACTIONDATETIME Desc;
END IF;
OPEN RECORDSET4 FOR
select rsa.*,planning.flightno,'' As StTime,SUBSTR(rsa.depdt,11,5) as EndTime from resourceallocation rsa inner join planning ON rsa.planningid = planning.planningid
where TO_TIMESTAMP(rsa.DEPDT,'dd-MON-rr HH24:MI')>=TO_TIMESTAMP(P_DateTime,'dd-MON-rr HH24:MI') ;
END SP_RESOURCEMONITOR1;
The view mobility_attendance_info_v is a called from a remote DB. Hope it's quite clear.
Regards,
Imran Khan -
Stored Procedure Command issues in CS3
I've been having a problem using some stored procedures in
CS3 which had previously worked with no issue in 8.0.2. I'm running
CS3 on a Mac for ASP & SQL Server 2000.
The input parameters for the stored procedure are...
Fieldname: CategoryID (int) length: 4
Fieldname: Men (bit) length: 1
Fieldname: Women(bit) length:1
I have no problem using the Command function to call this
stored procedure in DW 8.0.2, but in CS3, while I am able to TEST
the recordset successfully within the Command dialog, when I press
OK and then attempt to view the field list in the Bindings panel, I
get this error...
[Microsoft][ODBC SQL Server Driver][SQL Server]Procedure
'spCategoryProduct' expects parameter '@Men', which was not
supplied.
When I open up the command settings dialog again, Default
Values and the Runtime Values I entered for the Men and Women bit
parameter are blank. The only Default Value and Runtime Value
retained is for the field CategoryID.
CS3 is able to call other stored procedures which do not
contain a Bit field type without issue, so I'm curious if this is
the culprit.
I have DW8.0.2 still installed on the same system, and have
been able to call this stored procedure in this older version,
without any problems.
Please help!Holy thread-resurrection Batman!
Please open a new dicussion after reading the bi4.0 data access guide: http://help.sap.com/businessobject/product_guides/boexir4/en/xi4sp5_data_acs_en.pdf
Also, please specify which SP and Patch you are using.
Regards,
H -
Migrating Stored procedure from Oracle to Mysql
Dear All,
Please suggest, is ther any tool of stored procedure migration from oracle to mysql.
I tried some tool like
1. Intelligent Converter.
2. Sql way
3. Mysql Migration Toolkit.
But procedure cannot migrate properly.
hb venkiVenki,
I think you are in the wrong place, try finding a MySQL forum ;0) -
MS SQL Server system stored procedures can't be migrated into Oracle 11g
During database migration from MS SQL Server 2008 to Oracle 11g R2, if the application stored procedure invokes the MS SQL Server system stored procedures (for example: sp_getapplock, sp_releaseapplock ....), these SQL server system stored procedures can't be transferred. See following migrated Oracle application stored procedure for example:
create or replace
PROCEDURE spPwSysID_GetNextID
v_ID OUT NUMBER,
iv_SysType IN NVARCHAR2 DEFAULT NULL ,
iv_Cnt IN NUMBER DEFAULT NULL
AS
v_SysType NVARCHAR2(50) := iv_SysType;
v_Cnt NUMBER(10,0) := iv_Cnt;
v_result NUMBER(10,0);
BEGIN
--SQL Server BEGIN TRANSACTION;
utils.incrementTrancount;
v_Systype := UPPER(v_Systype) ;
IF v_Cnt < 1 THEN
v_Cnt := 1 ;
END IF;
v_result :=sp_getapplock(v_Resource => v_Systype,
v_LockMode => 'Exclusive') ;
IF v_result >= 0 THEN
BEGIN
SELECT ID
INTO v_ID
FROM PWSYSID
WHERE SysType = v_SysType;
IF SQL%ROWCOUNT = 1 THEN
UPDATE PwSysID
SET ID = ID + v_cnt
WHERE SysType = v_SysType;
ELSE
BEGIN
INSERT INTO PwSysID
( ID, SysType )
VALUES ( v_cnt + 1, v_SysType );
v_ID := 1 ;
END;
END IF;
v_result :=sp_releaseapplock(v_Resource => v_Systype) ;
END;
ELSE
BEGIN
raise_application_error( -20002, 'Lock failed to acquire to generate Cityworks Id.' );
END;
END IF;
utils.commit_transaction;
END;During database migration from MS SQL Server 2008 to Oracle 11g R2, if the application stored procedure invokes the MS SQL Server system stored procedures (for example: sp_getapplock, sp_releaseapplock ....), these SQL server system stored procedures can't be transferred. See following migrated Oracle application stored procedure for example:
create or replace
PROCEDURE spPwSysID_GetNextID
v_ID OUT NUMBER,
iv_SysType IN NVARCHAR2 DEFAULT NULL ,
iv_Cnt IN NUMBER DEFAULT NULL
AS
v_SysType NVARCHAR2(50) := iv_SysType;
v_Cnt NUMBER(10,0) := iv_Cnt;
v_result NUMBER(10,0);
BEGIN
--SQL Server BEGIN TRANSACTION;
utils.incrementTrancount;
v_Systype := UPPER(v_Systype) ;
IF v_Cnt < 1 THEN
v_Cnt := 1 ;
END IF;
v_result :=sp_getapplock(v_Resource => v_Systype,
v_LockMode => 'Exclusive') ;
IF v_result >= 0 THEN
BEGIN
SELECT ID
INTO v_ID
FROM PWSYSID
WHERE SysType = v_SysType;
IF SQL%ROWCOUNT = 1 THEN
UPDATE PwSysID
SET ID = ID + v_cnt
WHERE SysType = v_SysType;
ELSE
BEGIN
INSERT INTO PwSysID
( ID, SysType )
VALUES ( v_cnt + 1, v_SysType );
v_ID := 1 ;
END;
END IF;
v_result :=sp_releaseapplock(v_Resource => v_Systype) ;
END;
ELSE
BEGIN
raise_application_error( -20002, 'Lock failed to acquire to generate Cityworks Id.' );
END;
END IF;
utils.commit_transaction;
END; -
Issue with Oracle.sql.NUMBER in Java Stored Procedure
When we try to make a call to the Oracle.sql.NUMBER(String) inside a java stored procedure and pass values from '01' to '09', it throws java.lang.StringIndexOutOfBoundsException: String index out of range: 3
We use Oracle 9.2.0.6 - JServer Release 9.2.0.6.0.
It works fine for other values. Please find below the code used for simulating the issue outside the application. Thanks.
create or replace and compile java source named testNumber as
import oracle.sql.NUMBER;
import java.sql.SQLException;
public class TestNumber
public static String convertNumber(String parm) {
NUMBER nTest;
try {
nTest = new NUMBER(parm);
return "TRUE";
}catch (SQLException sqle) {
return "FALSE";
create or replace function test_number (p_str in varchar2) return varchar2 as
language Java name 'TestNumber.convertNumber(java.lang.String) return
java.lang.String';
select test_number('05') from dual; - Throws exception ORA-29532: Java call terminated by uncaught Java exception: java.lang.StringIndexOutOfBoundsException: String index out of range: 3
select test_number('5') from dual; - Works fine
select test_number('010') from dual; - Works fineSiva,
I'm only guessing, but it could be an Oracle bug, in which case I suggest checking with Oracle Support.
(You do have a support contract, don't you? ;-)
Did you try compiling and running your java class "TestNumber" outside the database?
Class "oracle.sql.NUMBER" should be in Oracle's JDBC driver, I believe.
Good Luck,
Avi. -
DateTime parameter issue with Stored Procedure CR XI
Hello everyone.
This error was touched on here previously but no answer provided.
I am using Crystal Reports XI with SAP's BUSINESS ONE product. I have a report using a SQL Stored Procedure (SQL 2005). It has datetime parameters.
The Stored Procedure (SP) works fine when executed from within the Management studio. I then created my report, connecting to the SP with an ODBC driver and all was great.
But the add on being used for the report to be included in B1 requires OLE connectivity. No problem, all my reports (none of the others have SP's though), work fine with OLE.
So I tried redirecting the report to use the OLE driver. But I get an error.
I tried creating a new report with the SP using the OLE driver. Same message.
I get the following:
Query Engine Error: 'ADO Error Code: 0x80040e14
Source: Microsoft SQL Native Client
Description: Incorrect syntax near the keyword 'CONVERT'.
SQL State: 42000
Native Error: 156'
My code does not include the word CONVERT anywhere.
From what I can find on the web, this is supposedly an issue with the datetime parameter. But despite a few people posting messages about this, I have yet to find the answer. None of the topics have had a reply that provides the fix.
It seems to be something specific to OLE, since it works fine in ODBC. I am using SQL NATIVE CLIENT.
Thanks in advance for any help.
MarkHi Alex. Thanks.
One of my colleagues actually suggested a similar thing. He pointed out I should be using the MICROSOFT OLE DB PROVIDER FOR SQL SERVER (I had been doing so but somewhere along the line started using the Native driver).
And yes, that worked like a charm.
Thanks for your help.
Mark -
Customize the stored procedure migrating of MWB
Hi, All,
Is there anybody know how much customize we can have for using
the MWB when migrate stored procedure? For sample I have a SQL
Server 6.5 strored procedure like following:
/******************* SQL Server 6.5 sp *************/
CREATE PROCEDURE sp_SelectUsers
AS
select
tbl_Sp_users.ID, UserName, Password, ExpiresOn,
PwdChangedDate, tbl_Sp_UserGrps.name
from
tbl_Sp_users, tbl_Sp_UserGrps
where
GroupID = tbl_Sp_UserGrps.id
order by username
/******************* end ***************************/
After I migrate it to Oracle 8 with MWB, I got following object,
one Pkg and one Procedure in Oracle db, like following:
/****************** Oracle Pkg **********************/
CREATE OR REPLACE PROCEDURE sp_SelectUsers(
RC1 IN OUT sp_SelectUsersPkg.RCT1)
AS
StoO_selcnt INTEGER;
StoO_error INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
StoO_sqlstatus INTEGER;
BEGIN
OPEN RC1 FOR
SELECT tbl_Sp_users.ID, UserName, Password,
ExpiresOn, PwdChangedDate, tbl_Sp_UserGrps.name FROM
tbl_Sp_users, tbl_Sp_UserGrps
WHERE GroupID = tbl_Sp_UserGrps.id
ORDER BY username ;
END sp_SelectUsers;
/******************* Oracle Procedure ****************/
PROCEDURE sp_SelectUsers(
RC1 IN OUT sp_SelectUsersPkg.RCT1)
AS
StoO_selcnt INTEGER;
StoO_error INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
StoO_sqlstatus INTEGER;
BEGIN
OPEN RC1 FOR
SELECT tbl_Sp_users.ID, UserName, Password,
ExpiresOn, PwdChangedDate, tbl_Sp_UserGrps.name FROM
tbl_Sp_users, tbl_Sp_UserGrps
WHERE GroupID = tbl_Sp_UserGrps.id
ORDER BY username ;
END sp_SelectUsers;
/******************* end *****************************/
As our client use RDO as access method, there is no way we can
use this migrated SP in RDO and return resultset. We need
convert this SP to following to be able to use RDO to get
resultset back in client:
/******************* need convert to *********************/
create or replace package sp_selectUsersPkg
as
cursor c1
is select tbl_Sp_users.ID, UserName, Password,ExpiresOn,
PwdChangedDate, tbl_Sp_UserGrps.name
from tbl_Sp_users, tbl_Sp_UserGrps
where GroupID = tbl_Sp_UserGrps.id
order by username;
type UsersCur
is ref cursor return c1%ROWTYPE;
procedure sp_selectUsers(UserCursor in out UsersCur );
END;
create or replace package body sp_selectUsersPkg
as
procedure sp_selectUsers(UserCursor in out UsersCur )
is
begin
open UserCursor for
select tbl_Sp_users.ID, UserName,
password, ExpiresOn,
PwdChangedDate, tbl_Sp_UserGrps.name
from tbl_Sp_users, tbl_Sp_UserGrps
where GroupID = tbl_Sp_UserGrps.id
order by username;
end;
end;
/******************* end *********************************/
Is there any idea how we can do this? I hope we don't need do
this manually.
Thank you very much for any help!
Jing
nullI have done a rough example of using VB6, RDO and ODBC
drivers, which may be of help to some workbench users:
Calling Oracle 8.1.5 stored procedures with ref cursors using RDO
and Visual
Basic.
Ver 0.1 [email protected]
Summary
Versions Used
Table
Code
With Explicit Ref Cursor Argument
Without Explicit Ref Cursor Argument
Actions
Summary
This gives a comparison of the connectivity between Visual Basic
and Oracle,
with both the intersolve and oracle drivers. The Oracle odbc
still has
significant
shortcomings in comparison to the intersolve/Merant driver.
Versions Used
Visiual Basic 6.0, Oracle odbc driver 8.1.5.3.0, Oracle Database
8.1.5.0.0 on
NT, intersolve/Merant 3.5 32 bit Oracle driver.
Table
html table replaced by rough results in ascii form
test case with named result set cursor variable:
sSQL = "{CALL reftest.GetEmpData(?)}"
oracle 8.1.5.3
could not find item indicated by text, known vb6.0 bug?, thinks
reftest is user
intersolve
could not find item indicated by text, known vb6.0 bug?, thinks
reftest is user
sSQL = "begin reftest.GetEmpData(?); end;"
oracle 8.1.5.3
run time error 40002 driver not capable
intersolve
ok
sSQL = "{CALL GetEmpData(?)}"
oracle 8.1.5.3
run time error 40002 driver not capable
intersolve
could not find item indicated by text,?(similar to bug above?)
at qd.rdoParameters(0).Type = rdTypeVARCHAR
sSQL = "begin GetEmpData(?); end;"
oracle 8.1.5.3
run time error 40002 driver not capable
intersolve
ok
procedure with result set last argument wanting to be simulated
as not
argument result set
strsql = "{CALL BYROYALTYPkg.byroyalty()}"
oracle 8.1.5.3
ok
intersolve
ok
strsql = "begin BYROYALTYPkg.byroyalty(); end;"
oracle 8.1.5.3
wrong number of arguments in byroyalty
intersolve
ok
strsql = "{CALL byroyalty() }"
oracle 8.1.5.3
wrong number of arguments
intersolve
ok
strsql = "begin byroyalty(); end;"
oracle 8.1.5.3
wrong number of arguments
intersolve
ok
Code
With Explicit Ref Cursor Argument
Oracle Stored Procedures and Packages
(on scott/tiger account)
create or replace package reftest as
cursor c1 is select ename from emp;
type empCur is ref cursor return c1%ROWTYPE;
procedure GetEmpData(EmpCursor in out empCur );
END;
create or replace package body reftest as
procedure GetEmpData(EmpCursor in out empCur) is
begin
open EmpCursor for select ename from emp;
end;
end;
create or replace procedure GetEmpData(EmpCursor in out
reftest.empCur)
is
begin
open EmpCursor for select ename from emp;
end;
VB code
Private Sub Command1_Click()
Dim cn As New rdoConnection
Dim qd As rdoQuery
Dim rs As rdoResultset
Dim cl As rdoColumn
Static Number As Integer
Number = 0
cn.Connect = "uid=scott; pwd=tiger; DSN=Oracle;"
'enable the MS Cursor library
cn.CursorDriver = rdUseOdbc
'Make the connection
cn.EstablishConnection rdDriverPrompt
sSQL = "BEGIN GetEmpData(?); END;"
Set qd = cn.CreateQuery("", sSQL)
qd.rdoParameters(0).Type = rdTypeVARCHAR
'Dynamic or Keyset is meaningless here
Set rs = qd.OpenResultset(rdOpenStatic)
'all the output is routed to the debug window
Debug.Print ".....Starting Result Sets....."
Do
Debug.Print
Debug.Print
Do Until rs.EOF
For Each cl In rs.rdoColumns
If IsNull(cl.Value) Then
Debug.Print " "; cl.Name; "NULL"; 'Error
trap for
null fields
Else
Debug.Print " "; cl.Name; " ";
cl.Value;
End If
Next
Debug.Print
rs.MoveNext
Loop
Loop While rs.MoreResults
cn.Close
End Sub
Without Explicit Ref Cursor Argument
Oracle Stored Procedures and Packages
(requires table:
SQL> desc MTG_VERSION
Name
Null?
Type
VERSION
NUMBER
create or replace PACKAGE BYROYALTYPkg AS
TYPE RT1 IS RECORD (
val MTG_VERSION.VERSION%TYPE
TYPE RCT1 IS REF CURSOR RETURN RT1;
PROCEDURE byroyalty(
RC1 IN OUT BYROYALTYPkg.RCT1);
END;
create or replace PACKAGE BODY BYROYALTYPkg AS
PROCEDURE byroyalty(
RC1 IN OUT BYROYALTYPkg.RCT1)
AS
StoO_selcnt INTEGER;
StoO_error INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
StoO_sqlstatus INTEGER;
BEGIN
OPEN RC1 FOR
SELECT VERSION FROM MTG_VERSION;
END byroyalty;
END;
create or replace PROCEDURE byroyalty(
RC1 IN OUT BYROYALTYPkg.RCT1)
AS
StoO_selcnt INTEGER;
StoO_error INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
StoO_sqlstatus INTEGER;
BEGIN
OPEN RC1 FOR
SELECT VERSION FROM MTG_VERSION;
END byroyalty;
VB code
Dim env1 As rdoEnvironment
Dim conn1 As rdoConnection
Dim strsql As String
Dim ps As rdoPreparedStatement
Dim rs As rdoResultset
Private Sub Command1_Click()
strsql = "begin byroyalty(); end;"
'in oracle odbc driver uses refcusor argument to
get result set
Set ps = conn1.CreatePreparedStatement("PsTest",
strsql)
Set rs = ps.OpenResultset(rdOpenStatic)
Text1 = rs!Version
rs.Close
End Sub
Private Sub Form_Load()
rdoEngine.rdoDefaultCursorDriver = rdUseOdbc
Set env1 = rdoEngine.rdoCreateEnvironment(" ", " ", " ")
strsql = "ODBC;DSN=tot4;UID=test;PWD=test;"
Set conn1 = env1.OpenConnection(" ", rdDriverPrompt, False,
strsql)
conn1.QueryTimeout = 3600
End Sub
Actions
Encourage odbc to allow result sets , via the odbc processed
extra
argument, outside of packages.
Document the current situation, and keep users informed of
developments.
Turloch
Oracle Migration Workbench Team
Turloch O'Tierney (guest) wrote:
: Jing,
: Note that there is an example in the FAQ where the intersolve
: driver was used so no change was required in the client code.
The
: intersolve driver optionally converts the extra argument into a
: result set. With the Oracle ODBC driver the argument needs to
be
: explicitly handled.
: Is there a problem with RDO and the 8.0.5 ODBC driver handling
: package references?
: Turloch
: Turloch O'Tierney
: Oracle,
: Migration and Technology Group.
: FAQ entry reproduced:
: How are result sets/dynasets returned to the calling program?
: The Oracle Migration Workbench parser adds an extra
argument
: of type REF CURSOR for result
: sets/dynasets. This type is understood and can be
: manipulated by both PL/SQL and Oracle JDBC. Oracle8
: release 8.0.5 ODBC drivers support REF CURSORs which means
: that the additional argument must be
: explicitly handled by the application, and the client
: application code must be changed. However, some
: third-party vendors such as Intersolv supply ODBC drivers
: for Oracle that support REF CURSORs and can, in
: addition, implicitly make use of REF CURSORs for using
: result sets/dynasets. Therefore, no change is
: required in the client application code. This is
illustrated
: in the following examples of an MS SQL Server
: stored procedure and its equivalent Oracle package and
: stored procedure as generated by the Oracle
: Migration Workbench parser.
: MS SQL Server Stored Procedure
: CREATE PROCEDURE byroyalty
: AS
: select au_id from titleauthor
: GO
: Oracle8i Package and Stored Procedure
: PACKAGE BYROYALTYPkg AS
: TYPE RT1 IS RECORD (
: au_id titleauthor.au_id%TYPE
: TYPE RCT1 IS REF CURSOR RETURN RT1;
: END;
: PROCEDURE byroyalty(
: RC1 IN OUT byroyaltyPkg.RCT1)
: AS
: StoO_selcnt INTEGER;
: StoO_error INTEGER;
: StoO_rowcnt INTEGER;
: StoO_errmsg VARCHAR2(255);
: StoO_sqlstatus INTEGER;
: BEGIN
: OPEN RC1 FOR
: SELECT au_id FROM titleauthor;
: END byroyalty;
: The following example illustrates the typical ODBC code
used
: by Intersolv to call the above MS SQL Server
: stored procedure. This code also works for the above
: Oracle8i package and stored procedure. Note that error
: handling must be added in a real application:
: SQLPrepare(...,'{call byroyalty()}',...)
: SQLExecute()
: SQLBindCol()
: SQLFetch()
: Comments:
: SQLPrepare(...,'{call byroyalty()}',...) is the ODBC SQL
: syntax used to execute stored procedures.
: SQLExecute()executes the stored procedure.
: SQLBindCol()assigns storage for result column 1 in the
: result set (au_id).
: SQLFetch() fetches the first record from the result set
: generated by the stored procedure.
: The following examples illustrate how to call the above MS
: SQL Server stored procedure with result
: sets/dynasets in Visual Basic using DAO and RDO on top of
: ODBC. This code works for Oracle8i packages
: and stored procedures if you use an Intersolv ODBC driver
to
: understand Oracle REF CURSORs.
: DAO
: Private Sub Command2_Click()
: Dim sSql As String
: sSql = "{call byroyalty()}"
: 'In Oracle ODBC driver use refcusor argument to get
: result set
: Set rCustomers = dbsServer.OpenRecordset(sSql,
: dbOpenDynamic)
: Text4 = rCustomers.Fields(0)
: theend:
: End Sub
: Please note, this example assumes that a DAO connection
has
: been set up already.
: RDO
: Private Sub Command1_Click()
: StrSql = "{call byroyalty}"
: 'in oracle odbc driver uses refcusor argument to get
: result set
: Set Ps = connx1.CreatePreparedStatement("PsTest",
: StrSql)
: Set Rs = Ps.OpenResultSet(rdOpenStatic)
: Text3 = Rs!au_id
: Rs.Close
: End Sub
: Please note, this example assumes that an RDO connection
has
: been set up already.
: Jing Zhang (guest) wrote:
: : Hi, All,
: : Is there anybody know how much customize we can have for
using
: : the MWB when migrate stored procedure? For sample I have a
SQL
: : Server 6.5 strored procedure like following:
: : /******************* SQL Server 6.5 sp *************/
: : CREATE PROCEDURE sp_SelectUsers
: : AS
: : select
: : tbl_Sp_users.ID, UserName, Password, ExpiresOn,
: : PwdChangedDate, tbl_Sp_UserGrps.name
: : from
: : tbl_Sp_users, tbl_Sp_UserGrps
: : where
: : GroupID = tbl_Sp_UserGrps.id
: : order by username
: : /******************* end ***************************/
: : After I migrate it to Oracle 8 with MWB, I got following
: object,
: : one Pkg and one Procedure in Oracle db, like following:
: : /****************** Oracle Pkg **********************/
: : CREATE OR REPLACE PROCEDURE sp_SelectUsers(
: : RC1 IN OUT sp_SelectUsersPkg.RCT1)
: : AS
: : StoO_selcnt INTEGER;
: : StoO_error INTEGER;
: : StoO_rowcnt INTEGER;
: : StoO_errmsg VARCHAR2(255);
: : StoO_sqlstatus INTEGER;
: : BEGIN
: : OPEN RC1 FOR
: : SELECT tbl_Sp_users.ID, UserName, Password,
: : ExpiresOn, PwdChangedDate, tbl_Sp_UserGrps.name FROM
: : tbl_Sp_users, tbl_Sp_UserGrps
: : WHERE GroupID = tbl_Sp_UserGrps.id
: : ORDER BY username ;
: : END sp_SelectUsers;
: : /******************* Oracle Procedure ****************/
: : PROCEDURE sp_SelectUsers(
: : RC1 IN OUT sp_SelectUsersPkg.RCT1)
: : AS
: : StoO_selcnt INTEGER;
: : StoO_error INTEGER;
: : StoO_rowcnt INTEGER;
: : StoO_errmsg VARCHAR2(255);
: : StoO_sqlstatus INTEGER;
: : BEGIN
: : OPEN RC1 FOR
: : SELECT tbl_Sp_users.ID, UserName, Password,
: : ExpiresOn, PwdChangedDate, tbl_Sp_UserGrps.name FROM
: : tbl_Sp_users, tbl_Sp_UserGrps
: : WHERE GroupID = tbl_Sp_UserGrps.id
: : ORDER BY username ;
: : END sp_SelectUsers;
: : /******************* end *****************************/
: : As our client use RDO as access method, there is no way we
can
: : use this migrated SP in RDO and return resultset. We need
: : convert this SP to following to be able to use RDO to get
: : resultset back in client:
: : /******************* need convert to *********************/
: : create or replace package sp_selectUsersPkg
: : as
: : cursor c1
: : is select tbl_Sp_users.ID, UserName, Password,ExpiresOn,
: : PwdChangedDate, tbl_Sp_UserGrps.name
: : from tbl_Sp_users, tbl_Sp_UserGrps
: : where GroupID = tbl_Sp_UserGrps.id
: : order by username;
: : type UsersCur
: : is ref cursor return c1%ROWTYPE;
: : procedure sp_selectUsers(UserCursor in out UsersCur );
: : END;
: : create or replace package body sp_selectUsersPkg
: : as
: : procedure sp_selectUsers(UserCursor in out UsersCur )
: : is
: : begin
: : open UserCursor for
: : select tbl_Sp_users.ID, UserName,
: : password, ExpiresOn,
: : PwdChangedDate, tbl_Sp_UserGrps.name
: : from tbl_Sp_users, tbl_Sp_UserGrps
: : where GroupID = tbl_Sp_UserGrps.id
: : order by username;
: : end;
: : end;
: : /******************* end *********************************/
: : Is there any idea how we can do this? I hope we don't need do
: : this manually.
: : Thank you very much for any help!
: : Jing
Oracle Technology Network
http://technet.oracle.com
null
Maybe you are looking for
-
Hi All, I have an urgent query here regarding the Bakcground job. Let's say I need to schedule a background job on hourly basis to fetch the data. If first job runs more than 60 minutes, then will the second job will fetch the data. What will happen
-
Delivery Date with Zero Order Quantity in Sales Order
Dear All, I have created a sales order in va01 with different delivery date in schedule lines. I want to save delivery date with zero order quantity because he has not delivery on time.
-
Part 1 entries for RG23A not printed in registers
Dear Gurus, After capturing the excise invoice without refernce to the purchase order form transfer from stotage location to storage location excise Invoice we posted. RG23A PART1 and RG23A PART2 Resisters are extracted using J2I5 and Printed using Z
-
External hard drive solution....
I have a macbook pro with a 500gb 7200 rpm internal hard drive. I want to get an external hard drive. I want it mostly for editing videos with Final Cut Pro. Some of my ideas are to get a express card 34 with 2 firewire 800 ports and get an external
-
How can i change favourites in finder
i am not able to remove one video from favourite in finder