gluglu
09-03-2005, 18:06:16
Hola Amigos,
Tengo el siguiente 'Stored Procedure':
CREATE PROCEDURE RATES_AMOUNTS_DESCRIPTION
(category_no DECIMAL(7), subcategory_no DECIMAL(7), object_no CHAR(6), building_no DECIMAL(6))
RETURNS
(NAME_SP VARCHAR(40))
AS
BEGIN
If (:object_no <> '') THEN FOR Select NAME from OBJECTS where OBJECTNO = :object_no and BUILDINGNO = :building_no INTO NAME_SP DO SUSPEND;
If (:category_no <> 0 and :subcategory_no <> 0) THEN FOR Select NAME from CATEGORIES where CATEGORYNO = :category_no and SUBCATEGORYNO = :subcategory_no INTO NAME_SP DO SUSPEND;
If (:category_no <> 0 and :subcategory_no = 0) THEN FOR Select NAME from CATEGORIES where CATEGORYNO = :category_no and SUBCATEGORYNO = 0 INTO NAME_SP DO SUSPEND;
END;
Me dá un error si ninguno de los 'Select' encuentra un registro apropiado y guarda su valor en NAME_SP. Llamo a este procedimiento desde un Select de un DBGrid, y si abro el Form y no encuentra ningún registro en el Select del Stored Procedure me da un error y no se abre el Form.
Lo que me gustaría es que devolviera '? ? ? ? ?' en NAME_SP si ninguno de los Select encuentra nada.
Algo así como:
CREATE PROCEDURE RATES_AMOUNTS_DESCRIPTION
(category_no DECIMAL(7), subcategory_no DECIMAL(7), object_no CHAR(6), building_no DECIMAL(6))
RETURNS
(NAME_SP VARCHAR(40))
AS
BEGIN
.....
.....
If (:category_no <> 0 and :subcategory_no = 0) THEN FOR Select NAME from CATEGORIES where CATEGORYNO = :category_no and SUBCATEGORYNO = 0 INTO NAME_SP DO
BEGIN
If (NAME_SP IS NULL) THEN NAME_SP = '? ? ? ? ?';
SUSPEND;
END
END;pero este procedimiento no funciona correctamente. Algo debo de estar haciendo mal, claro.
Gracias por vuestra ayuda.
Tengo el siguiente 'Stored Procedure':
CREATE PROCEDURE RATES_AMOUNTS_DESCRIPTION
(category_no DECIMAL(7), subcategory_no DECIMAL(7), object_no CHAR(6), building_no DECIMAL(6))
RETURNS
(NAME_SP VARCHAR(40))
AS
BEGIN
If (:object_no <> '') THEN FOR Select NAME from OBJECTS where OBJECTNO = :object_no and BUILDINGNO = :building_no INTO NAME_SP DO SUSPEND;
If (:category_no <> 0 and :subcategory_no <> 0) THEN FOR Select NAME from CATEGORIES where CATEGORYNO = :category_no and SUBCATEGORYNO = :subcategory_no INTO NAME_SP DO SUSPEND;
If (:category_no <> 0 and :subcategory_no = 0) THEN FOR Select NAME from CATEGORIES where CATEGORYNO = :category_no and SUBCATEGORYNO = 0 INTO NAME_SP DO SUSPEND;
END;
Me dá un error si ninguno de los 'Select' encuentra un registro apropiado y guarda su valor en NAME_SP. Llamo a este procedimiento desde un Select de un DBGrid, y si abro el Form y no encuentra ningún registro en el Select del Stored Procedure me da un error y no se abre el Form.
Lo que me gustaría es que devolviera '? ? ? ? ?' en NAME_SP si ninguno de los Select encuentra nada.
Algo así como:
CREATE PROCEDURE RATES_AMOUNTS_DESCRIPTION
(category_no DECIMAL(7), subcategory_no DECIMAL(7), object_no CHAR(6), building_no DECIMAL(6))
RETURNS
(NAME_SP VARCHAR(40))
AS
BEGIN
.....
.....
If (:category_no <> 0 and :subcategory_no = 0) THEN FOR Select NAME from CATEGORIES where CATEGORYNO = :category_no and SUBCATEGORYNO = 0 INTO NAME_SP DO
BEGIN
If (NAME_SP IS NULL) THEN NAME_SP = '? ? ? ? ?';
SUSPEND;
END
END;pero este procedimiento no funciona correctamente. Algo debo de estar haciendo mal, claro.
Gracias por vuestra ayuda.