Re: [SQL] Delete Trigger Issue

2001-08-06 Thread Stephan Szabo
On Tue, 7 Aug 2001, Sundararajan wrote: > I am developing a db application in postgresql and i need to write a delete > trigger on one of the tables. > > I need a delete trigger on the table 1, so that if I delete a row from table > 1 , the corresponding rows from table 2 should also be deleted.

RE: [SQL] Delete Trigger Issue

2001-08-06 Thread Robby Slaughter
Let me make sure I get this right: CREATE TABLE table1 ( field1 varchar(64), ... ); CREATE TABLE table2 ( field2 varchar(64), ... ); and you want that whenever a row is deleted from table1 you want the SAME row to be deleted from table2? here's what you want. First, a trigger: CREATE

[SQL] Delete Trigger Issue

2001-08-06 Thread Sundararajan
I am developing a db application in postgresql and i need to write a delete trigger on one of the tables. the environment is table1 field1 varchar(64) other fields. table 2. field1 varchar(64) other fields I need a delete trigger on the table 1, so that if I delete a row from table 1 , the c

Re: [SQL] Delete coloumn

2001-08-06 Thread Grant
My response was incorrect! That's what you get for using phppgadmin all day everyday. A transparent feeling that there is alter table drop column support in postgresql :) Sorry. > > Please send to me how to delete coloumn in SQL. > > Thank's > > http://www.ca.postgresql.org/users-lounge/docs/7.1

RE: [SQL] Delete coloumn

2001-08-06 Thread Robby Slaughter
Unfortunately, there's no easy way to delete a column in a table in PostgreSQL. The standard SQL syntax is: ALTER TABLE tablename DROP COLUMN columnname; But I repeat, this is NOT supported in postgresql. If you really need to delete a column you can always just create a new table with an id

Re: [SQL] Delete coloumn

2001-08-06 Thread Grant
> Please send to me how to delete coloumn in SQL. > Thank's http://www.ca.postgresql.org/users-lounge/docs/7.1/reference/ Bookmark the above URL. ALTER TABLE is what you are looking for: http://www.ca.postgresql.org/users-lounge/docs/7.1/reference/sql-altertable.html

[SQL] Delete coloumn

2001-08-06 Thread Suhadi
Please send to me how to delete coloumn in SQL. Thank's ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Simple Insert Problem

2001-08-06 Thread Josh Berkus
Gonzo, > F*** you and the high horse you rode in on. Please restrain yourself from posting strong language to the list. If you want to use stong language at me, please e-mail it directly. Further, I e-mailed an apology for touching a nerve, but you appear to have supplied an invalid reply-to

RE: [SQL] Simple Insert Problem

2001-08-06 Thread GonzoRock
Josh, Fuck you and the high horse you rode in on. Yes as a matter of fact I did forget the quote marks. Do you think reading that book will help with my silly syntactical errors? Do you think I did not pull my hair out prior to posting? Sometimes the obvious just eludes the smartest of us. Per

RE: [SQL] Simple Insert Problem

2001-08-06 Thread Robby Slaughter
Gonzo: You need to make sure that you delimit your values correctly. To insert text fields (which may contain spaces) use 'single quotes'. You'll also want to enter date fields the same way. So, you should try INSERT INTO OP (op_num,op_name,start_time) VALUES (5400,'Welding','06:00:00'); Of c

Re: [SQL] Simple Insert Problem

2001-08-06 Thread Josh Berkus
Gonzo, > Sorry but this is making me crazy... yes... I'm way new to SQL Buy PostgreSQL: Introduction and Concepts. Now. Read it cover to cover before posting any more questions, ok? > Why would this error out ?? > > This is the Query... > INSERT INTO OP (op_num,op_name,start_time) Values >

[SQL] Simple Insert Problem

2001-08-06 Thread Gonzo Rock
Sorry but this is making me crazy... yes... I'm way new to SQL Why would this error out ?? This is the Query... INSERT INTO OP (op_num,op_name,start_time) Values (5400,Welding,06:00:00); And this is the pgSQL error... ERROR: parser: parse error at or near ":" The table has reasonable valu

Re: [SQL] views and null bothering

2001-08-06 Thread Josh Berkus
Martin, > I have a bunch of tables which I give access through a view. The > problem is > that in the main table there are columns, that are referenced to > another > tables column, that have NULLs. > In the SELECT inside the view's definition I put the join equality, > but have > lots of trou

[SQL] views and null bothering

2001-08-06 Thread Martín Marqués
I have a bunch of tables which I give access through a view. The problem is that in the main table there are columns, that are referenced to another tables column, that have NULLs. In the SELECT inside the view's definition I put the join equality, but have lots of trouble makeing it put correc

[SQL] [warning: largely off-topic] Re: Data type confusion

2001-08-06 Thread Allan Engelhardt
Josh, Thanks for your explanation. I'd like to get hold of a copy of SQL99/PKG001 to see what they have actually defined. I think the INTERVAL type sux :-) Long rant follows - consider hitting the delete button now. In this area, there are a number of different concepts that it would make

[SQL] Re: [warning: largely off-topic] Re: Data type confusion

2001-08-06 Thread Josh Berkus
Allan, > Thanks for your explanation. I'd like to get hold of a copy of > SQL99/PKG001 to see what they have actually defined. Tom posted a section of this. > I think the INTERVAL type sux :-) Long rant follows - consider > hitting the delete button now. Au contraire. I replying to the list

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Josh Berkus
Tom, > > Hmmm ... does this mean that I couldn't divide '1 year' by '1 > week'? > > That's exactly what it says. If that's the case, we'd need to create some sort of function to specify the time unit to output timestamp operation into: to_weeks(current_timestamp - hire_date) / '2 weeks' ... o

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > Hmmm ... does this mean that I couldn't divide '1 year' by '1 week'? That's exactly what it says. regards, tom lane ---(end of broadcast)--- TIP 3: if posting/reading through Usen

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Josh Berkus
Tom, > Curiously enough, ANSI doesn't define an INTERVAL-divided-by-INTERVAL > function either. Also, it rather looks like ANSI adopted the > position > Peter E. expressed: > > Year-month intervals are mutually comparable only with other > year- > month intervals. [...] >

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > I don't want to go through a bunch of non-ANSI SQL-compliant conversion > functions to do it. Especially not as this is just what the ANSI SQL > data type and operator specs are designed to support. Curiously enough, ANSI doesn't define an INTERVAL-div

Re: [SQL] prob with PERL/Postgres

2001-08-06 Thread Tom Lane
Thomas Good <[EMAIL PROTECTED]> writes: > Kate, he uses a diff module by the same author (Edmund Mergl) but with > a very diff syntax. The advantage of the DBI - Kris, if you're > interested - is that the syntax is much like ESQL/C and the code is > much more portable. For example I use DBI to a

[SQL] Re: prob with PERL/Postgres

2001-08-06 Thread Allan Engelhardt
1. I'm assuming that psql works fine? psql -h 127.0.0.1 mpact? 1b. Have you checked the port?? You ARE running postmaster with the '-i' option, aren't you? The recommended solutions are typically to use the DBI and DBD modules. Try man DBD::Pg. Alternatively: have you tried the setdbLogin

Re: [SQL] prob with PERL/Postgres

2001-08-06 Thread Thomas Good
On Mon, 6 Aug 2001, Kate Collins wrote: > I use the Perl DBI module to connect to a postgres data base on the local > system. I don't specify the host name. This is the syntax I use to connect to > the data base: > > use DBI; > > $dbname = "foo"; > $connstr = "dbi:Pg:dbname=$dbname"; > $dbh =

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Josh Berkus
Allan, > I see now what you are trying to do. It sort of makes sense, but I'm > still really reluctant to give (semantic or otherwise) meaning to > "yesterday divided by tomorrow" . I don't agree. Consider, for example, this statement: '30 weeks ago'::INTERVAL / '2 weeks'::INTERVAL = -15

Re: [SQL] prob with PERL/Postgres

2001-08-06 Thread clayton
Kristopher Yates wrote: >PERL SNIPPET: > ># build arrays from file (OMITTED) > >use Pg; >$dbhost='127.0.0.1'; >$dbname='mpact'; >#$connstr="dbname=$dbname"; >$connstr="host=$dbhost dbname=$dbname"; >$conn = Pg::connectdb($connstr); > >#more code related to date omitted > >$result=$conn->exec(

[SQL] Re: Data type confusion

2001-08-06 Thread Allan Engelhardt
Josh Berkus wrote: > Or, to put it another way, 95% of the time users just want to do simple > things. Like we want to know how many weeks an employee has been with > us for: '2 years 3 months'::INTERVAL / '1 week'::INTERVAL (and we > don't care about the fractional week left over). > Thus we

Re: [SQL] prob with PERL/Postgres

2001-08-06 Thread Kate Collins
I use the Perl DBI module to connect to a postgres data base on the local system. I don't specify the host name. This is the syntax I use to connect to the data base: use DBI; $dbname = "foo"; $connstr = "dbi:Pg:dbname=$dbname"; $dbh = DBI->connect($connstr); Kristopher Yates wrote: > PERL S

[SQL] prob with PERL/Postgres

2001-08-06 Thread Kristopher Yates
PERL SNIPPET: # build arrays from file (OMITTED) use Pg; $dbhost='127.0.0.1'; $dbname='mpact'; #$connstr="dbname=$dbname"; $connstr="host=$dbhost dbname=$dbname"; $conn = Pg::connectdb($connstr); #more code related to date omitted $result=$conn->exec($sql); (PGRES_COMMAND_OK eq $result

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > Peter is absolutely correct here. '1 year'::INTERVAL - '1 > day'::INTERVAL is '364 days'::INTERVAL most of the time. However, on > leap years it is '365 days'. Au contraire, it is always '1 year - 1 day'::INTERVAL. That is a two-part interval value a

Re: [SQL] Re: Data type confusion

2001-08-06 Thread Josh Berkus
Folks, Wow. Talk about asking dangerous questions ... > For a 3-part (month/day/second) interval, I think the preferable rule > for timestamp subtraction is to use the largest symbolic component > possible, ie, use the largest number of months/years you can, then > use the largest number of day