Loading src/UnicaenDbImport/CodeGenerator/CodeGenerator.php +10 −2 Original line number Diff line number Diff line Loading @@ -411,13 +411,19 @@ EOS; // Eventuel filtre. $andWhere = $filter ? 'and ' . $filter : ''; // Colonne 'detail'. Ex: "coalesce(t.RESULTAT::varchar, '') || '>' || coalesce(v.RESULTAT::varchar, '')" $detail = 'coalesce(' . $this->tableHelper->generateSQLForCastToString("t.$columnName") . ", '')" . " || '>' || " . 'coalesce(' . $this->tableHelper->generateSQLForCastToString("v.$sColName") . ", '')"; // Construction de la requête recherchant dans la vue V_DIFF_X les lignes correspondant à : // une prise de valeur particulière spécifiée par IMPORT_OBSERV.TO_VALUE, // de la colonne spécifiée par IMPORT_OBSERV.COLUMN_NAME, // dans la table spécifiée par IMPORT_OBSERV.TABLE_NAME. return <<<EOS select $id import_observ_id, v.source_code, t.$columnName || '>' || v.$sColName detail $detail detail from V_DIFF_$tableName v join $tableName t on t.source_code = v.source_code where $uColName = 1 and $toValueCond Loading @@ -439,12 +445,14 @@ EOS; } $selects = implode(PHP_EOL . 'UNION ALL' . PHP_EOL, $selects); $nextval = $this->tableHelper->generateSQLForSequenceNextVal('import_observ_result_id_seq'); return <<<EOS insert into import_observ_result (id, date_creation, import_observ_id, source_code, resultat) with tmp as ( $selects ) select import_observ_result_id_seq.nextval, $now, import_observ_id, source_code, detail select $nextval, $now, import_observ_id, source_code, detail from tmp EOS; } Loading src/UnicaenDbImport/CodeGenerator/Helper/TableHelper.php +6 −0 Original line number Diff line number Diff line Loading @@ -512,6 +512,12 @@ EOT; return $tableName . '_ID_SEQ'; } /** * @param string $columnName * @return string */ abstract public function generateSQLForCastToString(string $columnName); /** * @param string $sequenceName * @return string Loading src/UnicaenDbImport/CodeGenerator/Oracle/Helper/TableHelper.php +8 −0 Original line number Diff line number Diff line Loading @@ -132,4 +132,12 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper { return $sequenceName . '.nextval'; } /** * @inheritDoc */ public function generateSQLForCastToString(string $columnName) { return $columnName . "||''"; } } No newline at end of file src/UnicaenDbImport/CodeGenerator/PostgreSQL/Helper/TableHelper.php +8 −0 Original line number Diff line number Diff line Loading @@ -87,4 +87,12 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper { return "nextval('" . $sequenceName . "')"; } /** * @inheritDoc */ public function generateSQLForCastToString(string $columnName) { return $columnName . '::varchar'; } } No newline at end of file Loading
src/UnicaenDbImport/CodeGenerator/CodeGenerator.php +10 −2 Original line number Diff line number Diff line Loading @@ -411,13 +411,19 @@ EOS; // Eventuel filtre. $andWhere = $filter ? 'and ' . $filter : ''; // Colonne 'detail'. Ex: "coalesce(t.RESULTAT::varchar, '') || '>' || coalesce(v.RESULTAT::varchar, '')" $detail = 'coalesce(' . $this->tableHelper->generateSQLForCastToString("t.$columnName") . ", '')" . " || '>' || " . 'coalesce(' . $this->tableHelper->generateSQLForCastToString("v.$sColName") . ", '')"; // Construction de la requête recherchant dans la vue V_DIFF_X les lignes correspondant à : // une prise de valeur particulière spécifiée par IMPORT_OBSERV.TO_VALUE, // de la colonne spécifiée par IMPORT_OBSERV.COLUMN_NAME, // dans la table spécifiée par IMPORT_OBSERV.TABLE_NAME. return <<<EOS select $id import_observ_id, v.source_code, t.$columnName || '>' || v.$sColName detail $detail detail from V_DIFF_$tableName v join $tableName t on t.source_code = v.source_code where $uColName = 1 and $toValueCond Loading @@ -439,12 +445,14 @@ EOS; } $selects = implode(PHP_EOL . 'UNION ALL' . PHP_EOL, $selects); $nextval = $this->tableHelper->generateSQLForSequenceNextVal('import_observ_result_id_seq'); return <<<EOS insert into import_observ_result (id, date_creation, import_observ_id, source_code, resultat) with tmp as ( $selects ) select import_observ_result_id_seq.nextval, $now, import_observ_id, source_code, detail select $nextval, $now, import_observ_id, source_code, detail from tmp EOS; } Loading
src/UnicaenDbImport/CodeGenerator/Helper/TableHelper.php +6 −0 Original line number Diff line number Diff line Loading @@ -512,6 +512,12 @@ EOT; return $tableName . '_ID_SEQ'; } /** * @param string $columnName * @return string */ abstract public function generateSQLForCastToString(string $columnName); /** * @param string $sequenceName * @return string Loading
src/UnicaenDbImport/CodeGenerator/Oracle/Helper/TableHelper.php +8 −0 Original line number Diff line number Diff line Loading @@ -132,4 +132,12 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper { return $sequenceName . '.nextval'; } /** * @inheritDoc */ public function generateSQLForCastToString(string $columnName) { return $columnName . "||''"; } } No newline at end of file
src/UnicaenDbImport/CodeGenerator/PostgreSQL/Helper/TableHelper.php +8 −0 Original line number Diff line number Diff line Loading @@ -87,4 +87,12 @@ class TableHelper extends \UnicaenDbImport\CodeGenerator\Helper\TableHelper { return "nextval('" . $sequenceName . "')"; } /** * @inheritDoc */ public function generateSQLForCastToString(string $columnName) { return $columnName . '::varchar'; } } No newline at end of file