Commit 026c1c2e authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Mise à jour du générateur de TBL et ajout des paramètres d'optimisation pour les vues

parent 34322eca
Loading
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -269,15 +269,27 @@ class QueryGeneratorService extends AbstractService
        $testDiff = trim(implode("        AND ", $testDiff));
        $cols = trim(implode(",\n      ", $cols));

//        $view = $this->getViewDefinition($view);
//        $view = str_replace( '\'', '\'\'', $view);
//        $view = str_replace( "\n", "\n        ", $view);
        $view = $this->getViewDefinition($view);
        $view = str_replace( '\'', '\'\'', $view);
        $view = str_replace( "\n", "\n        ", $view);

        $sql = "  PROCEDURE C_$tableauBord(param VARCHAR2, value VARCHAR2) IS
  TYPE r_cursor IS REF CURSOR;
  c r_cursor;
  d $table%rowtype;
  filter VARCHAR2(150);
  viewQuery CLOB;
  BEGIN
    viewQuery := '$view';
  
    IF param IS NULL THEN 
      filter := '1=1';
    ELSIF value IS NULL THEN
      filter := 'COALESCE(v.' || param || ', t.' || param || ') IS NULL';
    ELSE
      filter := 'COALESCE(v.' || param || ', t.' || param || ') = q''[' || value || ']''';
    END IF;
    
    OPEN c FOR '
    SELECT
      CASE WHEN 
@@ -285,10 +297,10 @@ class QueryGeneratorService extends AbstractService
      THEN -1 ELSE t.ID END ID,
      $cols
    FROM
      ($view) v
      (' || QUERY_APPLY_PARAM(viewQuery,param,value) || ') v
      FULL JOIN $table t ON 
            $join
    ';
    WHERE ' || filter;
    LOOP
      FETCH c INTO d; EXIT WHEN c%NOTFOUND;