sql - Create function in MonetDB -


i'm trying add simple function in monetdb @ database level, sum(n) , returns result

create function sys.foo(number int) returns int begin declare tsum int; set tsum = 0; while number > 0 set tsum = tsum + number; set number = number -1; end while; return tsum; end; 

while attempting execute above code i'm seeing error follows

[error code: 0, sql state: 42000] syntax error, unexpected $end, expecting while: end of input stream in "create function sys.foo(number int)

i add same function in mysql, , works!!

>select sys.foo(10)  sys.foo(10) ----------- 55 

could 1 please let me know whats going wrong here?

this works fine me (oct2014 release of monetdb, mac os x)

➜ ~ mclient welcome mclient, monetdb/sql interactive terminal (unreleased) database: monetdb v11.19.16 (unreleased), 'demo' type \q quit, \? list of available commands auto commit mode: on sql>create function sys.foo(number int) more>returns int more>begin more>declare tsum int; more>set tsum = 0; more>while number > 0 more>set tsum = tsum + number; more>set number = number -1; more>end while; more>return tsum; more>end; operation successful (2.127ms)

sql>select sys.foo(10); +------------------+ | foo_single_value | +==================+ | 55 | +------------------+ 1 tuple (1.771ms)


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -