Re: [GENERAL] Inserting data from one database to another using stored functions

2011-01-07 Thread Richard Huxton
On 07/01/11 01:56, Benjie Buluran wrote: Hi pgSQL peeps! I’m stumped on this question for over 3 days now. PERFORM dblink_exec('SELECT sp_insert_detailtable('|| pActivityId ||', '|| pserialnumber ||')'); I’m using the DEBUG function in pgAdmin, and I keep getting the “*statement returning

Re: [GENERAL] Inserting data from one database to another using stored functions

2011-01-07 Thread Benjie Buluran
com] Sent: Friday, January 07, 2011 4:03 PM To: Benjie Buluran Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Inserting data from one database to another using stored functions On Thu, Jan 6, 2011 at 6:56 PM, Benjie Buluran wrote: Hi pgSQL peeps! I'm stumped on this question

Re: [GENERAL] Inserting data from one database to another using stored functions

2011-01-07 Thread Eric McKeeth
On Thu, Jan 6, 2011 at 6:56 PM, Benjie Buluran < benjie.bulu...@igentechnologies.com> wrote: > Hi pgSQL peeps! > > > > I’m stumped on this question for over 3 days now. > > > > I need to run a stored function in Database A (“sf DBa”) which calls a > stored function in Database B (“sf DBb”). > > >

[GENERAL] Inserting data from one database to another using stored functions

2011-01-06 Thread Benjie Buluran
Hi pgSQL peeps! I'm stumped on this question for over 3 days now. I need to run a stored function in Database A ("sf DBa") which calls a stored function in Database B ("sf DBb"). Here's "sf DBa": CREATE OR REPLACE FUNCTION sp_update_serialnumber(pserialnumber character varying, pActivi

Re: [GENERAL] Inserting data in composite types

2006-11-13 Thread Jeff Davis
On Mon, 2006-11-13 at 09:37 -0300, Rodrigo Sakai wrote: > Hi, I have a question about how to insert data in composite types! > > > > Imagine the exemple: > > > > CREATE TYPE t_time AS ( > > a date, > > b date > > ); > > > > CREATE TABLE salary ( > >salary numeric(10,2),

Re: [GENERAL] Inserting data in composite types

2006-11-13 Thread Albe Laurenz
> Hi, I have a question about how to insert data in composite types! > > CREATE TYPE t_time AS ( > a date, > b date > ); > > CREATE TABLE salary ( >salary numeric(10,2), >t_date t_time > ); > > I know that if I want to insert data in the table SALARY I > just have to do like: > >

[GENERAL] Inserting data in composite types

2006-11-13 Thread Rodrigo Sakai
  Hi, I have a question about how to insert data in composite types!     Imagine the exemple:   CREATE TYPE t_time AS (   a date,   b date );   CREATE TABLE salary (    salary numeric(10,2),    t_date t_time );   I know that if I want to insert data in the table SALARY I just

Re: [GENERAL] Inserting Data

2006-08-26 Thread Bob Pawley
Michael Thanks again for your help. Bob - Original Message - From: "Michael Fuhr" <[EMAIL PROTECTED]> To: "Bob Pawley" <[EMAIL PROTECTED]> Cc: "Postgresql" Sent: Saturday, August 26, 2006 1:36 PM Subject: Re: [GENERAL] Inserting Data On

Re: [GENERAL] Inserting Data

2006-08-26 Thread Michael Fuhr
On Sat, Aug 26, 2006 at 01:22:49PM -0700, Bob Pawley wrote: > What is the reason for redefining type_ as device_type ??? The function doesn't redefine type_; it selects the value of the type_ column into a local variable named device_type to avoid querying library.devices more than once. That loc

Re: [GENERAL] Inserting Data

2006-08-26 Thread Bob Pawley
t; Sent: Friday, August 25, 2006 12:31 PM Subject: Re: [GENERAL] Inserting Data On Fri, Aug 25, 2006 at 09:35:21AM -0700, Bob Pawley wrote: The library.devices table holds the static information on each of the devices that are available to the user. Is library.devices.device_number

Re: [GENERAL] Inserting Data

2006-08-25 Thread Michael Fuhr
On Fri, Aug 25, 2006 at 09:35:21AM -0700, Bob Pawley wrote: > The library.devices table holds the static information on each > of the devices that are available to the user. Is library.devices.device_number a unique attribute? That is, for a given device_number, is there at most one row in librar

[GENERAL] Inserting Data

2006-08-25 Thread Bob Pawley
Michael   OK here goes.   What I am attempting is to break down large categories (devices) into subcategories (monitor, end-devices, pumps, etc) and enter their device_ids into their own tables with, in some cases the device_id as that table’s primary key.   The p_id.devices table hol

Re: [GENERAL] Inserting Data

2006-08-25 Thread Michael Fuhr
On Thu, Aug 24, 2006 at 09:20:11AM -0700, Bob Pawley wrote: > In attempting to use the IF expression (below) I receive an error > message stating the return includes two or more rows. This seems > to make sense since I am asking if one condition exists > (p_id device_number = library device_number

[GENERAL] Inserting Data

2006-08-24 Thread Bob Pawley
Michael   You did well interpreting my scribblings.   In attempting to use the IF _expression_ (below) I receive an error message stating the return includes two or more rows. This seems to make sense since I am asking if one condition exists (p_id device_number = library device_number

Re: [GENERAL] Inserting Data

2006-08-24 Thread Michael Fuhr
On Wed, Aug 23, 2006 at 07:34:43PM -0700, Bob Pawley wrote: > Let me explain. I'll build a simple example based on what you describe. Please make corrections as necessary. > I have a table called p_id.devices which accumulates the devices_id for a > multitude of differing devices used in P&ID d

Re: [GENERAL] Inserting Data

2006-08-23 Thread Michael Fuhr
On Wed, Aug 23, 2006 at 05:34:27PM -0700, Bob Pawley wrote: > Could you explain why Postgresql simply doesn't accept the simple 'where' > statement that was in my earlier e-mail. Because INSERT doesn't take a WHERE clause. If you want to do the insert conditionally then use an IF statement as To

Re: [GENERAL] Inserting Data

2006-08-23 Thread Bob Pawley
ls behind the structure as best I can. Bob - Original Message - From: "Tom Lane" <[EMAIL PROTECTED]> To: "Bob Pawley" <[EMAIL PROTECTED]> Cc: "Michael Fuhr" <[EMAIL PROTECTED]>; "Postgresql" Sent: Wednesday, August 23, 2006 4:44 P

Re: [GENERAL] Inserting Data

2006-08-23 Thread Bob Pawley
e simple 'where' statement that was in my earlier e-mail. Bob - Original Message - From: "Tom Lane" <[EMAIL PROTECTED]> To: "Bob Pawley" <[EMAIL PROTECTED]> Cc: "Michael Fuhr" <[EMAIL PROTECTED]>; "Postgresql" Sent: Wed

Re: [GENERAL] Inserting Data

2006-08-23 Thread Tom Lane
Bob Pawley <[EMAIL PROTECTED]> writes: > What I have is one table which stores device_id numbers that are referenced > on the second table "library.devices". > I need to insert device_ids from the first table that satisfy the conditions > of the argument found on the library table. Hence the 'whe

Re: [GENERAL] Inserting Data

2006-08-23 Thread Bob Pawley
ar all I can get are errors when I attempt this procedure. Hence - my problem. Bob - Original Message - From: "Tom Lane" <[EMAIL PROTECTED]> To: "Bob Pawley" <[EMAIL PROTECTED]> Cc: "Michael Fuhr" <[EMAIL PROTECTED]>; "Postgresql"

Re: [GENERAL] Inserting Data

2006-08-23 Thread Tom Lane
Bob Pawley <[EMAIL PROTECTED]> writes: > insert into p_id.loops (monitor) values (new.devices_id) > where new.device_number = library.devices.device_number > and library.devices.type_ = 'mon' ; Huh? How did library.devices get into this? Are you trying to join to it, and if so why, seeing tha

Re: [GENERAL] Inserting Data

2006-08-23 Thread Bob Pawley
: "Tom Lane" <[EMAIL PROTECTED]> To: "Bob Pawley" <[EMAIL PROTECTED]> Cc: "Michael Fuhr" <[EMAIL PROTECTED]>; "Postgresql" Sent: Wednesday, August 23, 2006 3:31 PM Subject: Re: [GENERAL] Inserting Data Bob Pawley <[EMAIL PROTECTED]&

Re: [GENERAL] Inserting Data

2006-08-23 Thread Tom Lane
Bob Pawley <[EMAIL PROTECTED]> writes: > I thought the NEW qualified the select. Not at all; that would rather cripple the ability to write interesting triggers. I think what you are really wanting to do here is just insert into p_id.loops (monitor) values (new.devices_id);

Re: [GENERAL] Inserting Data

2006-08-23 Thread Bob Pawley
stgresql" Sent: Wednesday, August 23, 2006 3:18 PM Subject: Re: [GENERAL] Inserting Data Bob Pawley <[EMAIL PROTECTED]> writes: Perhaps we can look at the following as a simple example of what is happening- - create or replace function loop_association() returns t

Re: [GENERAL] Inserting Data

2006-08-23 Thread Tom Lane
Bob Pawley <[EMAIL PROTECTED]> writes: > Perhaps we can look at the following as a simple example of what is > happening- > - > create or replace function loop_association() returns trigger as $$ > begin > Insert Into p_id.loops (monitor) > select new.devices_id > from p_id.devices ;

Re: [GENERAL] Inserting Data

2006-08-23 Thread Bob Pawley
correct this action? Bob - Original Message - From: "Michael Fuhr" <[EMAIL PROTECTED]> To: "Bob Pawley" <[EMAIL PROTECTED]> Cc: "Postgresql" Sent: Tuesday, August 22, 2006 1:58 PM Subject: Re: [GENERAL] Inserting Data On Tue, Aug 22, 200

Re: [GENERAL] Inserting Data

2006-08-22 Thread Michael Fuhr
On Tue, Aug 22, 2006 at 09:02:52AM -0700, Bob Pawley wrote: > I set aside the procedure you sent to me as it resulted in multiple rows of > the same information. (In fact one variation produced 100 rows for each of > the 9 "new" fields creating a 900 row table. If it was doing that then it would

Re: [GENERAL] Inserting Data

2006-08-22 Thread Bob Pawley
Help is greatly appreciated. Bob. - Original Message - From: "Michael Fuhr" <[EMAIL PROTECTED]> To: "Bob Pawley" <[EMAIL PROTECTED]> Cc: "Postgresql" Sent: Monday, August 21, 2006 4:47 PM Subject: Re: [GENERAL] Inserting Data On Mon, Aug

Re: [GENERAL] Inserting Data

2006-08-21 Thread Michael Fuhr
On Mon, Aug 21, 2006 at 08:27:58AM -0700, Bob Pawley wrote: > Yes - Multiple rows of the same data are created in each secondary table. > > I have two triggers that are identical in format although handling > different tables. One is triggeres after insert and with this there is no > multiplying

Re: [GENERAL] Inserting Data

2006-08-21 Thread Bob Pawley
- Original Message - From: "Michael Fuhr" <[EMAIL PROTECTED]> To: "Bob Pawley" <[EMAIL PROTECTED]> Cc: "Postgresql" Sent: Friday, August 18, 2006 7:27 PM Subject: Re: [GENERAL] Inserting Data On Fri, Aug 18, 2006 at 09:27:19AM -0700, Bob Pawley wr

Re: [GENERAL] Inserting Data

2006-08-18 Thread Michael Fuhr
On Fri, Aug 18, 2006 at 09:27:19AM -0700, Bob Pawley wrote: > I need to insert data from one table into three other tables. > > I attempted the following format. [...] > insert into p_id.loops (monitor) > Select p_id.devices.devices_id > Where p_id.devices.device_number = library.devices.devi

Re: [GENERAL] Inserting Data

2006-08-18 Thread Merlin Moncure
On 8/18/06, Bob Pawley <[EMAIL PROTECTED]> wrote: Unfortunately this gave multiple results on the target tables. Is there a format that will give me a single insert for each original field without the need of creating three triggers??? Bob try using old/new in your trigger functions. insert

[GENERAL] Inserting Data

2006-08-18 Thread Bob Pawley
Hi All   I have a basic problem that I hope can be addressed.   I need to insert data from one table into three other tables.   I attempted the following format.    CREATE OR REPLACE FUNCTION p_id_monitor() RETURNS "trigger" AS $$ Begin insert into p_id.loops (monitor)  Select p_id.devices.d

[GENERAL] inserting data into multiple tables

2001-10-15 Thread Tony Grant
Hello, I have a table "refers_to" individual_id int4 book_id int4 and another "individual" individual_id int4 nextval('individual_serial') name varchar forename varchar If the individual exists then get his id. If he doesn't allready exist write his names to the table and get the newly create