populating arrays with default values

From: "G(dot) J(dot) Walsh" <gjwalsh(at)dscdirectionalservices(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: populating arrays with default values
Date: 2007-11-14 20:09:37
Message-ID: 1195070977.17701.20.camel@www.dscdirectionalservices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I come from a long background with C and isam. Moving into php and
postgresql is therefore not all that strange, but I suffer with the
comparative lack of structure at times.

I deal with a lot of psych scoring and am establishing tables which will
contain the response patterns for each individual test within a battery.
In defining this, I plan on something like: ans CHAR(1) ARRAY[192]

But I learned that PostgreSQL does not 'enforce' this. I would rather
have an '?' placed in each of the 192 array elements (and thereby
constrain with NOT NULL) to indicate lack of a response (the default)
when the test records are first established for the client.

Because the client does not need to complete a test at one sitting, but
must do so before tackling another test in his or her battery, I need to
'see' where things stand test by test at each login.

I can certainly write php script to fill the array as each record is
established - clumsy the first time around, but pretty efficient after
that - just an include function. There is apparently no other way of
defining (inserting) a default value for array elements.

Am I correct in my approach to this?

Thanks for any insight .....

George

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Rodrigo De León 2007-11-14 21:16:49 Re: array indizes in SQL
Previous Message Michael Glaesemann 2007-11-14 12:28:07 Re: Precision of time types