CREATE OR REPLACE FUNCTION sgc_m_doc_base_buscar(tipo bpchar)
RETURNS SETOF refcursor AS '
DECLARE
BEGIN
IF $1=''NEN'' THEN
OPEN nota FOR SELECT * FROM alma_m_nota_ing;
RETURN NEXT;
ELSE
OPEN notasal FOR SELECT * FROM alm_m_nota_salida;
RETURN NEXT;
END IF;
RETURN;
END;
'
LANGUAGE 'plpgsql' VOLATILE;