Solved

Issue while migrating from SQL server to Oracle database

Posted on 2003-11-10
5
681 Views
Last Modified: 2007-12-19
I have migrated SQL server database to Oracle database using Oracle Migration Workbench.
There is an sp in SQL server with the statement "Set nocount off"
The sp in Oracle after migration in oracle has the following code
(
PKID       IN NUMBER  DEFAULT NULL)
AS
PKID_       NUMBER(10,0) := PKID;
StoO_selcnt      INTEGER;
StoO_error       INTEGER;
StoO_rowcnt      INTEGER;
StoO_crowcnt      INTEGER := 0;
StoO_fetchstatus      INTEGER := 0;
StoO_errmsg      VARCHAR2(255);
StoO_sqlstatus      INTEGER;
BEGIN
NULL;

      /*[SPCONV-ERR(5)]:(set nocount) Manual conversion required*/

      BEGIN
            BEGIN
            StoO_error   := 0;
            StoO_rowcnt  := 0;
            DELETE FROM sa.ClientCustomFieldvalues
                  WHERE InstanceSpecificId = SP_ADMIN_DELETE_CLIENT.PKID_;
            StoO_rowcnt := SQL%ROWCOUNT;
            EXCEPTION
                  WHEN NO_DATA_FOUND THEN
                        NULL;
                  WHEN OTHERS THEN
                        StoO_error := SQLCODE;
                        StoO_errmsg := SQLERRM;
                        raise_application_error(SQLCODE, SQLERRM,true);
            END;
            BEGIN
            StoO_error   := 0;
            StoO_rowcnt  := 0;
            DELETE FROM sa.CLIENTCONTACTCUSTOMFIELDSVALUE
                  WHERE InstanceSpecificId  IN (
            SELECT  pkid
                   FROM sa.ClientTeammembers
                  WHERE clientid = SP_ADMIN_DELETE_CLIENT.pkid_              );
            StoO_rowcnt := SQL%ROWCOUNT;
            EXCEPTION
                  WHEN NO_DATA_FOUND THEN
                        NULL;
                  WHEN OTHERS THEN
                        StoO_error := SQLCODE;
                        StoO_errmsg := SQLERRM;
                        raise_application_error(SQLCODE, SQLERRM,true);
            END;
/*Delete from CompanyCustomFieldsLookUp where InstanceSpecificId = @PKID

Delete from CompanyEmployeeContactCustomFieldsLookUp where InstanceSpecificId in (select pkid from CompanyEmployees where companyId = @pkid)*/

            BEGIN
            StoO_error   := 0;
            StoO_rowcnt  := 0;
            DELETE FROM sa.ClientContacts
                  WHERE ClientId = SP_ADMIN_DELETE_CLIENT.PKID_;
            StoO_rowcnt := SQL%ROWCOUNT;
            EXCEPTION
                  WHEN NO_DATA_FOUND THEN
                        NULL;
                  WHEN OTHERS THEN
                        StoO_error := SQLCODE;
                        StoO_errmsg := SQLERRM;
                        raise_application_error(SQLCODE, SQLERRM,true);
            END;
            BEGIN
            StoO_error   := 0;
            StoO_rowcnt  := 0;
            DELETE FROM sa.ClientTeammembers
                  WHERE ClientId = SP_ADMIN_DELETE_CLIENT.PKID_;
            StoO_rowcnt := SQL%ROWCOUNT;
            EXCEPTION
                  WHEN NO_DATA_FOUND THEN
                        NULL;
                  WHEN OTHERS THEN
                        StoO_error := SQLCODE;
                        StoO_errmsg := SQLERRM;
                        raise_application_error(SQLCODE, SQLERRM,true);
            END;
            BEGIN
            StoO_error   := 0;
            StoO_rowcnt  := 0;
            DELETE FROM sa.ClientLocations
                  WHERE ClientId = SP_ADMIN_DELETE_CLIENT.PKID_;
            StoO_rowcnt := SQL%ROWCOUNT;
            EXCEPTION
                  WHEN NO_DATA_FOUND THEN
                        NULL;
                  WHEN OTHERS THEN
                        StoO_error := SQLCODE;
                        StoO_errmsg := SQLERRM;
                        raise_application_error(SQLCODE, SQLERRM,true);
            END;
            BEGIN
            StoO_error   := 0;
            StoO_rowcnt  := 0;
            DELETE FROM sa.Clients
                  WHERE
                  (PKID = SP_ADMIN_DELETE_CLIENT.PKID_);
            StoO_rowcnt := SQL%ROWCOUNT;
            EXCEPTION
                  WHEN NO_DATA_FOUND THEN
                        NULL;
                  WHEN OTHERS THEN
                        StoO_error := SQLCODE;
                        StoO_errmsg := SQLERRM;
                        raise_application_error(SQLCODE, SQLERRM,true);
            END;
      END;
END SP_ADMIN_DELETE_CLIENT;
Is there any manual conversion required for this SP to get corrected, though its compiling successfully and also deleting the records the same way deletion is taking place in SQL server SP
0
Comment
Question by:mona_saxena27
  • 2
5 Comments
 
LVL 12

Expert Comment

by:catchmeifuwant
ID: 9720630
whats the significance of set nocount off?
0
 
LVL 12

Accepted Solution

by:
catchmeifuwant earned 25 total points
ID: 9720642
Well on googling,I found the following link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_set-set_3ed0.asp

This is just displaying the numbers of rows affected.

Oracle,does not display these results in a SP.However if you want to know how many rows were affected for every delete in the sp...you can do...After this statement in your SP ->

StoO_rowcnt := SQL%ROWCOUNT;
dbms_output.put_line('Rows Deleted:'||StoO_rowcnt);

To turn on this Server output option,in your session you need to execute the command :

set serveroutput on


HTH

0
 
LVL 15

Assisted Solution

by:andrewst
andrewst earned 25 total points
ID: 9721886
That Migration Workbench seems to create a lot of unnecessary code!  The procedure above can be simplified to this:

     BEGIN
          DELETE FROM sa.ClientCustomFieldvalues
               WHERE InstanceSpecificId = SP_ADMIN_DELETE_CLIENT.PKID_;
          StoO_rowcnt := SQL%ROWCOUNT;
          DELETE FROM sa.CLIENTCONTACTCUSTOMFIELDSVALUE
               WHERE InstanceSpecificId  IN (
          SELECT  pkid
                FROM sa.ClientTeammembers
               WHERE clientid = SP_ADMIN_DELETE_CLIENT.pkid_            );
          StoO_rowcnt := SQL%ROWCOUNT;
          DELETE FROM sa.ClientContacts
               WHERE ClientId = SP_ADMIN_DELETE_CLIENT.PKID_;
          StoO_rowcnt := SQL%ROWCOUNT;
          DELETE FROM sa.ClientTeammembers
               WHERE ClientId = SP_ADMIN_DELETE_CLIENT.PKID_;
          StoO_rowcnt := SQL%ROWCOUNT;
          DELETE FROM sa.ClientLocations
               WHERE ClientId = SP_ADMIN_DELETE_CLIENT.PKID_;
          StoO_rowcnt := SQL%ROWCOUNT;
          DELETE FROM sa.Clients
               WHERE
               (PKID = SP_ADMIN_DELETE_CLIENT.PKID_);
          StoO_rowcnt := SQL%ROWCOUNT;
     END;

Quite why it was handling the NO_DATA_FOUND exception for DELETE statements that will never raise it baffles me.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question