Re: [GENERAL] question about default value and timestamp

2006-07-25 Thread A. Kretschmer
am 26.07.2006, um 7:26:09 +0200 mailte Christian Rengstl folgendes: > Hi list, > > i have a table with a column where the default value is > current_timestamp, but somehow all the tuples (around 8.000.000) have > the same timestamp, which is, honestly speaking, not what i intended > to do. So is

[GENERAL] question about default value and timestamp

2006-07-25 Thread Christian Rengstl
Hi list, i have a table with a column where the default value is current_timestamp, but somehow all the tuples (around 8.000.000) have the same timestamp, which is, honestly speaking, not what i intended to do. So is the current_timestamp function only executed when the insert statement starts?

Re: [GENERAL] Executing an SQL query from an internal function...

2006-07-25 Thread Alvaro Herrera
Redefined Horizons wrote: > If I am implementing an internal function in PostgreSQL with the C > programming language, can I use one of the C API's to execute a query > from within the function? Is there another way to execute an SQL query > from within an internal function implemented in C? The S

Re: [GENERAL] Mapping/DB Migration tool

2006-07-25 Thread Reece Hart
On Tue, 2006-07-25 at 17:21 -0500, MC Moisei wrote: The main thing is I changed a bunch of date types to timestamp type. Is there a simple way to change the type on such fields ? Yes, and more generally to change the type of a column. See below: [EMAIL PROTECTED]> create table t

[GENERAL] Executing an SQL query from an internal function...

2006-07-25 Thread Redefined Horizons
If I am implementing an internal function in PostgreSQL with the C programming language, can I use one of the C API's to execute a query from within the function? Is there another way to execute an SQL query from within an internal function implemented in C? Thanks, Scott Huey -

Re: [GENERAL] Mapping/DB Migration tool

2006-07-25 Thread MC Moisei
The main thing is I changed a bunch of date types to timestamp type. Is there a simple way to change the type on such fields ? Some fields got renamed and the type changed. It sounds like doing a copy|template of db1 as db2 and then applying the new changes as a script that will probably wo

Re: [GENERAL] Mapping/DB Migration tool

2006-07-25 Thread Reece Hart
On Tue, 2006-07-25 at 13:59 -0500, MC Moisei wrote: I'm looking to migrate psql db1 to a psql db2 that has a different structure even though 70% would be the same. Depending on how much the structure changes (as opposed to more trivial things like column names), you might consider

Re: [GENERAL] ECPG usage

2006-07-25 Thread Michael Meskes
>while(1) >{ >EXEC SQL FETCH IN c_movie INTO :movie_title; > printf("%s\n",movie_title); > movie_title = NULL; >} > > free (movie_title); As a side note, you should free movie_title each time, not just set it to NULL if you us

Re: [GENERAL] Mapping/DB Migration tool

2006-07-25 Thread John DeSoi
On Jul 25, 2006, at 2:59 PM, MC Moisei wrote: I'm looking to migrate psql db1 to a psql db2 that has a different structure even though 70% would be the same. I'd need a tool that allows me to map field to field and then migrate the data from one db to another. Needless to say that preservi

Re: [GENERAL] Mapping/DB Migration tool

2006-07-25 Thread Pavel Golub
Hello, MC. Only human can do this. Moreover, if "data integrity is very important". Regards You wrote: MM> Hi, MM> I'm looking to migrate psql db1 to a psql db2 that has a different structure MM> even though 70% would be the same. I'd need a tool that allows me to map MM> field to field and th

Re: [GENERAL] Using currval() in an insert statement...

2006-07-25 Thread Shoaib Mir
Try it out the following way:create table test (var1 int);create sequence s1;select s1.nextval;insert into test values (s1.currval);select * from test;Thanks,Shoaib Mir EnterpriseDB (www.enterprisedb.com)On 7/25/06, Redefined Horizons < [EMAIL PROTECTED]> wrote:I'm having trouble figuring out how t

[GENERAL] Mapping/DB Migration tool

2006-07-25 Thread MC Moisei
Hi, I'm looking to migrate psql db1 to a psql db2 that has a different structure even though 70% would be the same. I'd need a tool that allows me to map field to field and then migrate the data from one db to another. Needless to say that preserving data integrity is very important. Any goo

Re: [GENERAL] Using currval() in an insert statement...

2006-07-25 Thread Brad Nicholson
On Tue, 2006-07-25 at 10:45 -0700, Redefined Horizons wrote: > I'm having trouble figuring out how to use the currval() function for > sequences in an INSERT statement. I did some searching online, but > couldn't find what I was looking for. > > I have two Schemas in my Database: > > metadata > g

Re: [GENERAL] ECPG. Badly stuck

2006-07-25 Thread Jasbinder Bali
Hi ,Forget about cursors. Singleton queries are also not working.Tried writing the follwoing code but doesn't give me any result. Don't know if i have to do somethin else apart from what i've already done. include EXEC SQL INCLUDE sqlca;int main (){    EXEC SQL BEGIN DECLARE SECTION;   

Re: [GENERAL] Plperl return_next and bytea binary data?

2006-07-25 Thread Philippe Lang
Alvaro Herrera wrote: > Philippe Lang wrote: > >> Juste one more question: what is the maximum size of a TEXT column in >> PG 8.1.4? > > A handful of bytes less than 1 GB. It should be ok then... :) --- Philippe Lang Attik System smime.p7s Description: S/MIME cryptographic signa

Re: [GENERAL] Does a GRANT on a table cascade/implied to its SEQUENCES

2006-07-25 Thread Roderick A. Anderson
Tom Lane wrote: "Roderick A. Anderson" <[EMAIL PROTECTED]> writes: I've add a new user and as I go though granting various accesses to the different tables I realized many of those tables have primary keys that are generated by a sequence. Do I need to grant access on the sequences and what

Re: [GENERAL] Plperl return_next and bytea binary data?

2006-07-25 Thread Alvaro Herrera
Philippe Lang wrote: > Juste one more question: what is the maximum size of a TEXT column in > PG 8.1.4? A handful of bytes less than 1 GB. -- Alvaro Herrerahttp://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc. ---(e

Re: [GENERAL] Splitting Timestamps

2006-07-25 Thread Chris Browne
[EMAIL PROTECTED] ("Chris Hoover") writes: > I have several columns in my database that are timestamps.  My > developers are asking me how to split the timestamp so that they can > look at either the date or at the time portion. I know I can do a > select to_date(now(),'-mm-dd') and it will re

Re: [GENERAL] Splitting Timestamps

2006-07-25 Thread Reece Hart
On Tue, 2006-07-25 at 12:54 -0400, Chris Hoover wrote: > I know I can do a select to_date(now(),'-mm-dd') and it will > return the date. However, how do I get the time? Casting is the better option, but the to_date format spec handles a lot more than just dates. See: http://www.postgresql.

Re: [GENERAL] gmake Errors: pg_backup_archiver.c: undefined reference

2006-07-25 Thread Emi Lu
I did make distclean, and I retried "configuration and ", but I still saw the following errors: The only other theory I can think of is that the linker is picking up an old libpq.so from /home/postgresql/lib because of the -rpath switch ... which it should not be doing, but maybe it is an

Re: [GENERAL] Plperl return_next and bytea binary data?

2006-07-25 Thread Philippe Lang
[EMAIL PROTECTED] wrote: > Martijn van Oosterhout wrote: > >> On Mon, Jul 24, 2006 at 11:43:39AM +0200, Philippe Lang wrote: >>> The problem seems to come from the return_next, in conjunction with >>> binary data: >>> >>> >>> return_next >>> ( >>>

[GENERAL] Using currval() in an insert statement...

2006-07-25 Thread Redefined Horizons
I'm having trouble figuring out how to use the currval() function for sequences in an INSERT statement. I did some searching online, but couldn't find what I was looking for. I have two Schemas in my Database: metadata geometry I have a table named "metadata_geometries" in the metadata schema.

Re: [GENERAL] CASE statement and SETOF values

2006-07-25 Thread Christian Schoenebeck
Am Dienstag, 25. Juli 2006 17:56 schrieben Sie: > You could use a procedural language like plpgsql. Ok, using the plpgsql approach I tried this: CREATE FUNCTION my_function(int4) RETURNS SETOF int8 AS $BODY$ DECLARE myrow RECORD; BEGIN IF (some_condition) THEN FOR myrow IN SEL

Re: [GENERAL] Splitting Timestamps

2006-07-25 Thread Curtis Scheer
I believe you would want to cast the field to a date like so select datefield::datefrom table1 or select datefield::time from table1.   From: Chris Hoover [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 25, 2006 11:55 AM To: pgsql-general@postgresql.org Subject: [GENERAL] Splitting

Re: [GENERAL] Splitting Timestamps

2006-07-25 Thread A. Kretschmer
am 25.07.2006, um 12:54:35 -0400 mailte Chris Hoover folgendes: > I have several columns in my database that are timestamps. My developers > are asking me how to split the timestamp so that they can look at either > the > date or at the time portion. The CAST-Operater is your friend: est=# sel

Re: [GENERAL] Splitting Timestamps

2006-07-25 Thread Alvaro Herrera
Chris Hoover wrote: > I have several columns in my database that are timestamps. My developers > are asking me how to split the timestamp so that they can look at either the > date or at the time portion. > > I know I can do a select to_date(now(),'-mm-dd') and it will return the > date. How

[GENERAL] Splitting Timestamps

2006-07-25 Thread Chris Hoover
I have several columns in my database that are timestamps.  My developers are asking me how to split the timestamp so that they can look at either the date or at the time portion.I know I can do a select to_date(now(),'-mm-dd') and it will return the date.  However, how do I get the time?  Also

Re: [GENERAL] CASE statement and SETOF values

2006-07-25 Thread Stephan Szabo
On Tue, 25 Jul 2006, Christian Schoenebeck wrote: > Am Dienstag, 25. Juli 2006 00:01 schrieb Stephan Szabo: > > The above basically looks like: > > CASE WHEN THEN ELSE > > END. > > > > In SQL92 at least, the form of which looks like (SELECT > > ...) is which is limited to 1 column and 1 row.

Re: [GENERAL] Lock changes with 8.1 - what's the right lock?

2006-07-25 Thread Wes
> Unless I'm misunderstanding you or a bug was fixed between 7.4.5 > and 7.4.13 (the version I'm running), I'm not convinced that last > statement is true. EXCLUSIVE conflicts with all lock types except > ACCESS SHARE; foreign key references prior to 8.1 use SELECT FOR > UPDATE and in 8.1 they use

Re: [GENERAL] sequences vs oids as primary keys

2006-07-25 Thread Kenneth Downs
craigp wrote: 1) does it make sense (and would it be possible) to make a rule which would, say, somehow write into the oid field of a tuple to be returned by lastoid? i'm assuming here that the database would not have oid's enabled. We do this in a trigger. We assign the NEXTVAL to a variab

Re: [GENERAL] gmake Errors: pg_backup_archiver.c: undefined reference to `lo_create'

2006-07-25 Thread Tom Lane
Emi Lu <[EMAIL PROTECTED]> writes: > I did make distclean, and I retried "configuration and ", but I still > saw the following errors: The only other theory I can think of is that the linker is picking up an old libpq.so from /home/postgresql/lib because of the -rpath switch ... which it should n

Re: [GENERAL] Lock changes with 8.1 - what's the right lock?

2006-07-25 Thread Michael Fuhr
On Tue, Jul 25, 2006 at 07:12:28AM -0500, Wes wrote: > > Unless I'm misunderstanding you or a bug was fixed between 7.4.5 > > and 7.4.13 (the version I'm running), I'm not convinced that last > > statement is true. EXCLUSIVE conflicts with all lock types except > > ACCESS SHARE; foreign key refere

Re: [GENERAL] Archiving wal files

2006-07-25 Thread Alvaro Herrera
Christian Rengstl wrote: > Hi list, > > somehow it seems that in my pg_xlog directory not all wal files are > deleted after copying them to the archive directory even though the > archive_status is done for all of them. Is it safe to delete them > after they were copied or is it safe to use 'mv'

Re: [GENERAL] CASE statement and SETOF values

2006-07-25 Thread Christian Schoenebeck
Am Dienstag, 25. Juli 2006 00:01 schrieb Stephan Szabo: > The above basically looks like: > CASE WHEN THEN ELSE > END. > > In SQL92 at least, the form of which looks like (SELECT > ...) is which is limited to 1 column and 1 row. The > other subquery forms don't look legal in that position unl

Re: [GENERAL] Lock changes with 8.1 - what's the right lock?

2006-07-25 Thread Wes
> Did you try the example I posted? What happens if you do the > following? First set up a couple of tables: I no longer have 7.4 running. I'll have to check and see if can test. > Is it possible that your foreign key constraints are DEFERRED in > 7.4 but not in 8.1? That would change transac

Re: [GENERAL] Beginner's questions about creating a custom data type in PostgreSQL...

2006-07-25 Thread Merlin Moncure
On 7/25/06, Redefined Horizons <[EMAIL PROTECTED]> wrote: Merlin, I am actually working on a spatial extension for PostgreSQL that is similar to PostGIS, but compatible with a geometry library I am developing. I had first thought of using a "table" only desgin, with no custom data types, to stor

[GENERAL] Archiving wal files

2006-07-25 Thread Christian Rengstl
Hi list, somehow it seems that in my pg_xlog directory not all wal files are deleted after copying them to the archive directory even though the archive_status is done for all of them. Is it safe to delete them after they were copied or is it safe to use 'mv' as archive_command? Thanks! -- Ch

[GENERAL] error code when database does not exist

2006-07-25 Thread surabhi.ahuja
Title: [JDBC] Invalid column display size. Cannot be less than zero   i want to know what error code will be returned if the database does not exist.   i have the following list, howvere do not know which one shall be returned when database itself does not exits   http://www.postgresql.org/

Re: [GENERAL] What about pgtclsh

2006-07-25 Thread Ian Harding
It's here now. I think it used to be in the main distro, but has been moved out recently. http://pgfoundry.org/projects/pgtcl/ On 24 Jul 2006 03:07:59 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hello everybody, I must replace an old server by a new one, and I decide to upgrade postgr

Re: [GENERAL] sequences vs oids as primary keys

2006-07-25 Thread Richard Huxton
craigp wrote: i had some questions/thoughts on using sequences vs oids as pks... it's a common requirement to obtain the last value of a sequence after an insert. most other databases support such a feature, but since oid's are deprecated, and only oid's are returned, this isn't supported by post