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

Number of fields in split()

From: Greg Lindstrom <greg(dot)lindstrom(at)novasyshealth(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Number of fields in split()
Date: 2006-11-02 20:07:59
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
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 

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,


pgsql-novice by date

Next:From: Davis, Sean (NIH/NCI) [E]Date: 2006-11-02 20:16:04
Subject: Re: Insert Question
Previous:From: operationsengineer1Date: 2006-11-02 20:01:51
Subject: Insert Question

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