Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Issue while migrating from SQL server to Oracle database

Posted on 2003-11-10
5
Medium Priority
?
690 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
3 Comments
 
LVL 12

Expert Comment

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

Accepted Solution

by:
catchmeifuwant earned 100 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 100 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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

782 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