Re: [SQL]

2001-09-03 Thread Michael Davis
Try: Create table table1(field1,field2) as (select field1, field2 from table2); -Original Message- From: Joseph Syjuco [SMTP:[EMAIL PROTECTED]] Sent: Monday, September 03, 2001 3:03 AM To: [EMAIL PROTECTED] Subject: im new in postgresql (actually came from SQL Server) an

[SQL] RE: Oracle to PostgreSQL help: What is (+) in Oracle select?

2001-03-16 Thread Michael Davis
This is Oracle's syntax for an outer join. Try this in PostgreSQL SELECT o.* from one o LEFT JOIN two t ON o.key = t.key; -Original Message- From: Christopher Audley [SMTP:[EMAIL PROTECTED]] Sent: Friday, March 16, 2001 3:57 PM To: [EMAIL PROTECTED] Subject:Oracle to Pos

[SQL] RE: Help with UPDATE syntax

2001-03-15 Thread Michael Davis
Try eliminating the statement " from user_group_map map". It does not belong in the update. Here is the fully rewritten statement: update user_group_map set user_id = 4 where user_id = 9 and not exists ( select * from

[SQL] Access tables inside pl/pgsql functions

2001-03-08 Thread Michael Davis
I would like to create a pl/pgsql function that can select from a table even though users can't select from the table directly. For example, create a table and function that hits the table as the postgres user. Log in as another user and select function_name();. This fails because the user

[SQL] RE: plpgsql error: cache lookup from pg_proc failed

2001-02-06 Thread Michael Davis
Setting NEW in an AFTER update or insert trigger is not wise. Try using a before update trigger instead. -Original Message- From: Joseph Shraibman [SMTP:[EMAIL PROTECTED]] Sent: Tuesday, February 06, 2001 6:35 PM To: [EMAIL PROTECTED] Subject:plpgsql error: cache looku

[SQL] RE: Hrm...why is this wrong?

2001-02-05 Thread Michael Davis
When declaring parameters try using varchar rather than varchar(255). I have used text successfully in the past. -Original Message- From: Ken Corey [SMTP:[EMAIL PROTECTED]] Sent: Sunday, February 04, 2001 6:38 AM To: [EMAIL PROTECTED] Subject:Hrm...why is this wrong? In

[SQL] RE: C function for use from PLpgSQL trigger

2001-02-05 Thread Michael Davis
You could send the column name directly into your c function. For example: c_function_name(NEW.col1, NEW.col2, NEW.col3). Otherwise I am not sure how to send NEW into a C function. You could try declaring NEW in your C function as a tuple. -Original Message- From: Joe Conway [SMTP

[SQL] RE: how to create this trigger?

2001-02-01 Thread Michael Davis
Did you insert a row into table2? What happens if there is no row in table 1 where id = code (of the newly inserted row in table2). Seems to me you many need to consider expanding increment_value() to check table1 to see if code exists. If not insert a new value, else update. -Original

[SQL] RE: no value for numeric filed in SQL statement causes an error

2001-01-31 Thread Michael Davis
Try: insert into table (name,id,city) values ('roger rabbit',NULL,'carrot city') -Original Message- From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]] Sent: Wednesday, January 31, 2001 7:16 AM To: [EMAIL PROTECTED] Subject:no value for numeric filed in SQL statement cause

[SQL] RE: Rownum/ row Id

2001-01-31 Thread Michael Davis
The column name is OID. -Original Message- From: Padmajha Raghunathan [SMTP:[EMAIL PROTECTED]] Sent: Tuesday, January 30, 2001 11:20 PM To: [EMAIL PROTECTED] Subject:Rownum/ row Id Hi, Is there a provision to delete the duplicate records using row num/ row id as avai

[SQL] RE: looping through results of a SELECT

2001-01-27 Thread Michael Davis
Try using aggregate functions. Creating your own aggregate function is fairly easy and can produce the exact results you are looking for. In case this is not good enough, here is an example of some code I used to loop through rows in a table in pl/pgsql CREATE FUNCTION pending_post_transact

[SQL] RE: Is there anything like DESCRIBE?

2001-01-25 Thread Michael Davis
This works for me: SELECT DISTINCT c.relname as table_name, a.attname as column_name, t.typname, pa.adsrc as default FROM (pg_attribute a join pg_class c on a.attrelid = c.oid join pg_type t on a.atttypid = t.oid) left join pg_attrdef pa on c.oid = pa.adrelid AND a

[SQL] RE: SQL Query Results

2001-01-24 Thread Michael Davis
In psql you can try \g or \o. -Original Message- From:[SMTP:[EMAIL PROTECTED]] Sent: Tuesday, January 23, 2001 10:03 PM To: [EMAIL PROTECTED] Subject:SQL Query Results I want to show a certain person the commands I type and the query results, and I want to save them i

[SQL] RE: plpgsql language

2001-01-23 Thread Michael Davis
Did you execute the following after you created your database? CREATE FUNCTION plpgsql_call_handler () RETURNS OPAQUE AS '/usr/local/pgsql/lib/plpgsql.so' LANGUAGE 'C'; CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'; These are

[SQL] RE: DATE

2001-01-23 Thread Michael Davis
Select now() + 7; -Original Message- From: john whale [SMTP:[EMAIL PROTECTED]] Sent: Monday, January 22, 2001 10:30 AM To: '[EMAIL PROTECTED]' Subject:DATE PLEASE ADVISE HOW I SHOULD ALTER THE COMMAND: <$NOW;DD;> TO GIVE ME A DATE THAT IS X DAYS FORWARD ie: I

[SQL] RE: retrieving user's groups

2001-01-23 Thread Michael Davis
Here's a start: select g.groname as group, g.grosysid as group_id, u.usename as user, u.usesysid as user_id from pg_group g, pg_user u where u.usesysid = g.grolist[1] or u.usesysid = g.grolist[2] or u.usesysid = g.grolist[3] or u.usesysid = g.grolist[4] or u.usesysid = g.grolist[5] or

[SQL] RE: Joining several tables

2001-01-22 Thread Michael Davis
1) Select t1.* from table_1 t1, table2 t2 where t1.column = t2.column; 2) Select t1.* from table_1 t1 join table2 t2 on t1.column = t2.column; -Original Message- From: Stephan Richter [SMTP:[EMAIL PROTECTED]] Sent: Sunday, January 21, 2001 11:20 PM To: [EMAIL PROTECTED] Subject:

[SQL] Numeric and money

2001-01-03 Thread Michael Davis
al functions that already exist to convert numeric to text so that I don't have to write one? I know that psql successfully does this. Thanks, Michael Davis Database Architect and Senior Software Engineer, Seva Inc. Office: 303-460-7360Fax: 303-460-7362 Mobile: 720-320-6971 Email: [EMAIL PROTECTED]

[SQL] Removing a constraint?

2001-01-01 Thread Michael Davis
Does anyone know how to completely and accurately remove or drop a constraint, specifically a foreign key constraint? I tried to remove a constraint by deleting it's trigger from pg_triggers. This caused some undesirable side effects with other tables involved with the constraint. I have se

[SQL] RE: Updating two table via a Rule?

2001-01-01 Thread Michael Davis
aymentLineID, Amount) VALUES(9, nextval('Payments_s'), '1/1/2001', nextval('PaymentLines_s'), 10); The Payments_s sequences is bumped on both inserts. As a result, the insert into the PaymentLines table has a different PaymentsID that the inse

[SQL] Updating two table via a Rule?

2001-01-01 Thread Michael Davis
before rule #1). Any suggestions on how to get this to work? Any help is greatly appreciated. Thanks, Michael Davis