diff options
Diffstat (limited to 'sql/serenitasdb.sql')
| -rw-r--r-- | sql/serenitasdb.sql | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/sql/serenitasdb.sql b/sql/serenitasdb.sql index a562ff8a..772411c3 100644 --- a/sql/serenitasdb.sql +++ b/sql/serenitasdb.sql @@ -662,8 +662,6 @@ $$ IF r.quotesource = 'MSre' THEN
CONTINUE;
END IF;
- EXIT WHEN r.quotesource != 'CITI';
- END LOOP;
EXECUTE
'SELECT array_agg(attach ORDER BY attach ASC)||100::smallint = $6||array_agg(detach ORDER BY detach ASC)
FROM tranche_quotes
@@ -671,18 +669,19 @@ $$ AND quotedate=$4 AND detach-attach!=5::smallint AND quotesource=$5'
INTO flag
USING pg_index_type, pg_series, pg_tenor, r.quotedate, r.quotesource, lower_attach;
- IF flag THEN
- IF pg_index_type = 'HY' AND pg_series >=15 THEN
- RETURN QUERY
- SELECT * FROM tranche_quotes WHERE index=pg_index_type::index_type AND series= pg_series
- AND tenor=pg_tenor::tenor AND quotedate=r.quotedate AND detach-attach!=5::smallint AND
- quotesource=r.quotesource ORDER BY attach ASC;
- ELSE
- RETURN QUERY
- SELECT * FROM tranche_quotes WHERE index=pg_index_type::index_type AND series=pg_series
- AND tenor=pg_tenor::tenor AND quotedate=r.quotedate AND quotesource=r.quotesource
- ORDER BY attach asc;
- END IF;
+ EXIT WHEN r.quotesource != 'CITI' AND flag;
+
+ END LOOP;
+ IF pg_index_type = 'HY' AND pg_series >=15 THEN
+ RETURN QUERY
+ SELECT * FROM tranche_quotes WHERE index=pg_index_type::index_type AND series= pg_series
+ AND tenor=pg_tenor::tenor AND quotedate=r.quotedate AND detach-attach!=5::smallint AND
+ quotesource=r.quotesource ORDER BY attach ASC;
+ ELSE
+ RETURN QUERY
+ SELECT * FROM tranche_quotes WHERE index=pg_index_type::index_type AND series=pg_series
+ AND tenor=pg_tenor::tenor AND quotedate=r.quotedate AND quotesource=r.quotesource
+ ORDER BY attach asc;
END IF;
END;
$$ language plpgsql;
|
