assign null value to a field in plpgsql
От | David Monarchi |
---|---|
Тема | assign null value to a field in plpgsql |
Дата | |
Msg-id | eea51fdb0706011105u7c6216c2kecb3336659842085@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: assign null value to a field in plpgsql
|
Список | 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
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
В списке pgsql-novice по дате отправления: