| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 20 Jul 2010 09:00:17
|
trexcoleman_trexcoleman
New member
Joined: 4 Jul 2010 12:26:19
Messages: 4
Offline
|
I have been attempting to create a function in pgAdminIII and it appears next to impossible. What am I doing wrong???
This the procedure that I've tried:
Databases -> myDatabase -> Schemas -> public ->Functions (0)
Next I right click on Functions (0)
this brings up a window which says: Refresh, New Function..., Object List Report, Grant Wizard
From list List Box I select "New Function"
A "New Function" entry window
In the "Properties tab" I enter:
Function Name
The owner
return type
language
select Definition
And enter (paste) the function definition:
CREATE OR REPLACE FUNCTION increment(i integer) RETURNS integer AS $$
BEGIN
RETURN i + 1;
END;
$$ LANGUAGE plpgsql;
Then I select "OK"
I get the following error message:
pgAdminIII
An error has occurred:
ERROR: Syntax error at or near "CREATE"
LINE 2: $BODY$CREATE OR REPLACE FUNCTION increment(i integer) RETURN...
^
This is a test function, but i get the same error on the real thing.
I have also tried
CREATE OR REPLACE FUNCTION increment(i integer) RETURNS integer AS '
BEGIN
RETURN i + 1;
END;
' LANGUAGE 'plpgsql';
Oh and:
CREATE FUNCTION increment(i integer) RETURNS integer AS '
BEGIN
RETURN i + 1;
END;
' LANGUAGE 'plpgsql';
with the same result.
Can somebody throw out a line???
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 2 Sep 2010 14:28:52
|
Dave_Derry
New member
Joined: 2 Sep 2010 14:23:43
Messages: 3
Offline
|
OK, I've never used the facility you describe, but let me take a stab at this. From the description you give of the process (In the "Properties tab" I enter: Function Name, The owner, return type, language .... select Definition), which sounds like a wizard, and the error (Syntax error at or near "CREATE" LINE 2: $BODY$CREATE OR REPLACE ), I would guess that what it expects is just the *body* of the function. Not the complete create statement. What you have pasted in is what you would enter into a query window, and what I suspect the wizard is attempting to construct.
Try pasting just the part between the opening $$ (which gets expanded to $BODY$) and the closing $$. In other words just
BEGIN
RETURN i + 1;
END;
|
|
|
 |
|
|
|
|