Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

328
Vistas
Postgresql: prueba de tipos de REGISTRO (para campos o nulo)

Tengo problemas con los tipos plpgsql y RECORD.

¿Alguien sabe de una manera de simplemente probar un tipo de REGISTRO devuelto para saber si se configuró o no?

Patrón básico:

Una función devuelve un REGISTRO y puede desactivarse (es decir, seleccionar si no se devolvieron registros) o establecerse en un único registro.

 create or replace function blah() returns RECORD as $$ declare rec RECORD; begin rec := row(null); --Do not want to hear about it not being assigned select *, status_field into rec ... ; if found then raise notice '%', rec.status_field is not null --prints 't' end if if not found then raise notice '%', rec.status_field is not null --Throws Error (I just want it to say 'f' end if; end; $$ create or replace function callblah() returns text as $$ declare rtText text; blahRec RECORD; begin blahRed := blah(...); -- what test can I do to determine if record is set or not. -- Try: if blah is not null then -- nope always returns false for is null and is not null -- Try: if blah.status is not null then -- nope throws error on field not existing -- What test condition do I need to add here to simply test if record is either (NOT FOUND) or (FOUND where field will exist). ... end if end; $$
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Ah ... es un operador nulo en RECORD is (todos los campos son nulos) y not es nulo (todos los campos no son nulos). Como tengo algunos campos nulos que necesito hacer

 if blah is null then -- No record found else if blah.status is not null then -- Record found with field I want end if; end if;
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda