esProc Integration & Application: Command Line

esProc 1540 0

The command line refers to using commands in the form of strings in DOS-like environment to execute programs. All operating systems support the command lines, like the Linux console and the Windows command line window.

The file, esprocx.exe, is needed when the command line is used to execute an esProc cellset file. The file can be found in esProc\bin path in esProc’s installation directory.

1. Cellset files without return results

Use the esprocx command to execute the cellset file at command line. Take the following cellset file, D:\files\output1.dfx, as an example:

  A B
1 =create(ID,Amount)  
2 for 100 >A1.insert(0,#A2,rand(100*100))
3 =file(“D:\\files\\Data1.txt”) >A3.export@t(A1)

Cellset files without return results are usually used to access files or databases. In the above cellset, for example, some simulation data are created and stored in a text file, Data1.txt. In using an esprocx command, enter the to-be-executed dfx file after it; during execution, prompts of start and end will be displayed on the screen, as shown below:

esProc_integration_commandline_2

After the execution, the randomly generated data will be written into Data1.txt, as shown below:

esProc_integration_commandline_3

If the path in which the esprocx file is located is included into the operating system’s path list, run the file directly instead of running it in esProc\bin path of the installation directory. But the to-be-called dfx file must be entered in its full path, or should be located in the current path. For example:

esProc_integration_commandline_4

If the running cellset file uses parameters, enter their values, separated by spaces, after the dfx file when executing esprocx. Take the following cellset file D:\files\output2.dfx as an example:

  A B
1 =file(“D:\\files\\Data1.txt”) =A1.import@t()
2 for IDs >B1.modify(A2,Value:Amount)
3 >A1.export@t(B1)  

The file uses two parameters: IDs and Value, as shown below:

esProc_integration_commandline_6

The cellset is to import the Data1.txt file just created, modify some of the records with specified sequence numbers so as to make their Amount fields are equal to the specified Value and store them in the file again. The prompts displayed on the screen during execution are as follows:

esProc_integration_commandline_7

Two parameters, one is a sequence, [2,3,5,7,11] and the other is an integer, 99999, are input while the cellset file, output2.dfx, is called. Similar to a cross-cellset call, the input parameters will assign value to the cellset parameters according to their orders instead of their names during the command line call. In this case [2,3,5,7,11] assigns value to the first parameter, IDs and 99999 assigns value to the second parameter, Value. After the command line is executed, data in Data1.txt will have been modified:

esProc_integration_commandline_8

2. Cellset files with return results

If the esprocx command is used directly at the command line, the result won’t be displayed on the screen by default. If the return result of the dfx file is to be displayed, -R option needs to be used in execution. Similar to the cellset file called by the call function, the dfx file must return the result using return (or result) statement. Take the following cellset file, D:\files\calculate1.dfx, as an example:

  A B
1 =days(Day) =string(Day,”EEE”)
2 return A1 return B1

This cellset will return the total number of days of the month in which the specified date occurs and compute what day the specified date is. It uses Day as one of its parameters:

esProc_integration_commandline_10

Let’s first look at the execution with -R option:

esProc_integration_commandline_11

Here no parameters have been set during the execution and a default parameter, 01/01/2000, is used for the computation. You can see that A2 and B2 respectively return a result using return statement. The results will be listed respectively after the computation is finished.

If a parameter is to be set, its data type should be date. As a parameter of date or time type should be in some kind of format, you need to set its format in the configuration file, config.xml, which is located in esProc\config path in esProc’s installation directory:

<dateFormat>MM/dd/yyyy</dateFormat>

<timeFormat>HH:mm:ss</timeFormat>

<dateTimeFormat>MM/dd/yyyy HH:mm:ss</dateTimeFormat>

The execution is what the following shows if a parameter is set for the call:

esProc_integration_commandline_12

At this point, you get the total number of days of the month in which February 22, 2012 occurs and what day this date is.

Different from the previous cellset file, the following one, D:\files\calculate2.dfx, returns the results as a sequence:

  A B
1 =days(Day) =string(Day,”EEE”)
2 return [A1,B1]  

The execution is as follows:

esProc_integration_commandline_14

It can be seen that members of the resulting sequence are listed respectively, each having a row.

Here comes the last sample of the cellset file – D:\files\calculate3.dfx:

  A B
1 $(demo) select * from CITIES $select * from STATES
2 =A1.switch(STATEID,B1) =A2.new(CID,NAME:City,STATEID.NAME:State)
3 =B2.select(left(City,1)==Letter)  
4 return A3  

The cellset file uses a parameter – Letter:

esProc_integration_commandline_16

This cellset uses the database data. In this case the database connection needs to be configured in config.xml in the esProc\config path in the esProc installation directory:

<DBList>

<DB name=”demo”>

<property name=”url” value=”jdbc:hsqldb:hsql://127.0.0.1/demo”/>

<property name=”driver” value=”org.hsqldb.jdbcDriver”/>

<property name=”type” value=”HSQL”/>

<property name=”user” value=”sa”/>

<property name=”password” value=””/>

<property name=”batchSize” value=”1000″/>

<property name=”autoConnect” value=”true”/>

<property name=”useSchema” value=”false”/>

<property name=”addTilde” value=”false”/>

</DB>

</DBList >

Please refer to related documents for detailed configuration method.

When the program is executed, the result is as follows:

esProc_integration_commandline_17

To set a parameter of string type, it’s not necessary to surround it with double quotation marks. Cities whose names start with B are listed in the above result. For the result of the type of a table sequence or a record sequence, each record is a row and fields are separated from each other by tabs.

The above configuration file, config.xml, is also used by the Integration Development Environment (IDE), so information, like date format and datasource configuration, can be edited on the IDE interface. Click Tool>Option on the menu bar and configure the information on the Environment of Option window:

esProc_integration_commandline_18

Click Tool>Datasource connection and configure information, like the database connection parameter, in the datasource manager. For detailed configuration method, please refer to esProc Accesses Databases: Database Configuration

FAVOR (0)
Leave a Reply
Cancel
Icon

Hi,You need to fill in the Username and Email!

  • Username (*)
  • Email (*)
  • Website