Re: [SQL] Calling plSQL functions

2001-04-11 Thread Josh Berkus
Lonnie, It may be that you have not linked the PL/pgSQL language in Postgres. It may be that you are putting a SELECT statement inside your function. It is hard to tell, becuase I am unclear on the problem youa re having, exactly. Here's some terminology to help clarify: PL/pgSQL is the exten

[SQL] Calling plSQL functions

2001-04-11 Thread Lonnie Cumberland
Hello All, I have created a plSQL function with the "create function ..." which seems to be ok and is just very simple. I then wanted to load the function by: psql -f test.sql -d trdata which loads my function fine. the problem is that I do not know how to call this function from the PLSQL in

[SQL] Timezone conversion

2001-04-11 Thread Roberto Mello
Hi, How can I do timezone conversions in PG? I looked on the docs and couldn't find how. I want to find the current time in another timezone. Thanks, -Roberto P.S: This type of function would be excellent on the cookbook (www.brasileiro.net). -- +| http://f

[SQL] Re: DB porting questions...

2001-04-11 Thread Joel Burton
On Wed, 11 Apr 2001, Diehl, Jeffrey wrote: > Hi all, > > I'm in the final stages of migrating from mysql to postgres and have a few > more questions... > > 1) > I have a table: > create table a ( > t timestamp not null, > ... > ); > > I'm thinking

Re: [SQL] DB porting questions...

2001-04-11 Thread Josh Berkus
Mike, You'll be overjoyed to know that both of your questions have simple answers. > 1) > I have a table: > create table a ( > t timestamp not null, > ... > ); > > I'm thinking that I can define a.t as not null default=now(). But > will this > work? That is, will it update a.t w

RE: [SQL] DB porting questions...

2001-04-11 Thread Michael Ansley
Title: RE: [SQL] DB porting questions... Hi, Jeff,   >>  1) >>  I have a table: >>      create table a ( >>          t   timestamp not null, >>          ... >>      ); >>  >>  I'm thinking that I can define a.t as not null default=now().  But >>  will >>  this >>  work?  That is

[SQL] Re: enumerating rows

2001-04-11 Thread Joel Burton
On Wed, 11 Apr 2001, Kovacs Zoltan wrote: > > Here is a method which is fairly cumbersome, but will do what you want. > > (Whether what you want is useful, is another matter. The row numbers > > have no meaning except to delineate which row is printed after which; they > > bear no relation to th

Re: [SQL] enumerating rows

2001-04-11 Thread Oliver Elphick
Kovacs Zoltan wrote: >> Here is a method which is fairly cumbersome, but will do what you want. >> (Whether what you want is useful, is another matter. The row numbers >> have no meaning except to delineate which row is printed after which; they >> bear no relation to their order in the t

Re: [SQL] enumerating rows

2001-04-11 Thread Josh Berkus
Kovacs, Oliver, First, thank you Oliver for the nice C program for this purpose. If there doesn't turn out to be another method, it shoudl og in the postgresql.org site. However, Postgresql does have an internal row count for query results. Otherwise LIMIT and OFFSET would not w

Re: [SQL] Making SELECT COUNT(seed) FROM fast

2001-04-11 Thread Peter Eisentraut
Gerald Gutierrez writes: > I have a table with about 5 million rows in it. I need to be able to get the > exact number of rows in the table at runtime. So I tried the following: > > xxx=> explain select count(seed) from mytable; > NOTICE: QUERY PLAN: > > Aggregate (cost=103152.27..103152.27 row

[SQL] Making SELECT COUNT(seed) FROM fast

2001-04-11 Thread Gerald Gutierrez
Hi all. I have a table with about 5 million rows in it. I need to be able to get the exact number of rows in the table at runtime. So I tried the following: xxx=> explain select count(seed) from mytable; NOTICE: QUERY PLAN: Aggregate (cost=103152.27..103152.27 rows=1 width=4) -> Seq Scan o

Re: [SQL] enumerating rows

2001-04-11 Thread Kovacs Zoltan
> Here is a method which is fairly cumbersome, but will do what you want. > (Whether what you want is useful, is another matter. The row numbers > have no meaning except to delineate which row is printed after which; they > bear no relation to their order in the table.) Thanks, Oliver! Are you su

Re: [SQL] enumerating rows

2001-04-11 Thread Oliver Elphick
Kovacs Zoltan wrote: >> Use the "serial" column type. >Unfortunately it's not what I expect. Assume that I have an arbitrary >"SELECT expr1 as column1, expr2 as column2, ..." which gives > >column1 | column2 | ... >+-+- ... >..data.. >.

RE: [SQL] enumerating rows

2001-04-11 Thread Koen Antonissen
I was searching for the same thing, I couldn't found it though :( -Original Message- From: Kovacs Zoltan [mailto:[EMAIL PROTECTED]] Sent: woensdag 11 april 2001 16:37 To: Poul L. Christiansen Cc: [EMAIL PROTECTED] Subject: Re: [SQL] enumerating rows > Use the "serial" column type. Unfor

Re: [SQL] enumerating rows

2001-04-11 Thread Kovacs Zoltan
> Use the "serial" column type. Unfortunately it's not what I expect. Assume that I have an arbitrary "SELECT expr1 as column1, expr2 as column2, ..." which gives column1 | column2 | ... +-+- ... ..data.. I would like to get the same res

Re: [SQL] Re: \i command

2001-04-11 Thread cbell
I don't know if you've resolved your problem, but if not, you could try deleting and recreating the indexes on the table... Najm Hashmi wrote: > Joel Burton wrote: > > > On Wed, 11 Apr 2001, Najm Hashmi wrote: > > > > > Hi All, > > > From pgsql, I try to insert data in table using the \i com

Re: [SQL] enumerating rows

2001-04-11 Thread Poul L. Christiansen
Use the "serial" column type. create table myTable (row_no serial,column1 varchar(10),column2 varchar(20)); HTH, Poul L. Christiansen On Wed, 11 Apr 2001, Kovacs Zoltan wrote: > Maybe a trivial question, maybe it's foreign from SQL, I'dont know... > How to add a column which stands for the row

[SQL] enumerating rows

2001-04-11 Thread Kovacs Zoltan
Maybe a trivial question, maybe it's foreign from SQL, I'dont know... How to add a column which stands for the row number in each row of the result? E.g.: row_no | column1 | column2 | ... ---+-+-+ ... 1 | datum11 | datum12 | ... 2 | datum21 | datum22 | ... ... |

Re: [SQL] Concatenate fields

2001-04-11 Thread Oliver Elphick
Amanda Riera wrote: >I would like concatenate some fields to have all information in just >one field. I'm doing this below: > >CREATE TABLE bill_2col AS >SELECT bill.bill_id, > (trim(text(bill.bill_number)) || ' | ' || > trim(text(provider.company)) || ' | ' || > trim(to_char(bi

Re: [SQL] problem with copy command

2001-04-11 Thread Oliver Elphick
Here is a method of filtering out the duplicate keys from the input file: Let us assume that the input data is in /tmp/table.in, that that file is tab-delimited and that the primary key is in field 2. psql -d database -c "COPY table TO '/tmp/table.1'" psql -d database -c "COPY table TO '

[SQL] Concatenate fields

2001-04-11 Thread Amanda Riera
Hi all, using PgSQL 7.0.3 I would like concatenate some fields to have all information in just one field. I'm doing this below: CREATE TABLE bill_2col AS SELECT bill.bill_id, (trim(text(bill.bill_number)) || ' | ' || trim(text(provider.company)) || ' | ' || trim(to_char(bill.issue_date,'M

Re: [SQL] problem with copy command

2001-04-11 Thread George Moga
Jaruwan Laongmal wrote: > dear all, > I currently using postgresql v7.0.3 > when i import text file to table with command "copy tablename from > '/tmp/a.txt'; > and it shows > "copy: line 20, Cannot insert a duplicate key into unique index testpri_pk" > ,then it exits with doing nothing. > > I wa

Re: [SQL] Foreign Key between different databases

2001-04-11 Thread Cedar Cox
AFAIK, not easily. There was a post to the hackers list recently with code for a "database connector" function. Using this it may be possible to write your own referential integrity triggers that reference the other database.. maybe not. I didn't look much into the code. There might be someth