ExecSql
![]() |
Cette
page a été mise à jour le21
décembre
2009
. Contact ![]() |
![]() |
see also
Cet outil permet d'exécuter une pile de
commandes SQL, comme le fait déja STRQMQRY (avec un ; entre
chaque commande SQL).
Cet outil ne permet pas
cet outil requiert (voir page de sommaire) Syntaxe utilisée
Mode d'emploi Cet outil propose plusieurs modes d'action :
Le mode RUNSQLSTM a des contraintes. La première étant qu'une commande SQL peut s'étaler sur une ou plusieurs lignes de 80 Caractères MAXIMUM Le texte des commandes se saisit dans un fichier source "normal" ... à savoir un fichier de largeur 80 à 100 caractères. separer chaque commande SQL avec une ligne RUNSQL , pour provoquer la prise en compte de la commande SQL par QSYS/RUNSQLSTM ... COMMIT(*NONE) NAMING(*SYS) Ou avec une ligne EXECUTESQL pour provoquer la prise en compte de la commande SQL par Execute Immediat, controlé par les SET OPTION codés en dur dans EXECSQLR (par défaut, aucun) Substitution de parametres : exemple |
This tool permits to execute a
stack of SQL orders, as already do STRQMQRY (with one ; between each
SQL order). It also permits
This tool doesn't permit
this tool requires (see summary) Syntax used
This tool offers some different action modes :
The RUNSQLSTM mode hac its constraints. The first is that an SQL order can spread on one or several lines of 80 MAXIMUM Characters The text of the orders are in a "normal" source file...
ie a file with record size 80 to 100 characters. Separate every SQL order with a RUNSQL line, to provoke the running of the SQL by the command QSYS/RUNSQLSTM... COMMIT(*NONE) NAMING(*SYS) Or with a EXECUTESQL to provoke the running of the SQL order by Immediate Execute ... controled by hardcoded SET OPTION in EXECSQLR (initialy, none) Substitution of parameters : sample |
|
2) l'appel | 2) the run |
|
excsql respecte les minuscules : dans le texte, dans le nom des variables (attention, l'as400 met par défaut en majuscule la saisie) et dans le texte de remplacement remarque : la ligne RUNSQL ou EXECUTESQL n'est pas sensible à la majuscule mais le mot 'RUNSQL'/'EXECUTESQL' doit être en position 1 à 6, 1 à 10 de la ligne si le titre est indiqué, il est utilisé comme référence utilisateur du spoule QTMPSQL, sinon référence = ligne du source options pour RUNSQLSTM gestion des messages. en fait, SQL9010 La commande
RUNSQLSTM a échoué. commentaires Imbrication de commande as400 : basé sur create procedure jpl/syscmd(UDF - user define function - source = jpl/qtxtsrc(sql)
|
excsql respects the lower-case
letters: in the text, in the variables name (attention, by
default the as400 capitalize the input) and in the text of
remplacement
remarque: the RUNSQL ou EXECUTESQL line is not sensitive to the case but the word ' RUNSQL'/'EXECUTESQL' must be in position 1 to 6, 1 to 10 of the line if title is indicated, it is used as user reference of the QTMPSQL spoule, otherwise reference = source line number options for RUNSQLSTM messages handling. in fact, SQL9010 : RUNSQLSTM has failed. by default: brutal exit with *ESCAPE commentaires Imbrication of as400 order: based on create procedure jpl/syscmd(UDF - to use define function - source = jpl/qtxtsrc(sql) |
|
Variables. Les
variables "internes" complètent les variables transmises par
l'appelant DELETE FROM &WORKDATA/MYFILE appelé par appelé par DELETE FROM &WORKDATA/MYFILE Test des variables internes : |
Variables.
The "internal" variables complete the variables transmitted by the
caller setvar permits to create or to correct a variable. One setvar can mention an existing variable A variable is detected in the code source by it
&. as soon as it finds a & the interpreter is
potentially working with 10 variables, depending on
analysing
1 to 10 chars after the &. At least, one must exists. The
interpreter looks among the available variables for the
first
that corresponds to the text. It is the length of each variable
that
determines the length of the text source analyzed. DELETE FROM &WORKDATA/MYFILE called by called by DELETE FROM &WORKDATA/MYFILE test of internal variables : |
ABCDEF = &ABCDEF |
Tester par | Test with |
EXECSQL LIBRARY(ECOLIB) MEMBER(EXECSQLTST) |
Vérifier par DSPJOBLOG, juste après CALL EXECSQLR : | Check with DSPJOBLOG, just after CALL EXECSQLR |
6100 - CALL PGM(EXECSQLR) /* LA COMMANDE CALL CONTIENT DES PARAMÈTRES * |
la suite importe peu. Ce test se termine par un
plantage. tu t'en doutais pas un peu ? OnCreate Ces deux options permettent de valoriser correctement les paramètres de CHGOBJATR, outil utilisé par EXECSQL chaque fois qu'il crée un objet SQL ONCREATE-USERATTR = le marqueur personnel. Cette option garde sa valeur en permanence ONCREATE-TEXT = la description de l'objet. Cette option est effacée après chaque utilisation pour éviter de répéter abusivement un nom d'objet (dans le cas de deux CREATE de suite, en en absence de ONCREATE-TEXT après le premier CREATE) Il y a un bug quand on crée une table SQL dans QTEMP quand le nom de la table fait plus de 10 caractères (dans ce cas le nom AS400 est différent du nom SQL) : |
the continuation imports little.
This test ends by an abort. didn't you suspect a few of them?
OnCreate These two options permit to valorize the parameters of CHGOBJATR correctly, tool used by EXECSQL each time it creates a SQL object ONCREATE-USERATTR = the personal mark. This option keeps its value in permanence, such as a variable. ONCREATE-TEXT = the object description. This option is erased after each use to avoid to repeat an object name abusively (in the case of two successive CREATE, without ONCREATE-TEXT after the first CREATE) There is a bug when it creates a SQL table in QTEMP when the table name is more than 10 characters long (in this case the AS400 name is different from the SQL name) |
setvar toto = VA.savoir |
Ca plante : je ne sais pas où est
l'équivalent de qsys.qadbxref pour qtemp. |
It dumps: I don't know where is the
equivalent of qsys.qadbxref for qtemp. therefore no long name (>10 cahrs) in qtemp under execsql |
last version : The SaveFiles