dbTalk Databases Forums  

A question about pl/pgsql

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss A question about pl/pgsql in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
jack_dull
 
Posts: n/a

Default A question about pl/pgsql - 01-14-2004 , 09:21 PM






hi, all

I'm writting a procedure by pl/pgsql as following. It's a star-join
query for star schema in data warehouse. The procedure is to test the
performance of this kind of query. But I get an error at "perform select
....." statement. I can't find what is wrong with it ? Thank you to take
time and trouble to lend me a hand.

Jack


-- Function: public.query()

-- DROP FUNCTION public.query();

CREATE OR REPLACE FUNCTION public.query()
RETURNS int4 AS
'
DECLARE
rand number;
LineRow linelevel%ROWTYPE;
RetailerRow retailerlevel%ROWTYPE;
YearRow yearlevel%ROWTYPE;
MonthRow monthlevel%ROWTYPE;
QuarterRow quarterlevel%ROWTYPE;
starttime timestamp;
duration timestamp;
BEGIN
rand := random();
select * into LineRow from linelevel limit 1 offset floor(rand*15);
rand := random();
select * into RetailerRow from retailerlevel limit 1 offset floor(rand*99);
rand := random();
select * into YearRow from yearlevel limit 1 offset floor(rand*2);
rand := random();
select * into MonthRow from monthlevel limit 1 offset floor(rand*24);
rand := random();
select * into QuarterRow from quarterlevel limit 1 offset floor(rand*8);

starttime := \'now\';
perform select * FROM custlevel as c, actvars as f, prodlevel as p,
timelevel as t
where c.store_level = f.customer_level AND p.code_level = f.product_level
AND t.month_level = f.time_level
AND P.line_level = LineRow.level AND t.year_level = YearRow.level
AND c.retailer_level = RetailerRow.level;
duration := \'now\'-starttime;

END;
'
LANGUAGE 'plpgsql' VOLATILE;



Reply With Quote
  #2  
Old   
jack_dull
 
Posts: n/a

Default Re: A question about pl/pgsql - 01-15-2004 , 08:08 AM






I'm sorry, it's a stupid questin indeed. I should write function now()
instead of now in the procedure.


"jack_dull" <jack_dull (AT) 163 (DOT) com> дÈëÓʼþ news:bu5169$re2$1 (AT) news (DOT) hub.org...
Quote:
hi, all

I'm writting a procedure by pl/pgsql as following. It's a star-join
query for star schema in data warehouse. The procedure is to test the
performance of this kind of query. But I get an error at "perform select
...." statement. I can't find what is wrong with it ? Thank you to take
time and trouble to lend me a hand.

Jack


-- Function: public.query()

-- DROP FUNCTION public.query();

CREATE OR REPLACE FUNCTION public.query()
RETURNS int4 AS
'
DECLARE
rand number;
LineRow linelevel%ROWTYPE;
RetailerRow retailerlevel%ROWTYPE;
YearRow yearlevel%ROWTYPE;
MonthRow monthlevel%ROWTYPE;
QuarterRow quarterlevel%ROWTYPE;
starttime timestamp;
duration timestamp;
BEGIN
rand := random();
select * into LineRow from linelevel limit 1 offset floor(rand*15);
rand := random();
select * into RetailerRow from retailerlevel limit 1 offset
floor(rand*99);
rand := random();
select * into YearRow from yearlevel limit 1 offset floor(rand*2);
rand := random();
select * into MonthRow from monthlevel limit 1 offset floor(rand*24);
rand := random();
select * into QuarterRow from quarterlevel limit 1 offset floor(rand*8);

starttime := \'now\';
perform select * FROM custlevel as c, actvars as f, prodlevel as p,
timelevel as t
where c.store_level = f.customer_level AND p.code_level = f.product_level
AND t.month_level = f.time_level
AND P.line_level = LineRow.level AND t.year_level = YearRow.level
AND c.retailer_level = RetailerRow.level;
duration := \'now\'-starttime;

END;
'
LANGUAGE 'plpgsql' VOLATILE;





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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.