SQL Programming Manual for Pascal
Examples of Dynamic NonStop SQL Programs
HP NonStop SQL Programming Manual for Pascal—528614-001
C-19
Detailed Dynamic SQL Program
 468 0 {**********************************************************}
 469 0 {* PARSE_CMD : Parse the command string and return the
          following *}
 470 0 {* tokens depending upon the input:    *}
 471 0 {* CMD_PREV_TYP : input is a PREVCMD string.   *}
 472 0 {* CMD_SQL_TYP : input is a SQL string.    *}
 473 0 {* CMD_STOP_TYP : input is a STOPCMD string.   *}
 474 0 {**********************************************************}
 475 0 function parse_cmd(var cmd : CMND_BUF) : integer;
 476 1 var
 477 1  i : integer := 1; { loop index   }
 478 1  cmd_len : integer; { input cmd string length }
 479 1  canned_cmd : CMND_BUF; { canned terminate command }
 480 1 begin
 481 2  if (same_cmd(cmd,CMD_PREV_TYP)) then
 482 3  begin
 483 4  parse_cmd := CMD_PREV_TYP;
 484 4  return;
 485 4  end
 486 3  else if (same_cmd(cmd,CMD_STOP_TYP)) then
 487 4  begin
 488 5  parse_cmd := CMD_STOP_TYP;
 489 5  return;
 490 5  end
 491 4  else if (valid_cmd(cmd[1])) then
 492 5  begin
 493 6  parse_cmd := CMD_SQL_TYP;
 494 6  return;
 495 6  end
 496 5  else parse_cmd := CMD_JUNK_TYP;
 497 2 end; { of proc parse_cmd }
 498 0
 499 0 {**********************************************************}
 500 0 {* READ_CMD: Prompt the user to read the input command.  *}
 501 0 {**********************************************************}
 502 0 procedure read_cmd(var cmdbuf : CMND_BUF);
 503 1 begin
 504 2  write('Enter a new SQL statement or ');
 505 2  write(CMD_PREV_STR,' to use the previous one or ');
 506 2  writeln(CMD_STOP_STR,' to stop :');
 507 2  readln(cmdbuf);
 508 2 end; { of proc readcmd }
 509 0










