By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,421 Members | 1,244 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,421 IT Pros & Developers. It's quick & easy.

Please help re function packaging...

P: n/a
Anyone please help... I'm a newbie on creating
functions in postgresql.

Here is an oracle package that I'm trying to port to
postgresql:

CREATE OR REPLACE PACKAGE BODY NewsPkg.NewsTools
AS
PROCEDURE del_news (i_id IN VARCHAR2)
IS
BEGIN
DELETE FROM tbl_news_type
WHERE uniqueid = i_id;

DELETE FROM tbl_news
WHERE uniqueid = i_id;
END del_news;

PROCEDURE upd_newstype
IS
CURSOR cur_news
IS
SELECT uniqueid
FROM tbl_news_type
WHERE mother_id IS NULL
GROUP BY uniqueid;

v_id tbl_news_type.uniqueid%TYPE;
BEGIN
OPEN cur_news;

LOOP
FETCH cur_news INTO v_id;
upd_mothernews (v_id);
COMMIT;
END LOOP;

CLOSE cur_news;
END upd_newstype;
END NewsTools;

Can anyone help me on how this oracle package would
look like in postgresql... I would really appreciate
it if someone could show me even the synopsis of this
code in postgresql. I've been trying all sorts of ways
to come up with the code in postgresql but when I this
command:
select NewsTools.del_news('20040111DN001869');
I get this error:
ERROR: Namespace "NewsTools" does not exist

Tnx,
Darius

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 22 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
On Tuesday 10 February 2004 11:18, brynk wrote:
Anyone please help... I'm a newbie on creating
functions in postgresql.

Here is an oracle package that I'm trying to port to
postgresql: CREATE OR REPLACE PACKAGE BODY NewsPkg.NewsTools
We don't have packages.
PROCEDURE del_news (i_id IN VARCHAR2)
These will be functions rather than procedures.
Can anyone help me on how this oracle package would
look like in postgresql... I would really appreciate
it if someone could show me even the synopsis of this
code in postgresql. I've been trying all sorts of ways
to come up with the code in postgresql
Post one of your functions with the Oracle equivalent and someone will be able
to point out any problems.
but when I this
command:
select NewsTools.del_news('20040111DN001869');
I get this error:
ERROR: Namespace "NewsTools" does not exist


And does the namespace (i.e. schema) NewsTools exist?

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 22 '05 #2

P: n/a
On Tuesday 10 February 2004 16:48, brynk wrote:
Anyone please help... I'm a newbie on creating
functions in postgresql.

Here is an oracle package that I'm trying to port to
postgresql:

CREATE OR REPLACE PACKAGE BODY NewsPkg.NewsTools
AS
Postgresql does not have packages. However you can create the schema which
contains only functions as a satisfactory replacement of packages.

Of course some 'minor' details such as package level variables could still be
a problem..:-)

So you have to replace this create package statement with a create schema
statement.
Can anyone help me on how this oracle package would
look like in postgresql... I would really appreciate
it if someone could show me even the synopsis of this
code in postgresql. I've been trying all sorts of ways
to come up with the code in postgresql but when I this
command:
select NewsTools.del_news('20040111DN001869');
I get this error:
ERROR: Namespace "NewsTools" does not exist


Postgresql is interpreting it as a schema access. If you define schema as I
have suggested above, it should not be a problem..

HTH

Shridhar

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.