Generate code for stored routine.

@param string $tableName The table name.
@param string $spType    Stored routine type {insert|update|delete|select}.
@param string $spName    Stored routine name.

@return string
495654
private function generateSP(string $tableName, string $spType, string $spName): string
  {
    switch ($spType)
    {
      case 'UPDATE':
        $routine = new UpdateRoutine($this->input,
                                     $this->output,
                                     $this->helper,
                                     $spType,
                                     $spName,
                                     $tableName,
                                     $this->dataSchema);
        break;

      case 'DELETE':
        $routine = new DeleteRoutine($this->input,
                                     $this->output,
                                     $this->helper,
                                     $spType, $spName,
                                     $tableName,
                                     $this->dataSchema);
        break;

      case 'SELECT':
        $routine = new SelectRoutine($this->input,
                                     $this->output,
                                     $this->helper,
                                     $spType, $spName,
                                     $tableName,
                                     $this->dataSchema);
        break;

      case 'INSERT':
        $routine = new InsertRoutine($this->input,
                                     $this->output,
                                     $this->helper,
                                     $spType,
                                     $spName,
                                     $tableName,
                                     $this->dataSchema);
        break;

      default:
        throw new FallenException("Unknown type '%s'", $spType);
    }

    return $routine->getCode();
  }
882733
public String generateSqlInsert(String tableName) {
        try {
            return cacheSQLs.get("INSERT:" + tableName, () -> {
                return MessageFormat.format("INSERT INTO {0} ({1}) VALUES ({2})", tableName,
                        strAllColumns, StringUtils.repeat("?", ",", getAllColumns().length));
            });
        } catch (ExecutionException e) {
            throw new DaoException(e);
        }
    }
353713
public String getInsertNamesPrepareSQL(T bean) {
        if (this.tableStrategy == null) return insertNamesPrepareSQL;
        return insertNamesPrepareSQL.replace("${newtable}", getTable(bean));
    }
826762
public function generateTableRowsForType($rdfType,$subject=null,$context=null, $specTypes = [])
    {
        $rdfType = $this->labeller->qname_to_alias($rdfType);
        $rdfTypeAlias = $this->labeller->uri_to_alias($rdfType);
        $foundSpec = false;

        if(empty($specTypes))
        {
            $tableSpecs = $this->getConfigInstance()->getTableSpecifications($this->storeName);
        }
        else
        {
            $tableSpecs = [];
            foreach($specTypes as $specType)
            {
                $spec = $this->getConfigInstance()->getTableSpecification($this->storeName, $specType);
                if($spec)
                {
                    $tableSpecs[$specType] = $spec;
                }
            }
        }

        foreach($tableSpecs as $key=>$tableSpec)
        {
            if(isset($tableSpec["type"]))
            {
                $types = $tableSpec["type"];
                if(!is_array($types))
                {
                    $types = array($types);
                }
                if (in_array($rdfType, $types) || in_array($rdfTypeAlias, $types))
                {
                    $foundSpec = true;
                    $this->debugLog("Processing {$tableSpec[_ID_KEY]}");
                    $this->generateTableRows($key,$subject,$context);
                }
            }
        }
        if (!$foundSpec)
        {
            $this->debugLog("Could not find any table specifications for $subject with resource type '$rdfType'");
            return;
        }
    }
879446
public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = "            ", $phpType = null)
    {
        if (!$sequenceName) {
            throw new EngineException('PostgreSQL needs a sequence name to fetch primary keys');
        }
        $snippet = "
\$dataFetcher = %s->query(\"SELECT nextval('%s')\");
%s = %s\$dataFetcher->fetchColumn();";
        $script = sprintf($snippet,
            $connectionVariableName,
            $sequenceName,
            $columnValueMutator,
            $phpType ? '('.$phpType.') ' : ''
        );

        return preg_replace('/^/m', $tab, $script);
    }
874083
protected function generateChangeFieldSql( $tableName, $fieldName, ezcDbSchemaField $fieldDefinition )
    {
        $this->queries[] = "ALTER TABLE '$tableName' CHANGE '$fieldName' " . $this->generateFieldSql( $fieldName, $fieldDefinition );
    }
188008
function GenID2008($seq='adodbseq',$start=1)
	{
		if($this->debug) ADOConnection::outp("<hr>CreateSequence($seq,$start)");
		sqlsrv_begin_transaction($this->_connectionID);
		$ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1");
		if (!$ok) {
			$start -= 1;
			$this->Execute("create table $seq (id int)");//was float(53)
			$ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
			if (!$ok) {
				if($this->debug) ADOConnection::outp("<hr>Error: ROLLBACK");
				sqlsrv_rollback($this->_connectionID);
				return false;
			}
		}
		$num = $this->GetOne("select id from $seq");
		sqlsrv_commit($this->_connectionID);
		return $num;
	}
504233
public static function dropRoutine(string $routineType, string $routineName): void
  {
    $query = sprintf('drop %s if exists `%s`', $routineType, $routineName);

    self::executeNone($query);
  }
732917
protected function beginAlterByCopyTable($tableName)
    {
        $instructions = new AlterInstructions();
        $instructions->addPostStep(function ($state) use ($tableName) {
            $createSQL = $this->getDeclaringSql($tableName);

            $tmpTableName = 'tmp_' . $tableName;
            $this->execute(
                sprintf(
                    'ALTER TABLE %s RENAME TO %s',
                    $this->quoteTableName($tableName),
                    $this->quoteTableName($tmpTableName)
                )
            );

            return compact('createSQL', 'tmpTableName') + $state;
        });

        return $instructions;
    }
108364
public function getTableSchemaId(string $tableName): string
    {
        $sql = sprintf('SHOW FULL COLUMNS FROM %s;', $this->quoter->quoteName($tableName));
        $rows = $this->db->query($sql)->fetchAll(PDO::FETCH_ASSOC);

        return sha1(json_encode($rows));
    }
1137100
protected function generateFunctionName($programPath, $programName)
    {
        return sprintf(
            '_%s_%s_complete',
            $this->sanitiseForFunctionName(basename($programName)),
            substr(md5($programPath), 0, 16)
        );
    }
1102360
protected function generateMainPart(array $columns): void
  {
    $this->codeStore->append(sprintf('create procedure %s(', $this->spName));

    $padding = $this->getMaxColumnLength($columns);
    $offset  = mb_strlen($this->codeStore->getLastLine());

    $first = true;
    foreach ($columns as $column)
    {
      if ($first)
      {
        $format = sprintf(' in p_%%-%ds @%%s.%%s%%s@', $padding);
        $this->codeStore->appendToLastLine(strtolower(sprintf($format,
                                                              $column['column_name'],
                                                              $this->tableName,
                                                              $column['column_name'],
                                                              '%type')));
      }
      else
      {
        $format = sprintf('%%%ds p_%%-%ds @%%s.%%s%%s@', $offset + 3, $padding);
        $this->codeStore->append(strtolower(sprintf($format,
                                                    'in',
                                                    $column['column_name'],
                                                    $this->tableName,
                                                    $column['column_name'],
                                                    '%type')), false);
      }

      if ($column!=end($columns))
      {
        $this->codeStore->appendToLastLine(',');
      }
      else
      {
        $this->codeStore->appendToLastLine(' )');
      }

      $first = false;
    }
  }
30925
function generateTableSQLList( $tableName, $table, $params, $separateTypes )
    {
        return $this->generateTableSQL( $tableName, $table, $params, true, $separateTypes );
    }
835717
private function getProcedureStructure($procedureName)
    {
        if (!$this->dumpSettings['skip-comments']) {
            $ret = "--".PHP_EOL.
                "-- Dumping routines for database '".$this->dbName."'".PHP_EOL.
                "--".PHP_EOL.PHP_EOL;
            $this->compressManager->write($ret);
        }
        $stmt = $this->typeAdapter->show_create_procedure($procedureName);
        foreach ($this->dbHandler->query($stmt) as $r) {
            $this->compressManager->write(
                $this->typeAdapter->create_procedure($r)
            );
            return;
        }
    }
372842
String buildPreparedStatementName(String methodName) {
		String name = methodName + "PreparedStatement" + preparedStatementNames.size();

		preparedStatementNames.add(name);
		return name;
	}
7050
public function addCode($tableName, $columnName = 'code')
    {
        $this->addColumn('{{%' . $tableName . '}}', $columnName,
            $this->string(32)->comment('Code for this item, used identifying when needed. Another criteria to replace ID because ID is auto-increment'));
        $this->createIndex($tableName . '_' . $columnName . '_idx', '{{%' . $tableName . '}}', $columnName);
    }
1006401
public function getIdentifierPhp($columnValueMutator, $connectionVariableName = '$con', $sequenceName = '', $tab = "            ", $phpType = null)
    {
        return sprintf(
            "
%s%s = %s%s->lastInsertId(%s);",
            $tab,
            $columnValueMutator,
            $connectionVariableName,
            $phpType ? '('.$phpType.') ' : '',
            $sequenceName ? ("'" . $sequenceName . "'") : ''
        );
    }