Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raimonizard/de8e4b2bd70dcb6a24200ed041465836 to your computer and use it in GitHub Desktop.
Save raimonizard/de8e4b2bd70dcb6a24200ed041465836 to your computer and use it in GitHub Desktop.
Formalització de TYPE + TYPE BODY + Main d'un objecte PLSQL de BDOR

Formalització de la creació d’un TYPE:

CREATE OR REPLACE TYPE <nom_classe> AS OBJECT(
    <atribut_1> <tipus_de_dades>,
    <atribut_2> <tipus_de_dades>,
    <atribut_N> <tipus_de_dades>,
    CONSTRUCTOR FUNCTION <nom_classe> (<paràmetre_1> <tipus_de_dades>, <paràmetre_N> <tipus_de_dades>) RETURN SELF AS RESULT,
    [MEMBER | STATIC] [FUNCTION | PROCEDURE] <nom_mètode>[(<paràmetre_1> <tipus_de_dades>, <paràmetre_N> <tipus_de_dades>)] [RETURN <tipus_de_dades>])
    [MAP | ORDER] MEMBER FUCTION <nom_mètode> RETURN <tipus_de_dades>

);

Formalització de la creació del TYPE BODY:

CREATE OR REPLACE TYPE BODY <nom_classe> AS
    CONSTRUCTOR FUNCTION <nom_classe> (<paràmetre_1> <tipus_de_dades>, <paràmetre_N> <tipus_de_dades>) RETURN SELF AS RESULT IS
        BEGIN
            <inicialització d'atributs de l'objecte>
               RETURN ;
        END;
    [MEMBER | STATIC] [FUNCTION | PROCEDURE] <nom_mètode> [RETURN <tipus_de_dades>] IS
        BEGIN
            <programació>
             [RETURN <valor>;]
        END;
    [MAP | ORDER] MEMBER FUNCTION <nom_mètode> RETURN <tipus_de_dades> IS
        BEGIN
            <programació>
             RETURN <valor>;
        END;
END;

Formalització d’un bloc PL/SQL:

DECLARE
    <nom_objecte_1> <tipus_classe>;
    <nom_objecte_2> <tipus_classe>;
BEGIN
    <nom_objecte_1> := NEW <tipus_classe>[(<valor_1>, <valor_N>)];
    <nom_objecte_2> := NEW <tipus_classe>[(<valor_1>, <valor_N>)];
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment