.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 1999-2005 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.TT 1 $SQL$Project Distributed Database System$VAK264$
.tt 2 $$$
.TT 3 $ThomasA$AK_Function$1999-01-19$
***********************************************************
.nf

.nf

    ========== licence begin  GPL
    Copyright (c) 1999-2005 SAP AG

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
.fo


.fo
.nf
.sp
MODULE  : AK_Function
=========
.sp
Purpose :
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              a264drop_function (VAR acv : tak_all_command_glob;
                    VAR func_name : tsp00_KnlIdentifier);
 
        PROCEDURE
              a264function_semantic (VAR acv : tak_all_command_glob);
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              Scanner : VAK01;
 
        VAR
              a01defaultkey      : tgg00_SysInfoKey;
 
      ------------------------------ 
 
        FROM
              AK_semantic_scanner_tools : VAK05;
 
        PROCEDURE
              a05identifier_get (VAR acv : tak_all_command_glob;
                    tree_index  : integer;
                    obj_len     : integer;
                    VAR moveobj : tsp00_KnlIdentifier);
 
      ------------------------------ 
 
        FROM
              AK_universal_semantic_tools : VAK06;
 
        PROCEDURE
              a06inc_linkage (VAR linkage : tsp00_C2);
 
        PROCEDURE
              a06_systable_get (VAR acv : tak_all_command_glob;
                    dstate       : tak_directory_state;
                    VAR tableid  : tgg00_Surrogate;
                    VAR base_ptr : tak_sysbufferaddress;
                    get_all      : boolean;
                    VAR ok       : boolean);
 
      ------------------------------ 
 
        FROM
              AK_error_handling : VAK07;
 
        PROCEDURE
              a07_b_put_error (VAR acv : tak_all_command_glob;
                    b_err    : tgg00_BasisError;
                    err_code : tsp00_Int4);
 
        PROCEDURE
              a07_nb_put_error (VAR acv : tak_all_command_glob;
                    b_err    : tgg00_BasisError;
                    err_code : tsp00_Int4;
                    VAR nam  : tsp00_KnlIdentifier);
 
      ------------------------------ 
 
        FROM
              Systeminfo_cache :  VAK10;
 
        PROCEDURE
              a10del_sysinfo (VAR acv : tak_all_command_glob;
                    VAR syskey  : tgg00_SysInfoKey;
                    VAR b_err   : tgg00_BasisError);
 
        PROCEDURE
              a10get_sysinfo (VAR acv : tak_all_command_glob;
                    VAR syskey   : tgg00_SysInfoKey;
                    dstate       : tak_directory_state;
                    VAR syspoint : tak_sysbufferaddress;
                    VAR b_err    : tgg00_BasisError);
 
        PROCEDURE
              a10_cache_delete  (VAR acv : tak_all_command_glob;
                    is_rollback : boolean);
 
      ------------------------------ 
 
        FROM
              AK_Table : VAK11;
 
        PROCEDURE
              a11drop_table  (VAR acv : tak_all_command_glob;
                    VAR tableid   : tgg00_Surrogate;
                    tablkind      : tgg00_TableKind;
                    succ_filevers : boolean);
 
      ------------------------------ 
 
        FROM
              AK_Stored_Procedure_DDL : VAK261;
 
        PROCEDURE
              a261drop_procedure (VAR acv : tak_all_command_glob;
                    VAR procbuf : tak_sysbufferaddress;
                    VAR owner_id: tgg00_Surrogate);
 
      ------------------------------ 
 
        FROM
              AK_Connect : VAK51;
 
        PROCEDURE
              a51build_userkey (VAR user_name : tsp00_KnlIdentifier;
                    VAR userkey : tgg00_SysInfoKey);
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              a05identifier_get;
 
              tsp00_MoveObj tsp00_KnlIdentifier
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : ThomasA
.sp
.cp 3
Created : 1989-08-29
.sp
.cp 3
Version : 1999-01-19
.sp
.cp 3
Release :      Date : 1999-01-19
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
.sp 4
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
 
 
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
CONST
      c_is_rollback = true;
 
 
(*------------------------------*) 
 
PROCEDURE
      a264drop_function (VAR acv : tak_all_command_glob;
            VAR func_name : tsp00_KnlIdentifier);
 
VAR
      b_err       : tgg00_BasisError;
      ix          : integer;
      ref_buf     : tak_sysbufferaddress;
      sysk        : tgg00_SysInfoKey;
 
BEGIN
WITH acv DO
    BEGIN
    a51build_userkey (func_name, sysk);
    sysk.sentrytyp := cak_efuncref;
    a10get_sysinfo (acv, sysk, d_fix, ref_buf, b_err);
    IF  b_err = e_sysinfo_not_found
    THEN
        a07_nb_put_error (acv,
              e_unknown_functionname, 1, func_name);
    (*ENDIF*) 
    IF  b_err = e_ok
    THEN
        WITH ref_buf^.sfuncref DO
            BEGIN
            ix := 1;
            WHILE (ix <= fct_proc_cnt) AND
                  (a_returncode = 0) DO
                BEGIN
                ak264drop_dependand_views (acv,
                      fct_procids[ix].ofp_procid);
                ak264drop_dbproc (acv,
                      fct_procids[ix].ofp_procid);
                ix := ix + 1
                END;
            (*ENDWHILE*) 
            IF  a_returncode = 0
            THEN
                a10del_sysinfo (acv, sysk, b_err)
            (*ENDIF*) 
            END;
        (*ENDWITH*) 
    (*ENDIF*) 
    IF  b_err <> e_ok
    THEN
        a07_b_put_error (acv, b_err, 1)
    (*ENDIF*) 
    END;
(*ENDWITH*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      a264function_semantic (VAR acv : tak_all_command_glob);
 
BEGIN
a10_cache_delete (acv, NOT c_is_rollback);
CASE acv.a_ap_tree^[acv.a_ap_tree^[ 0 ].n_lo_level].n_subproc OF
    cak_i_drop :
        ak264drop_function (acv);
    END;
(*ENDCASE*) 
IF  acv.a_returncode <> 0
THEN
    acv.a_part_rollback := true
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak264drop_function (VAR acv : tak_all_command_glob);
 
VAR
      ti          : integer;
      func_name   : tsp00_KnlIdentifier;
 
BEGIN
ti := acv.a_ap_tree^[acv.a_ap_tree^[ 0 ].n_lo_level].n_lo_level;
a05identifier_get (acv, ti, sizeof (func_name), func_name);
a264drop_function (acv, func_name)
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak264drop_dependand_views (VAR acv : tak_all_command_glob;
            VAR procid : tgg00_Surrogate);
 
CONST
      c_all_base_recs = true;
      c_inc_version   = true;
 
VAR
      found       : boolean;
      b_err       : tgg00_BasisError;
      ix          : integer;
      usage_buf   : tak_sysbufferaddress;
      base_ptr    : tak_sysbufferaddress;
      sysk        : tgg00_SysInfoKey;
 
BEGIN
sysk           := a01defaultkey;
sysk.stableid  := procid;
sysk.sentrytyp := cak_eusage;
REPEAT
    a10get_sysinfo (acv, sysk, d_fix, usage_buf, b_err);
    IF  b_err = e_ok
    THEN
        WITH usage_buf^.susage DO
            BEGIN
            ix := 1;
            WHILE (ix <= usagecount) AND (acv.a_returncode = 0) DO
                BEGIN
                WITH usagedef[ix] DO
                    BEGIN
                    a06_systable_get (acv, d_release, usa_tableid,
                          base_ptr, NOT c_all_base_recs, found);
                    IF  found
                    THEN
                        a11drop_table (acv, usa_tableid,
                              usa_tablekind, c_inc_version);
                    (*ENDIF*) 
                    END;
                (*ENDWITH*) 
                ix := ix + 1
                END;
            (*ENDWHILE*) 
            a10del_sysinfo (acv, sysk, b_err);
            IF  b_err = e_ok
            THEN
                IF  usagenext_exist
                THEN
                    a06inc_linkage (sysk.slinkage)
                ELSE
                    b_err := e_sysinfo_not_found;
                (*ENDIF*) 
            (*ENDIF*) 
            END;
        (*ENDWITH*) 
    (*ENDIF*) 
UNTIL
    (b_err <> e_ok);
(*ENDREPEAT*) 
IF  b_err <> e_sysinfo_not_found
THEN
    a07_b_put_error (acv, b_err, 1)
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      ak264drop_dbproc (VAR acv : tak_all_command_glob;
            VAR procid      : tgg00_Surrogate);
 
VAR
      b_err          : tgg00_BasisError;
      method_buf     : tak_sysbufferaddress;
      methodinfo_buf : tak_sysbufferaddress;
      sysk           : tgg00_SysInfoKey;
 
BEGIN
sysk           := a01defaultkey;
sysk.stableid  := procid;
sysk.sentrytyp := cak_emethodinfo;
a10get_sysinfo (acv, sysk, d_fix, methodinfo_buf, b_err);
IF  b_err = e_ok
THEN
    IF  methodinfo_buf^.smethodinfo.mei_owner <> acv.a_curr_user_id
    THEN
        b_err := e_missing_privilege
    ELSE
        BEGIN
        sysk.sentrytyp := cak_emethod;
        a10get_sysinfo (acv, sysk, d_fix, method_buf, b_err)
        END ;
    (*ENDIF*) 
(*ENDIF*) 
IF  b_err = e_ok
THEN
    a261drop_procedure (acv, method_buf, acv.a_curr_user_id)
ELSE
    a07_b_put_error (acv, b_err, 1)
(*ENDIF*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :         58
*-PRETTY-*  lines of code :        193        PRETTYX 3.10 
*-PRETTY-*  lines in file :        393         1997-12-10 
.PA 
