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 Firebird SQL

Date:04/20/05
Author:Jim Dunleavy
URL:n/a
Comments:3
Info:http://firebird.sourceforge.net/
Score: (3.00 in 86 votes)
/*
 * beer_song.sql - 99 Bottles of Beer in Firebird relational database SQL
 * Firebird is at firebird.sourceforge.net
 * Author: Jim Dunleavy <jim.dunleavy@ehss.ie>
 * 2003-11-27
 */

set term !!;

create procedure bottles_beer(bottles integer)
  returns(text varchar(30)) as
begin
  if (bottles > 0) then
    text = bottles;
  else
    text = 'no more';
  text = text || ' bottle';
  if (bottles <> 1) then
    text = text || 's';
  text = text || ' of beer';
  suspend;
end!!

create procedure beer_song
  returns(line varchar(60)) as
declare variable bottles integer;
declare variable bottles_beer varchar(30);
begin
  bottles = 99;
  select text from bottles_beer(:bottles) into :bottles_beer;
  while (bottles > 0) do
  begin
    line = bottles_beer || ' on the wall, ' || bottles_beer || ',';
    suspend;
    line = 'Take one down, pass it around,';
    suspend;
    bottles = bottles - 1;
    select text from bottles_beer(:bottles) into :bottles_beer;
    line = bottles_beer || ' on the wall.';
    suspend;
  end
end!!

set term ;!!

/* Print it out */
select line from beer_song;

/* cleanup */
drop procedure beer_song;
drop procedure bottles_beer;

Download Source | Write Comment

Alternative Versions

Comments

>>  mariuz said on 07/18/05 10:52:16

mariuz very nice beer song ;)

>>  Mia24kv said on 02/02/10 12:22:32

Mia24kv We get know just about this post from different sources. And I could suggest to <a href=" http://www.essayslab.com">buy essay</a> at the custom writing service. And men some times purchase custom essay.

>>  essays said on 09/04/10 11:05:12

essays Thanks for sharing

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: