how to use variables in postgresql

From: "saumya goel" <somya(dot)goel(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: how to use variables in postgresql
Date: 2007-06-22 05:55:38
Message-ID: 888154f50706212255n2acce6avfcc0ff33fb820e1b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I HAVE A PROBLEM REGARDING DECLARATION/ INITIALISATION OF VARIABLES IN
POSTGRESQL FUNCTIONS AND PROCEDURES. MY CODE PRESENTLY LOOKS LIKE
CREATE FUNCTION ins_into_std_values() RETURNS void AS
$BODY$
myflag CHAR(1) :='y';
dbms_output.put_line('enter the values sequentially');
loop
if myflag='n' then
exit;
end if;
insert into std_values
values('&tree_species_name','&location',&p,&c1,&c2,&q,&c3,&a,&b,&sp_gravity,&exp_factor);
commit;
dbms_output.put_line('records inserted sucessfully');
dbms_output.put_line('enter n to exit or y to continue entering values');
myflag:= '&y or n';
end loop;
commit;
$BODY$
LANGUAGE 'sql' VOLATILE;

BUT IT SHOWS ERROR AT INITIALISATION OF MYFLAG... CAN ANYONE TELL ME HOW TO
DECLARE VARIABLES IN POSTGRESQL..

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message A. Kretschmer 2007-06-22 06:07:32 Re: how to use variables in postgresql
Previous Message Tom Lane 2007-06-22 03:33:17 Re: 8.1 -- very slow query time because of "BETWEEN" (dbmail)