[SQL] loading a file into a field

2009-12-31 Thread Brian Sherwood
I am looking to play around with the postgres XML functions, but can't
seem to find a way to load my data.

I have a number of XML files: file1.xml, file2.xml, etc  All files
follow the same xml format (DTD?)

I would like to create the following table:

CREATE TABLE configs  (
filenamevarchar(80) PRIMARY KEY,
config  xml
);


and load each file into the xml field, but can't seem to find a way.
(I think I need something similiar to lo_import, but have not found anything)

Any help is appreciated.

Thanks

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] Using || operator to fold multiple columns into one

2009-12-31 Thread Rosser Schwarz
On Tue, Dec 29, 2009 at 4:44 PM, Bryce Nesbitt  wrote:

> Craig is correct in the OP attempt.   All but one field is intended to be null

Ah; my misunderstanding, then.  Sorry for the noise.

> Duplicate rows, or data in multiple columns, would wreck havoc on the
> scheme.  If there is a better way, I am all eyes.

One thought would be to add a couple of constraints: a CHECK
constraint to ensure that one and only one of the columns is populated
(think "t_number IS NOT NULL AND t_string IS NULL AND t_boolean IS
NULL AND t_date IS NULL OR..."), and a UNIQUE constraint against
(context_key, t_number, t_string, t_boolean, t_date).  That's not
really a "better" way, but it should prevent both duplicate and
"compound" data.

rls

-- 
:wq

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] Proper case function

2009-12-31 Thread Michael Gould
All,

Has anyone got a proper case function that they are willing to share.  We're
moving from SQL Anywhere to PostgreSQL and decided that much of our data is
upper case when it really should be proper cased.  The columns that we will
be putting proper case data in are all defined using the contrib module
citext which makes searching very nice.

Best Regards

Michael Gould



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] Proper case function

2009-12-31 Thread Gary Chambers
> Has anyone got a proper case function that they are willing to share.  We're
> moving from SQL Anywhere to PostgreSQL and decided that much of our data is
> upper case when it really should be proper cased.  The columns that we will
> be putting proper case data in are all defined using the contrib module
> citext which makes searching very nice.

Why doesn't the initcap function work as you require?

-- Gary Chambers

/* Nothing fancy and nothing Microsoft! */

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] loading a file into a field

2009-12-31 Thread Tim Landscheidt
Brian Sherwood  wrote:

> I am looking to play around with the postgres XML functions, but can't
> seem to find a way to load my data.

> I have a number of XML files: file1.xml, file2.xml, etc  All files
> follow the same xml format (DTD?)

> I would like to create the following table:

> CREATE TABLE configs  (
> filenamevarchar(80) PRIMARY KEY,
> config  xml
> );


> and load each file into the xml field, but can't seem to find a way.
> (I think I need something similiar to lo_import, but have not found anything)

There is no function to do that in the standard distribu-
tion. You have to solve that in your client application.
Theoretically, you could try to do it in a server-side user
function, but permissions, local vs. remote file systems &
Co. usually only create major headaches.

Tim


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] Proper case function

2009-12-31 Thread Michael Gould
Gary,

Based on what I read it wouldn't handle cases where the result should be

MacDonald from macdonald.  There are other cases such as the sentence below

('it''s crazy! i couldn''t believe kate mcdonald, leo dicaprio, (terrence)
trent d''arby (circa the 80''s), and jada pinkett-smith all showed up to
[cHris o''donnell''s] party...donning l''oreal lIpstick! They''re heading to
o''neil''s pub later on t''nite. the_underscore_test. the-hyphen-test)

This wouldn't handle the quotes and proper case all of the words.

Best Regards

Mike Gould


"Gary Chambers"  wrote:
>> Has anyone got a proper case function that they are willing to share.
 We're
>> moving from SQL Anywhere to PostgreSQL and decided that much of our data
is
>> upper case when it really should be proper cased.  The columns that we
will
>> be putting proper case data in are all defined using the contrib module
>> citext which makes searching very nice.
> 
> Why doesn't the initcap function work as you require?
> 
> -- Gary Chambers
> 
> /* Nothing fancy and nothing Microsoft! */
> 
> -- 
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
> 

--
Michael Gould, Managing Partner
Intermodal Software Solutions, LLC
904.226.0978
904.592.5250 fax



-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] Proper case function

2009-12-31 Thread Tim Landscheidt
Michael Gould  wrote:

> Based on what I read it wouldn't handle cases where the result should be

> MacDonald from macdonald.  There are other cases such as the sentence below

> ('it''s crazy! i couldn''t believe kate mcdonald, leo dicaprio, (terrence)
> trent d''arby (circa the 80''s), and jada pinkett-smith all showed up to
> [cHris o''donnell''s] party...donning l''oreal lIpstick! They''re heading to
> o''neil''s pub later on t''nite. the_underscore_test. the-hyphen-test)

> This wouldn't handle the quotes and proper case all of the words.
> [...]

Based on your requirements, you want to hire some cheap Eng-
lish native speaker with lots of cultural knowledge.

Tim


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] Proper case function

2009-12-31 Thread Seth Gordon

Michael Gould wrote:

Gary,

Based on what I read it wouldn't handle cases where the result should be

MacDonald from macdonald.


A function that translates “macdonald” to “MacDonald” would also 
translate “mackintosh” (the raincoat) to “MacKintosh”, unless you write 
it *really really* cleverly.



--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql