Encountered error while running PL/SQL block from c#.NET

Hi,

I am writing the following PL/SQL block in .NET.
DECLARE
    BEGIN
    INSERT INTO na_acct_add
    (acct_request_id, processing_code_1022_cd,
    stk_cmsn_sch_191_cd,bond_cmsn_sch_192_cd,
    optn_cmsn_sch_193_cd
    )
    VALUES (@AcctRequestId, 'A',
    '1', '1',
    '1'
    );
    EXCEPTION WHEN OTHERS THEN
    NULL;
    END;

I am getting the following error while executing:
System.Data.OracleClient.OracleException: ORA-06550: line 1, column 305:
PLS-00103: Encountered the symbol "ROLLBACK" when expecting one of the following:

  * & - + / at mod remainder rem then <an exponent (**)> and or
  ||
The symbol "then" was substituted for "ROLLBACK" to continue.
ORA-06550: line 1, column 345:
PLS-00103: Encountered the symbol ";" when expecting one of the following:

can anyone help on this ???
ramitharahulAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
as there is no ROLLBACK in the code you showed, it must be somewhere else.
also, why do you put a DECLARE, when you have no pl/sql variables?


now, is there maybe a trigger on that table (na_acct_add)?
0
ramitharahulAuthor Commented:
Hi angellll,

The below is more refined code & Iam still getting the same error:

DECLARE
  proc_error              INTEGER;
  proc_errmsg             VARCHAR2(255);
BEGIN
  INSERT INTO na_acct_add(acct_request_id,
                          processing_code_1022_cd,
                          stk_cmsn_sch_191_cd,
                          bond_cmsn_sch_192_cd,
                          optn_cmsn_sch_193_cd
                         )
    VALUES (195655,
            'A',
            '1',
            '1',
            '1'
           );
  COMMIT;
EXCEPTION
  WHEN OTHERS THEN
    proc_error := SQLCODE;
    proc_errmsg := SQLERRM;
    IF (proc_errmsg = 'ORA-00001: unique constraint (DEV1NA1.NA_ACCT_ADD_PK) violated') THEN
      ROLLBACK;
    ELSE
      Na_P_Error(proc_error,
                 'na_p_delete_acct',
                 proc_errmsg ,
                 'delete '
                );
      RAISE;
    END IF;
END;
0
ramitharahulAuthor Commented:
Hi Angellll

195655 record already exists & the acct_request_id is a primary key on that table. I am just testing if by mistake the user enters the existing account id. It should throw the error message, but it was never happening.

Thanks
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Jinesh KamdarCommented:
Try this correction in ur code.
...
EXCEPTION 
  WHEN OTHERS THEN
    proc_error := SQLCODE;
    proc_errmsg := SQLERRM;
    IF (proc_errmsg = 'ORA-00001: unique constraint (DEV1NA1.NA_ACCT_ADD_PK) violated') THEN
      ROLLBACK;
    ELSE
      Na_P_Error(proc_error,
                 'na_p_delete_acct',
                 proc_errmsg ,
                 'delete '
                );
    END IF;
    RAISE;
END;

Open in new window

0
SujithData ArchitectCommented:
Assuming that above shown is the full code that you are trying to execute;
You dont need a ROLLBACK in the exception handler, as the record itself didnt get inserted because of the constraint violation.
Is it necessary to RAISE the exception again?

Your code can be re-written as below:
BEGIN
  INSERT INTO na_acct_add(acct_request_id, 
                          processing_code_1022_cd,
                          stk_cmsn_sch_191_cd,
                          bond_cmsn_sch_192_cd,
                          optn_cmsn_sch_193_cd
                         )
    VALUES (195655,
            'A',
            '1', 
            '1',
            '1'
           );
  COMMIT;
EXCEPTION 
  WHEN OTHERS THEN
   IF sqlcode <> -1 then
      Na_P_Error( sqlcode ,
                 'na_p_delete_acct',
                 sqlerrm ,
                 'delete '
                );
      RAISE;
    END IF;
END;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ramitharahulAuthor Commented:
make sense to me. good guidance...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.