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


    ========== licence begin LGPL
    Copyright (C) 2000 SAP AG

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

    This library 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
    Lesser General Public License for more details.

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

.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    : tsp_execline;
                    ex_mode           : tsp_exec_mode;
                    VAR ex_return     : tsp_exec_return;
                    VAR ex_errtext    : tsp_errtext;
                    VAR ex_progresult : tsp_int2;
                    hold              : boolean;
                    reset_tty         : boolean );
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              global_variable : VIN01;
 
        VAR
              i01g   : tin_global_in_vars;
 
      ------------------------------ 
 
        FROM
              RTE-Extension-10 : VSP10;
 
        PROCEDURE
              s10mv1 (size1 : tsp_int4; size2 : tsp_int4;
                    VAR val1 : tsp_errtext; p1 : tsp_int4;
                    VAR val2 : tin_screenline; p2  :tsp_int4;
                    cnt : tsp_int4);
 
        PROCEDURE
              s10fil (size   : tsp_int4;
                    VAR m    : tin_screenline;
                    pos      : tsp_int4;
                    len      : tsp_int4;
                    fillchar : char);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-30 : VSP30;
 
        FUNCTION
              s30klen (VAR str : tsp_execline;
                    val : char; cnt : integer) : integer;
 
      ------------------------------ 
 
        FROM
              RTE-Extension-70 : VSP70;
 
        PROCEDURE
              s70execanalyze (VAR cmd : tin_screenline;
                    cmdl              : tsp_int2;
                    VAR ex_command    : tsp_execline;
                    VAR ex_mode       : tsp_exec_mode;
                    VAR spec_complete : boolean);
 
      ------------------------------ 
 
        FROM
              RTE_driver : VEN102;
 
        PROCEDURE
              sqlexec ( VAR command   : tsp_execline;
                    mode              : tsp_exec_mode;
                    VAR exec_ret      : tsp_exec_return;
                    VAR err_text      : tsp_errtext;
                    VAR commandresult : tsp_int2);
&       if $os = unix
 
        PROCEDURE
              sqltrelease (term_ref : tsp_int4);
 
        PROCEDURE
              sqlthold (term_ref : tsp_int4; wait : boolean);
&       endif
 
      ------------------------------ 
 
        FROM
              logical_screen_IO: VIN57;
 
        PROCEDURE
              i57screenmessed;
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              s10mv1;
 
              tsp_moveobj tsp_errtext
              tsp_moveobj tin_screenline
 
        PROCEDURE
              s10fil;
 
              tsp_moveobj tin_screenline
 
        PROCEDURE
              s30klen;
 
              tsp_moveobj tsp_execline
 
        PROCEDURE
              s70execanalyze;
 
              tsp_buf tin_screenline
 
        PROCEDURE
              sqlexec;
 
              tsp00_ExecLine    tsp_execline
              tsp00_ExecMode    tsp_exec_mode
              tsp00_ExecReturn  tsp_exec_return
              tsp00_ErrText     tsp_errtext
              tsp00_Int2        tsp_int2
 
        PROCEDURE
              sqltrelease;
 
              tsp00_Int4  tsp_int4
 
        PROCEDURE
              sqlthold;
 
              tsp00_Int4  tsp_int4
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : 
.sp
.cp 3
Created : 1989-06-08
.sp
.cp 3
Version : 1998-06-19
.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    : tsp_execline;
      ex_mode       : tsp_exec_mode;
      ex_return     : tsp_exec_return;
      ex_errtext    : tsp_errtext;
      ex_progresult : tsp_int2;
 
BEGIN
s10fil (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, mxsp_execline) = 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*) 
            s10mv1 (mxsp_errtext, mxin_screenline,
                  ex_errtext, 1, msg, 1, mxsp_errtext);
            END;
        (*ENDIF*) 
        END;
    (*ENDIF*) 
(*ENDIF*) 
END; (* i71exec *)
 
(*------------------------------*) 
 
PROCEDURE
      i71sqlexec (
            VAR ex_command    : tsp_execline;
            ex_mode           : tsp_exec_mode;
            VAR ex_return     : tsp_exec_return;
            VAR ex_errtext    : tsp_errtext;
            VAR ex_progresult : tsp_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 
***********************************************************
*-PRETTY-*  statements    :         20
*-PRETTY-*  lines of code :         82        PRETTYX 3.10 
*-PRETTY-*  lines in file :        320         1997-12-10 
.PA 
