#arg

Read(2592) Label: script file, arguments,

Description:

Define arguments in a plain text script.

Syntax:

  #arg=…

Note:

 The first few lines of the text script begin with # to define parameters. Note that #arg=... must appear at the beginning of the cellset code.

Parameter:

arg

Parameter name.

…

Parameter value.

Example:

Define parameters in a SPL script file:

 

Define parameters when esProc JDBC executes the cellset code.

Define values of parameter n1 and parameter n2 respectively as 2 and 3, and then compute n1+n2:

  public void executeQuery1(){

   Connection con = null;

    java.sql.PreparedStatement ps; 

     try{ 

    Class.forName("com.esproc.jdbc.InternalDriver");

    con= DriverManager.getConnection("jdbc:esproc:local://");

     String code= "#n1=2\n#n2=3\n=n1+n2";

    Statement st = con.createStatement();

    ResultSet set = st.executeQuery("=" + code);          

    ResultSetMetaData meta = set.getMetaData();

    while (set.next()) {

    for(int i=0; i<meta.getColumnCount(); i++){ 

  System.out.print(set.getObject(i+1) + "\t");

  }

  System.out.println();

    }

    }

    catch(Exception e){

    System.out.println(e);

    }

    finally{

    //Close the connection

    if (con!=null) {

    try {

    con.close();

    }

    catch(Exception e) {

    System.out.println(e);

    }

    }

      } 

  }