Oracle: Error management and exception handling in PL/SQL

Raise Error in Oracle

RAISE VALUE_ERROR;

Raise Application Error in Oracle

Create custom exception and raise it.

Handle Exception

You could also insert into error log table and RAISE

Reference:
https://blogs.oracle.com/connect/post/error-management



UML Collaboration Diagram

"Collaboration diagrams (known as Communication Diagram in UML 2.x) are used to show how objects interact to perform the behavior of a particular use case, or a part of a use case. Along with sequence diagrams, collaboration are used by designers to define and clarify the roles of the objects that perform a particular flow of events of a use case. They are the primary source of information used to determining class responsibilities and interfaces."

Ref: Check Below

https://www.visual-paradigm.com/servlet/editor-content/guide/uml-unified-modeling-language/what-is-uml-collaboration-diagram/sites/7/2018/12/collaboration-diagram-example.png

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-uml-collaboration-diagram/

Software Engineering: Propositional Logic

Ref: Software Engineering Course: https://www.cs.ox.ac.uk/people/michael.wooldridge/teaching/soft-eng/
https://www.cs.ox.ac.uk/people/michael.wooldridge/teaching/soft-eng/lect07-4up.pdf

Oracle PL/SQL: If-Then-Else, For Loop, While Loop

How it works: if, elsif, else (then) (Click on the images to see them clearly)

Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/13_elems024.htm

Example:

Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/13_elems024.htm

Oracle: CASE, WHEN, THEN

Simple:

Searched:

Else:

Reverse For Loop

Ref: For Loop Examples in Oracle

https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/controlstatements.htm#BABEFFDC

Oracle While Loop

While loop example from the referenced url

DECLARE
done BOOLEAN := FALSE;
BEGIN
WHILE done LOOP
DBMS_OUTPUT.PUT_LINE (‘This line does not print.’);
done := TRUE; — This assignment is not made.
END LOOP;

WHILE NOT done LOOP
DBMS_OUTPUT.PUT_LINE (‘Hello, world!’);
done := TRUE;
END LOOP;
END;
/

Ref: https://docs.oracle.com/en/database/oracle/oracle-database/19/lnpls/plsql-control-statements.html#GUID-3F69F563-BCAE-4D3E-8E03-F53C8D64D093

Oracle Sub Types for Data Types: Exception Block

An unconstrained subtype has the same set of values as its base type, so it is only another name for the base type.

Syntax:

SUBTYPE subtype_name IS base_type
Example:
 
SUBTYPE "DOUBLE PRECISION" IS FLOAT
SUBTYPE Balance IS NUMBER;

Constrained SubType
 
SUBTYPE Balance IS NUMBER(8,2);

Oracle Exception Block Example:



Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/07_errs.htm


						
						
						
		

Misc. Oracle: Data Types: Why a Data Type.

Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/02_funds.htm

https://stackoverflow.com/questions/7425153/reason-why-oracle-is-case-sensitive

Oracle Data Types and Allowed Sizes:

https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/datatypes.htm#LNPLS99943

Oracle SIMPLE_FLOAT vs SIMPLE_DOUBLE

Ref: https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/datatypes.htm#CJAEAEJG

PLS_Integer vs Number

"The PLS_INTEGER data type has these advantages over the NUMBER data type and NUMBER subtypes:

  • PLS_INTEGER values require less storage.
  • PLS_INTEGER operations use hardware arithmetic, so they are faster than NUMBER operations,

"

Ref: https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/datatypes.htm#LNPLS319

Hardly anything is by me. All are from external sources. Credit belongs to them.

Oracle Data types, ROWID, PLS_INTEGER vs INTEGER

Data Types

Ref: https://docs.oracle.com/cd/A97630_01/server.920/a96524/c13datyp.htm

(Click on the image to see it properly)

Why PLS_Integer:

https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/03_types.htm

“You use the PLS_INTEGER datatype to store signed integers. Its magnitude range is -231 .. 231. PLS_INTEGER values require less storage than NUMBER values. Also, PLS_INTEGER operations use machine arithmetic, so they are faster than NUMBER and BINARY_INTEGER operations, which use library arithmetic. For efficiency, use PLS_INTEGER for all calculations that fall within its magnitude range.”

ROWID vs ROWNUM

ROWID is useful when you need to refer to a specific row in a table without using a primary key or unique constraint. Hence, ROWNUM is a pseudocolumn that assigns a unique row number to each row in a result set, while ROWID is a physical address that identifies a specific row in a table

https://www.c-sharpcorner.com/interview-question/what-is-the-difference-between-rownum-and-rowed

Simple Integer vs PLS_integer

https://docs.oracle.com/en/database/oracle/oracle-database/19/lnpls/plsql-data-types.html

“SIMPLE_INTEGER has the same range as PLS_INTEGER and has a NOT NULL constraint. It differs significantly from PLS_INTEGER in its overflow semantics. If you know that a variable will never have the value NULL or need overflow checking, declare it as SIMPLE_INTEGER rather than PLS_INTEGER .”

Algorithm Complexity: Notations and Comparisons

Algorithm Complexity Notations and Comparisons:

Ref: https://www.freecodecamp.org/news/big-o-notation-why-it-matters-and-why-it-doesnt-1674cfa8a23c/

Algorithm Complexity: A simple example

The complexity here is: 3n+2 i.e. O(n)

Ref: https://www2.cs.sfu.ca/CourseCentral/125/johnwill/Packet06.pdf

Java spring application demo

https://youtu.be/euJzoAbaXjc