01 August 2015

PL/SQL Sample code and error handling mechanism

NoSQL Jobs, Apply today
SAMPLE PL/SQL:
CREATE TABLE dummy
( dummy_value       VARCHAR2(1));
DECLARE
  -- Define local variable.
  my_string VARCHAR2(1) := ' ';
  my_number NUMBER;
BEGIN
  -- Select a white space into a local variable.
  SELECT ' ' INTO my_string FROM dummy;
  -- Attempt to assign a single white space to a number.
  my_number := TO_NUMBER(my_string);
EXCEPTION
 WHEN no_data_found THEN
   dbms_output.put_line('SELECT-INTO'||CHR(10)||SQLERRM);
END;
/
Social Media + Mobile Technology for Health care
Output and Error:
The program returns the following output, which illustrates formatting user- defined exceptions. The CHR(10) inserts a line return and provides a clean break between the program's SQLCODE and SQLERRM messages:
RAISE my_error
SQLCODE [1]
SQLERRM [User-Defined Exception]

No comments:

Post a Comment

Thanks for your message. We will get back you.

© 2010-2017 Biganalytics.me. All rights reserved.. Powered by Blogger.

Total Pageviews

All material, files, logos and trademarks within this site are properties of their respective organizations.