Re: DB insert Error

From: "Jasbinder Bali" <jsbali(at)gmail(dot)com>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: DB insert Error
Date: 2006-08-16 05:20:08
Message-ID: a47902760608152220m45eda9ccl41af709070c1fffb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

This is how the array is formed in my C code
-------------------------------------------------------------------------------------------
FILE *fp;

while(!feof(fp))
{ch[i]=fgetc(fp);
if(ch[i]=='\n') lines++; i++; }
ch[i-1]='\0';
fclose(fp);
------------------------------------------------------------------------------
and then am inserting ch as a whole in the varchar column in the database.

Do you want me to append a leading '{' and a trailing '}' to ch??

~Jas

On 8/16/06, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
>
> On Wed, Aug 16, 2006 at 12:38:42AM -0400, Jasbinder Bali wrote:
> > table definition of raw_email table is as follows
> >
> > CREATE TABLE raw_email (
> > id int4 NOT NULL,
> > raw_email varchar[],
> > parsed_flag bool NOT NULL DEFAULT false,
> > CONSTRAINT pk_rawemail PRIMARY KEY (id)
> > )
> > WITHOUT OIDS;
> >
> > i have very much declared raw_email field as varchar and not char
>
> It's not the varchar-vs-char distinction that matters; it's the
> fact that raw_email is declared as array, so it expects a certain
> input syntax. Example:
>
> test=> INSERT INTO raw_email (id, raw_email) VALUES (1, 'test');
> ERROR: array value must start with "{" or dimension information
> test=> INSERT INTO raw_email (id, raw_email) VALUES (1, '{test}');
> INSERT 0 1
>
> Are you sure you want raw_email to be an array instead of a simple
> varchar column? Are you handling the contents as array elements
> (e.g., one element per line) or is the whole considered a single
> piece of data?
>
> --
> Michael Fuhr
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Harpreet Dhaliwal 2006-08-16 05:35:47 Trigger (Calling a Procedure)
Previous Message Michael Fuhr 2006-08-16 05:07:31 Re: how to use variable for select query in pl/pgsql

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Fuhr 2006-08-16 05:38:02 Re: DB insert Error
Previous Message operationsengineer1 2006-08-16 05:06:35 Re: Optimal Postgres Development Process, Software