assign null value to a field in plpgsql

From: "David Monarchi" <david(dot)e(dot)monarchi(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: assign null value to a field in plpgsql
Date: 2007-06-01 18:05:40
Message-ID: eea51fdb0706011105u7c6216c2kecb3336659842085@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello -

I'm using PG 8.2.

I have some code of the form

domain2Row domain2_dom%ROWTYPE;
adServerLoadRow domain2_dom%ROWTYPE;
...
SELECT * INTO domain2Row FROM domain2_dom WHERE domain_name_dom =
quote_literal(domainName);
adServerLoadRow = domain2Row;

I want to go through a series of checks to see if I should set a field to
null in the adServerLoadRow. I will not know in advance which fields I will
need to check nor their data types.

Assuming I have identified field X as one which I want to set to null, I
want to be able to perform the following assignment;

adServerLoadRow.X = NULL;

However, I can't seem to do this. I thought about just declaring a variable
and not assigning anything to it, so it would be null. Then I could do the
following

adServerLoadRow.X = aNullVariable;

The problem is that I won't know in advance whether the field is numeric or
text, so I won't know which null variable to use.

I'm constrained to use plpgsql, so alternate language solutions won't help
me.

Any suggestions would be greatly appreciated.

david

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2007-06-01 18:22:45 Re: assign null value to a field in plpgsql
Previous Message psql-novice 2007-06-01 09:49:47 Re: STABLE has no effect on PL/pgsql functions