The tag <call> also supports execution of R and Javascript. It can execute code stored in catalogue tables or code can be embedded in the <body> tag. Catalog tables are:

  • wic_dbscripts_js for Javascript code
  • wic_dbscripts_r for R code

Both catlog tables can be reached via the wic menu:

Business Logic > Server JS/R code

New in 2019.1

This capability is available in versions 2019.1 onwards. Previous releases do not support execution of R and Javascript

1 call

Executes a javascript or R script on the server. Javascripts are stored in wic_dbscripts_js and R scripts in wic_dbscripts_r table

<call
    name='name'
    code='code'
    type='type'
>
    <args> ?
        <arg /> *
    </args>
    <body /> ?
</call>
Example

The following xsql script calls an embedded JS script and an embedded R script.

Copy
<xsql-script name='hello_world'>
    <body>
        <set name="m_result_js">
            <call type="js" name='sayHiFromJS'>
               <args>
                   <arg>Earth</arg>
               </args>
                <body><![CDATA[
                    function sayHiFromJS(name) {
                        return "Hello " + name + " from JS";
                    }
                 ]]>
                </body>
            </call>
        </set>
        <set name="m_result_r">
            <call type="r" name="sayHiFromR">
               <args>
                   <arg>Mars</arg>
               </args>                
                <body><![CDATA[
                   sayHiFromR <- function(name) {
                        d <- c("Hello", name, "from R")
                        return(paste(d, collapse=" "))
                    }
               ]]>
                </body>

            </call>
        </set>
        
        <println>
            <m_result_js />
            <m_result_r />
        </println>
        
    </body>
</xsql-script>
Hello Earth from JS
Hello Mars from R
Example

Execute a catalogued script:

Copy
<xsql-script >
    <body>
        <println>
            <return>						
                <call name='fibonacci' type="js">		
                    <args>						
                   	<arg>10</arg>		
                   </args>					
                </call>					
            </return>						
        </println>
    </body>

</xsql-script>
89