.CM  SCRIPT , Version - 1.1 , last edited by holger
.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 2000-2005 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.TT 1 $SQL$Project Distributed Database System$VIN71$
.tt 2 $$$
.TT 3 $$SQLEXEC$1998-06-19$
***********************************************************
.nf
 
.nf
 
 .nf

    ========== licence begin  GPL
    Copyright (c) 2000-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
 
 
.fo
.nf
.sp
MODULE  : SQLEXEC
=========
.sp
Purpose : Parse and execute operating system calls
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        FUNCTION
              i71exec (VAR cmnd : tin_cmd_type;
                    VAR msg : tin_screenline) : tin_i71_state;
 
        PROCEDURE
              i71sqlexec (
                    VAR ex_command    : tsp00_ExecLine;
                    ex_mode           : tsp00_ExecMode;
                    VAR ex_return     : tsp00_ExecReturn;
                    VAR ex_errtext    : tsp00_ErrText;
                    VAR ex_progresult : tsp00_Int2;
                    hold              : boolean;
                    reset_tty         : boolean );
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              global_variable : VIN01;
 
        VAR
              i01g   : tin_global_in_vars;
 
      ------------------------------ 
 
        FROM
              Kernel_move_and_fill : VGG101;
 
        PROCEDURE
              SAPDB_PascalForcedFill (
                    size        : tsp00_Int4;
                    m           : tsp00_MoveObjPtr;
                    pos         : tsp00_Int4;
                    len         : tsp00_Int4;
                    fillchar    : char);
 
        PROCEDURE
              SAPDB_PascalForcedMove (
                    source_upb  : tsp00_Int4;
                    destin_upb  : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;
                    source_pos  : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;
                    destin_pos  : tsp00_Int4;
                    length      : tsp00_Int4);
 
        PROCEDURE
              s10mv (
                    source_upb  : tsp00_Int4;       
                    destin_upb  : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;    
                    source_pos  : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;    
                    destin_pos  : tsp00_Int4;
                    length      : tsp00_Int4);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-30 : VSP30;
 
        FUNCTION
              s30klen (VAR str : tsp00_ExecLine;
                    val : char; cnt : integer) : integer;
 
      ------------------------------ 
 
        FROM
              RTE-Extension-70 : VSP70;
 
        PROCEDURE
              s70execanalyze (VAR cmd : tin_screenline;
                    cmdl              : tsp00_Int2;
                    VAR ex_command    : tsp00_ExecLine;
                    VAR ex_mode       : tsp00_ExecMode;
                    VAR spec_complete : boolean);
 
      ------------------------------ 
 
        FROM
              RTE_driver : VEN102;
 
        PROCEDURE
              sqlexec ( VAR command   : tsp00_ExecLine;
                    mode              : tsp00_ExecMode;
                    VAR exec_ret      : tsp00_ExecReturn;
                    VAR err_text      : tsp00_ErrText;
                    VAR commandresult : tsp00_Int2);
&       if $os = unix
 
        PROCEDURE
              sqltrelease (term_ref : tsp00_Int4);
 
        PROCEDURE
              sqlthold (term_ref : tsp00_Int4; wait : boolean);
&       endif
 
      ------------------------------ 
 
        FROM
              logical_screen_IO: VIN57;
 
        PROCEDURE
              i57screenmessed;
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              s30klen;
 
              tsp00_MoveObj tsp00_ExecLine
 
        PROCEDURE
              s70execanalyze;
 
              tsp00_Buf tin_screenline
 
        PROCEDURE
              sqlexec;
 
              tsp00_ExecLine    tsp00_ExecLine
              tsp00_ExecMode    tsp00_ExecMode
              tsp00_ExecReturn  tsp00_ExecReturn
              tsp00_ErrText     tsp00_ErrText
              tsp00_Int2        tsp00_Int2
 
        PROCEDURE
              sqltrelease;
 
              tsp00_Int4  tsp00_Int4
 
        PROCEDURE
              sqlthold;
 
              tsp00_Int4  tsp00_Int4
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  :
.sp
.cp 3
Created : 1989-06-08
.sp
.cp 3
.sp
.cp 3
Release :      Date : 1998-06-19
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
Function I71EXEC (CMND : cmnd_type; MSG : ti_screenline) : ti_i71_state;
.sp
CMND contains the command entered by the user.
.sp
ti_i71_state ::= i71_no_exec | i71_is_exec | i71_executed | i71_error
.sp
"i71_no_exec" is returned if CMND contains no "exec" sign.
.sp;.nf
"i71_is_exec" is returned if CMND contains an "exec" sign, but
              <command> (see below) is empty.
.sp
"i71_executed" is returned if CMND contains a full "exec" call
             that was executed and returned no error
.sp
i71_error is returned if CMND contains a full "exec" call
          that was executed and returned an error
          (exec_return <> e_ok).
.sp 2
The ti_screenline MSG contains either blanks or an error message text.
.sp 2
The formats recognized as "exec" sign are analyzed and described
in VSP70.
 
.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    :
 
 
(*------------------------------*) 
 
FUNCTION
      i71exec (VAR cmnd : tin_cmd_type;
            VAR msg : tin_screenline) : tin_i71_state;
 
VAR
      spec_complete : boolean;
      ex_command    : tsp00_ExecLine;
      ex_mode       : tsp00_ExecMode;
      ex_return     : tsp00_ExecReturn;
      ex_errtext    : tsp00_ErrText;
      ex_progresult : tsp00_Int2;
 
BEGIN
SAPDB_PascalForcedFill (mxin_screenline, @msg, 1, mxin_screenline, bsp_c1);
s70execanalyze (cmnd.content, cmnd.length, ex_command,
      ex_mode, spec_complete);
IF  NOT spec_complete
THEN
    i71exec := i71_no_exec
ELSE
    IF  (s30klen (ex_command, bsp_c1, EXEC_LINE_MXSP00) = 0)
    THEN
        i71exec := i71_is_exec
    ELSE
        BEGIN
        i71sqlexec (ex_command, ex_mode, ex_return,
              ex_errtext, ex_progresult, true, true );
        IF  ex_return = ex_ok
        THEN
            BEGIN
            i71exec := i71_executed;
            cmnd.length := 0;
            END
        ELSE
            BEGIN
            i71exec := i71_error;
            IF  ex_return = ex_no_exec
            THEN
                ex_errtext := 'NOT IMPLEMENTED                         ';
            (*ENDIF*) 
            s10mv (ERRTEXT_MXSP00,mxin_screenline,
                  @ex_errtext,1,
                  @msg,1,ERRTEXT_MXSP00);
            END;
        (*ENDIF*) 
        END;
    (*ENDIF*) 
(*ENDIF*) 
END; (* i71exec *)
 
(*------------------------------*) 
 
PROCEDURE
      i71sqlexec (
            VAR ex_command    : tsp00_ExecLine;
            ex_mode           : tsp00_ExecMode;
            VAR ex_return     : tsp00_ExecReturn;
            VAR ex_errtext    : tsp00_ErrText;
            VAR ex_progresult : tsp00_Int2;
            hold              : boolean;
            reset_tty         : boolean );
 
BEGIN
&if $os = unix
IF  (ex_mode <> async) AND reset_tty
THEN
    sqltrelease (i01g^.vt.vt_ref);
&endif
(*ENDIF*) 
sqlexec (ex_command, ex_mode, ex_return,
      ex_errtext, ex_progresult);
&if $os = unix
IF  (ex_mode <> async) AND reset_tty
THEN
    BEGIN
    i57screenmessed;
    sqlthold (i01g^.vt.vt_ref, hold);
    END;
&endif
(*ENDIF*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
.PA 
