Re: Problem inserting data

From: Tk421 <vrobador(at)gmail(dot)com>
To: Adrian Klaver <aklaver(at)comcast(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem inserting data
Date: 2008-06-20 15:55:30
Message-ID: 485BD2F2.2040204@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Adrian Klaver escribi&oacute;:
<blockquote cite="mid:200806200740(dot)46335(dot)aklaver(at)comcast(dot)net"
type="cite">
<pre wrap="">On Friday 20 June 2008 5:20 am, Tk421 wrote:
</pre>
<blockquote type="cite">
<pre wrap=""> Hello everybody.

I''ve just converted an access database to postgres. The conversion
was ok, but when i'm trying to insert data on some tables with boolean
types from a Visual Basic application i receive an error. A sample:

table example, with firs field of integer, second of type text and
third of type boolean

the query: INSERT INTO EXAMPLE VALUES (1, 'text', 0)

When i used access this worked fine, in boolean types 0 is false and
1 is true, but in postgres (8.1 and 8.3 version) i receive the next error:

column "premarco" is of type boolean but expression is of type integer

My question is, can i force postgres to accept integer values as
boolean without changin query to INSERT INTO EXAMPLE VALUES (1, 'text',
0::boolean). This is a problem because if I have to do this i will have
to test about one hundred queryes

Thank you very much
</pre>
</blockquote>
<pre wrap=""><!---->
Two options:
1) Change the column in Postgres to an integer type.
2) Change the assignment in pg_cast from explicit to implied for the
int4,bool cast. See for more details:
<a class="moz-txt-link-freetext" href="http://www.postgresql.org/docs/8.3/interactive/catalog-pg-cast.html">http://www.postgresql.org/docs/8.3/interactive/catalog-pg-cast.html</a>
</pre>
</blockquote>
&nbsp;&nbsp;&nbsp; Thank you very much. I've choosen the second option, using this
query:<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; update pg_cast set castcontext='i' where castsource=23 and
casttarget=16<br>
<br>
<br>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 1.9 KB

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2008-06-20 16:22:23 Re: "TZ"/"tz" not supported
Previous Message Tom Lane 2008-06-20 14:57:26 Re: Problem inserting data