src-db/database/model/functions/M_RESERVATION_POST.xml
changeset 20972 3f5e8c7117d6
parent 20942 73deee3c38d5
child 21157 2e9ce78cf1e3
--- a/src-db/database/model/functions/M_RESERVATION_POST.xml	Mon Aug 12 10:36:36 2013 +0200
+++ b/src-db/database/model/functions/M_RESERVATION_POST.xml	Mon Aug 12 11:13:35 2013 +0200
@@ -87,11 +87,18 @@
   FROM m_reservation
   WHERE m_reservation_id = v_reservation_id;
   
-  SELECT count(*), max(p.name) INTO v_count, v_productname
-  FROM m_product p 
-  WHERE p.m_product_id = v_product_id
-    AND COALESCE(p.isgeneric, 'N') = 'Y';
+  SELECT count(*) INTO v_count
+  FROM dual
+  WHERE EXISTS (
+      SELECT 1
+      FROM m_product p 
+      WHERE p.m_product_id = v_product_id
+        AND p.isgeneric = 'Y');
   IF (v_count > 0) THEN
+    SELECT max(p.name) INTO v_productname
+    FROM m_product p 
+    WHERE p.m_product_id = v_product_id
+      AND p.isgeneric = 'Y';
     RAISE_APPLICATION_ERROR(-20000, '@CannotUseGenericProduct@ ' || v_productName);
   END IF;