Hello-
I'm running postgres 8.0.8 on Gento Linux and have a text field
delimited with tildes that I am splitting using split_part(). Is there
a way to tell how many "parts" I have? For example:

1~22~33 would split into 3 fields
1~2~3~4 would split into 4 fields

In Python I would do:

fields = '1~22~333'.split('~')

and then len(fields) would be 3, so I would know there were 3 fields to
process.

Another way to solve this problem would be to determine the names of
columns in a given table. Is there a way to get that information?

I want this information so I can build insert and update queries on the
fly in my pgplsql functions.

Thanks for your help,
--greg

Search Discussions

  • Davis, Sean \(NIH/NCI\) [E] at Nov 2, 2006 at 8:23 pm
    If you like python, you can use plpython?

    As for the column names in a table, look in the docs under system catalogs and information schema.

    Sean


    -----Original Message-----
    From: Greg Lindstrom
    Sent: Thu 11/2/2006 3:07 PM
    To: pgsql-novice@postgresql.org
    Subject: [NOVICE] Number of fields in split()

    Hello-
    I'm running postgres 8.0.8 on Gento Linux and have a text field
    delimited with tildes that I am splitting using split_part(). Is there
    a way to tell how many "parts" I have? For example:

    1~22~33 would split into 3 fields
    1~2~3~4 would split into 4 fields

    In Python I would do:

    fields = '1~22~333'.split('~')

    and then len(fields) would be 3, so I would know there were 3 fields to
    process.

    Another way to solve this problem would be to determine the names of
    columns in a given table. Is there a way to get that information?

    I want this information so I can build insert and update queries on the
    fly in my pgplsql functions.

    Thanks for your help,
    --greg

    ---------------------------(end of broadcast)---------------------------
    TIP 5: don't forget to increase your free space map settings

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedNov 2, '06 at 8:08p
activeNov 2, '06 at 8:23p
posts2
users2
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase