Sql hHw通过R将系统功能传递给MonetDB?
使用Sql hHw通过R将系统功能传递给MonetDB?,sql,r,monetdb,r-dbi,monetdblite,Sql,R,Monetdb,R Dbi,Monetdblite,使用MonetDB.R,我想运行这个命令,但不想打开mclient。有没有一种通用的方法可以做到这一点 create function div_noerror(l double, r double) returns double 来自《货币数据库》的作者汉内斯-- 您可以在数据库中创建它。如果它已经存在,则会失败,但您可以捕获该错误。所以 dbSendQuery(con, "create function div_noerror(l double, r double) returns doub
MonetDB.R
,我想运行这个命令,但不想打开mclient。有没有一种通用的方法可以做到这一点
create function div_noerror(l double, r double) returns double
来自《货币数据库》的作者汉内斯-- 您可以在数据库中创建它。如果它已经存在,则会失败,但您可以捕获该错误。所以
dbSendQuery(con, "create function div_noerror(l double, r double) returns double external name calc.div_noerror”) should work.
下面是一个稍长的使用示例:
# example of division
dbGetQuery( con , "SELECT 1 / 2 AS a" )
# example of division by zero, which causes an error
dbGetQuery( con , "SELECT 1 / 0 AS a" )
# load the `div_noerror` function through a system call
dbSendQuery( con , "CREATE FUNCTION div_noerror(l DOUBLE, r DOUBLE) RETURNS DOUBLE EXTERNAL NAME calc.div_noerror" )
# use the div_noerror function instead of the `/` operator
dbGetQuery( con , "SELECT div_noerror( 1 , 2 ) AS a" )
# division by zero now returns a missing instead of crashing the entire query
dbGetQuery( con , "SELECT div_noerror( 1 , 0 ) AS a" )
来自《货币数据库》的作者汉内斯-- 您可以在数据库中创建它。如果它已经存在,则会失败,但您可以捕获该错误。所以
dbSendQuery(con, "create function div_noerror(l double, r double) returns double external name calc.div_noerror”) should work.
下面是一个稍长的使用示例:
# example of division
dbGetQuery( con , "SELECT 1 / 2 AS a" )
# example of division by zero, which causes an error
dbGetQuery( con , "SELECT 1 / 0 AS a" )
# load the `div_noerror` function through a system call
dbSendQuery( con , "CREATE FUNCTION div_noerror(l DOUBLE, r DOUBLE) RETURNS DOUBLE EXTERNAL NAME calc.div_noerror" )
# use the div_noerror function instead of the `/` operator
dbGetQuery( con , "SELECT div_noerror( 1 , 2 ) AS a" )
# division by zero now returns a missing instead of crashing the entire query
dbGetQuery( con , "SELECT div_noerror( 1 , 0 ) AS a" )
来自《货币数据库》的作者汉内斯-- 您可以在数据库中创建它。如果它已经存在,则会失败,但您可以捕获该错误。所以
dbSendQuery(con, "create function div_noerror(l double, r double) returns double external name calc.div_noerror”) should work.
下面是一个稍长的使用示例:
# example of division
dbGetQuery( con , "SELECT 1 / 2 AS a" )
# example of division by zero, which causes an error
dbGetQuery( con , "SELECT 1 / 0 AS a" )
# load the `div_noerror` function through a system call
dbSendQuery( con , "CREATE FUNCTION div_noerror(l DOUBLE, r DOUBLE) RETURNS DOUBLE EXTERNAL NAME calc.div_noerror" )
# use the div_noerror function instead of the `/` operator
dbGetQuery( con , "SELECT div_noerror( 1 , 2 ) AS a" )
# division by zero now returns a missing instead of crashing the entire query
dbGetQuery( con , "SELECT div_noerror( 1 , 0 ) AS a" )
来自《货币数据库》的作者汉内斯-- 您可以在数据库中创建它。如果它已经存在,则会失败,但您可以捕获该错误。所以
dbSendQuery(con, "create function div_noerror(l double, r double) returns double external name calc.div_noerror”) should work.
下面是一个稍长的使用示例:
# example of division
dbGetQuery( con , "SELECT 1 / 2 AS a" )
# example of division by zero, which causes an error
dbGetQuery( con , "SELECT 1 / 0 AS a" )
# load the `div_noerror` function through a system call
dbSendQuery( con , "CREATE FUNCTION div_noerror(l DOUBLE, r DOUBLE) RETURNS DOUBLE EXTERNAL NAME calc.div_noerror" )
# use the div_noerror function instead of the `/` operator
dbGetQuery( con , "SELECT div_noerror( 1 , 2 ) AS a" )
# division by zero now returns a missing instead of crashing the entire query
dbGetQuery( con , "SELECT div_noerror( 1 , 0 ) AS a" )