473,379 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

USE OF VARIABLES IN postgreSQL

1
I HAVE A PROBLEM REGARDING DECLARATION/ INITIALISATION OF VARIABLES IN POSTGRESQL FUNCTIONS AND PROCEDURES. MY CODE PRESENTLY LOOKS LIKE
Expand|Select|Wrap|Line Numbers
  1. CREATE FUNCTION ins_into_std_values() RETURNS void AS
  2. $BODY$
  3. myflag CHAR(1) :='y';
  4. dbms_output.put_line('enter the values sequentially');
  5.     loop
  6.             if myflag='n' then 
  7.             exit;
  8.             end if;
  9.         insert into std_values
  10.         values('&tree_species_name','&location',&p,&c1,&c2,&q,&c3,&a,&b,&sp_gravity,&exp_factor);
  11.         commit;
  12.         dbms_output.put_line('records inserted sucessfully');
  13.         dbms_output.put_line('enter n to exit or y to continue entering values');
  14.         myflag:= '&y or n';
  15.     end loop;
  16. commit;
  17. $BODY$
  18. LANGUAGE 'sql' VOLATILE;
  19.  
BUT IT SHOWS ERROR AT INITIALISATION OF MYFLAG... CAN ANYONE TELL ME HOW TO DECLARE VARIABLES IN POSTGRESQL..
Jun 22 '07 #1
2 6520
michaelb
534 Expert 512MB
saumya, please read the Posting Guidelines at the top of the forum and use the CODE tags in your future postings.
Jun 22 '07 #2
michaelb
534 Expert 512MB
Your code has to with Oracle more than with Postgresql.
There's no dbms_output.put_line in Postgresql, and you probably want to use plpgsql, not sql for this function.

Please start with the PostgreSQL manual:
CREATE FUNCTION
Writing SQL Functions
Procedural languages
plpgsql procedural language
Declarations
Jun 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Otis Green | last post by:
Vote for or against a new newsgroup proposal. To summarize what you need to do, just send an empty e-mail to postgresql-ballot@netagw.com You will receive a ballot by e-mail. Follow the...
0
by: Bill J. | last post by:
I have to update a PostgreSQL linked server through MSSQL2K. I first configured the connection with ODBC as follows and I can do queries with no problem: EXEC sp_droplinkedsrvlogin @rmtsrvname...
175
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I...
0
by: lnd | last post by:
A few question regarding PostgreSQL handling of queries: - Is each query submitted parsed and planned even if it is identical to a query submitted before? For example, 10 queries "select * from...
6
by: Grainne Reilly | last post by:
I am new to PostgreSQL and am porting some scripts written for MySQL over to psql. There is one MySQL feature which I cannot find in psql - user defined SQL variables. In MySQL I can use these to...
1
by: Daniel Martini | last post by:
Hi all, I'm currently coding some functions in plpgsql for generating reports out of records in a table. Problem is: NULL values in records make the complete function fail. Here is a simple...
0
by: Greg Sabino Mullane | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This is a PGP-signed copy of the checksums for following PostgreSQL versions: 7.4.5 7.4.4 7.3.7
0
by: Vassilev, Lubomir G. | last post by:
i am currently migrating a db from Oracle to Pg and in some of my triggers i use variables, i.e. i have some thing like this: CREATE OR REPLACE TRIGGER "USERACTION_VIEW" INSTEAD OF...
0
by: Charles, Auriance | last post by:
Hello, Is it possible to use Bind variables with Postgresql 8.1? Thanks, Charles. Desenvolvimento e criação de sites: www.auriance.com Hospedagem de sites e servidores dedicados:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.