Unix Technical Forum

PERFORM statement question

This is a discussion on PERFORM statement question within the pgsql Novice forums, part of the PostgreSQL category; --> Hi All, Well, I am continueing to make progress on my function to transfer or update data as required. ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 08:15 PM
Keith Worthington
 
Posts: n/a
Default PERFORM statement question

Hi All,

Well, I am continueing to make progress on my function to transfer or update
data as required. However I have hit another snag. After I successfully
create the function below I atttempt to run it with the command

SELECT xfer_gl_account_data();

And get the error

WARNING: Error occurred while executing PL/pgSQL function xfer_gl_account_data
WARNING: line 11 at assignment
ERROR: parser: parse error at or near "SELECT" at character 9

This was an error regarding not using a PERFORM statement but now the PERFORM
is in there and it still won't work. I have read
http://www.postgresql.org/docs/7.3/i...EMENTS-PERFORM
to no avail.

Obviously I am not using the PERFORM command peroperly but I do not
understand. Hints greatly appreciated.

Kind Regards,
Keith

CREATE OR REPLACE FUNCTION xfer_gl_account_data() RETURNS INTEGER AS '
DECLARE
rcrd_gl_account RECORD;
BEGIN
FOR rcrd_gl_account IN SELECT
data_transfer.tbl_peachtree_gl_account.account_id,

data_transfer.tbl_peachtree_gl_account.description ,

data_transfer.tbl_peachtree_gl_account.account_typ e,

data_transfer.tbl_peachtree_gl_account.inactive
FROM data_transfer.tbl_peachtree_gl_account
ORDER BY
data_transfer.tbl_peachtree_gl_account.account_id
LOOP
PERFORM SELECT peachtree.tbl_gl_account.account_id
FROM peachtree.tbl_gl_account
WHERE peachtree.tbl_gl_account.account_id =
rcrd_gl_account.account_id;
IF NOT FOUND THEN
INSERT INTO peachtree.tbl_gl_account
( peachtree.tbl_gl_account.account_id,
peachtree.tbl_gl_account.description,
peachtree.tbl_gl_account.account_type,
peachtree.tbl_gl_account.inactive )
VALUES ( rcrd_gl_account.account_id,
rcrd_gl_account.description,
rcrd_gl_account.account_type,
rcrd_gl_account.inactive );
ELSE
UPDATE peachtree.tbl_gl_account
SET peachtree.tbl_gl_account.description =
rcrd_gl_account.description,
peachtree.tbl_gl_account.account_type =
rcrd_gl_account.account_type,
peachtree.tbl_gl_account.inactive = rcrd_gl_account.inactive
WHERE peachtree.tbl_gl_account.account_id =
rcrd_gl_account.account_id;
END IF;
END LOOP;
RETURN 1;
END;
' LANGUAGE 'plpgsql';

______________________________________________
99main Internet Services http://www.99main.com


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 08:15 PM
Tom Lane
 
Posts: n/a
Default Re: PERFORM statement question

"Keith Worthington" <keithw@narrowpathinc.com> writes:
> PERFORM SELECT peachtree.tbl_gl_account.account_id
> FROM peachtree.tbl_gl_account
> WHERE peachtree.tbl_gl_account.account_id =
> rcrd_gl_account.account_id;


You just want "PERFORM peachtree...", that is, the PERFORM keyword
is syntactically a substitute for SELECT. The manual is not very
good about this :-( ... I've tried to make it clearer in the 8.0
docs.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:36 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com