Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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 .....



pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group