Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language PL/PGSQL

Date:01/10/06
Author:Daivd Bitner
URL:n/a
Comments:0
Info:http://postgresql.org
Score: (2.00 in 6 votes)
CREATE OR REPLACE FUNCTION ninetyninebottles()
  RETURNS "varchar" AS
$BODY$declare
nbottles int4;
begin
nbottles := 99;
loop
	if (nbottles > 1) then
		raise notice '% bottles of beer on the wall, % bottles of beer.',nbottles,nbottles;
		nbottles := nbottles-1;
		raise notice 'Take one down, pass it around, % bottles of beer on the wall.',nbottles;
	else 
		raise notice '1 bottle of beer on the wall, 1 bottle of beer.';
		raise notice 'Take one down, pass it around, no more bottles of beer on the wall.';
		return 'Burp';
	end if;
end loop;
return 'burp';
end;$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
Version returning SETOFLuis Carlos F. Dias06/08/062

Comments

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: