Home | About SQeeL | Document | DownLoad | Mail Japanese
Home > Document > SQeeL Reference
A B C D E F G H I J L M N O P R S T U X Y  

S

  • Built-in variable
  • Built-in function
  • setcookie()
    Description
    Sets the name and value of the cookie
    The value of the cookie is stored on the client computer. You can refer to the value using the getcookie() function.
    Set the expire time with the bintime() function or the curtime() function plus the number of seconds before you want it to expire
    If cookie expires, the browser will delete the value of the cookie
    If the expiration date is omitted, the cookie is stored in a memory of a browser and will be deleted when the browser closes.
    You can also delete cookie from the browser by setting the past time for expire time
    You can make the cookie available on all sub-domains or sub-directories by specifying DOMAIN and PATH.
    If DOMAIN and PATH is not set, the host where a SQeeL program is running will be set. Cookie will be available in this SQeeL program.
    Cookies are available for all files under the specified path.
    If PATH is not set, the cookies will be available within the directory where a SQeeL program is running
    Note that path may be used differently based on the type of browser and versions.
    If SECURE is set to TRUE, the browser returns cookie only when a secure HTTPS connection exists.
    Syntax
    ret = setcookie(name,value,expires,path,secure)
    Parameters
    name:Cookie name
    value:Cookie value
    expires:Expiration date
    Specify 0 if you want to omit.
    Specify WWW server name issuing cookie.
    If you omit, specify the character string ("""") of the length 0.
    path:Path name
    Specify a path name (URL) issuing cookie.
    If you omit, specify the character string ("""")of the length 0
    secure:Specify a security flag with an integer.
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    Topへ
    sql()
    Description
    Executes SQL statements(DML and DDL)
    In the select statement, the result data have not been selected until the xfecth() or sqlprint() are executed
    Returns the number of rows processed in the execution of the DELETE, INSERT, and UPDATE statements
    Syntax
    ret = sql(sql_statement)
    Parameters
    sql_statement:Specify the SQL statement
    Return Value
    1 or more:Number of lines processed
    0:Fail
    System Return Value
    ERROR
    0Success
    1Argument error
    100Oracle error
    DBERR
    文字列Database error number
    DBERRMSG
    文字列Database message
    DBUSER
    文字列Connected username to database
    Requirements
    dboralib.slb
    Example
    //[result example]
    //
    // DEPT table has 5 data
    //
    
    require 'dboralib.slb'
    
    run()
    exit
    
    function run()
    
    	local dept
    
    	connect scott/tiger
    	sql select DEPTNO, DNAME, LOC from DEPT;
    
    	if DBERR eq 0
    		dept = fetch(0)
    		print('DEPT table has '&count(dept)&' data', stdout)
    	else
    		print(DBERRMSG, stdout)
    	endif
    
    	logout
    
    endfunction
    
    Topへ
    sqlformat()
    Description
    Sets the format of the data outputted to the file by the sqlprint()
    Sets the number of letter for each column sequentially
    Syntax
    ret = sqlformat(length,{ … })
    Parameters
    length:Number of strings per column
    Default (maximum column length of the specified table)
    { … }:
    Return Value
    1:Success
    System Return Value
    ERROR
    0Success
    Requirements
    dboralib.slb
    Example
    //[result example]
    //
    //    DEPTNO DNAME      LOC
    //        10 ACCOUNTING NEW YORK
    //        20 RESEARCH   DALLAS
    //        30 SALES      CHICAGO
    //        40 OPERATIONS BOSTON
    //        50 LOGISTICS  LOS ANGELE
    //
    
    require 'dboralib.slb'
    
    run()
    exit
    
    function run()
    
    	connect scott/tiger
    	sql select DEPTNO, DNAME, LOC from DEPT;
    
    	if DBERR eq 0
    		sqlformat(10, 10, 10)
    		sqlprint(0, stdout)
    	else
    		print(DBERRMSG, stdout)
    	endif
    
    	logout
    
    endfunction
    
    Topへ
    sqlprint()
    Description
    Outputs the result data of the select statement of sql() to a specified file (FILEHANDLE)
    You can set the number of rows (CNT) to be outputted
    To output the result continously, this function is called again.
    Syntax
    ret = sqlprint(count,filehandle)
    Parameters
    count:Number of rows to be fetched from Oracle
    filehandle:File number to be printed
    Return Value
    1 or more:Number of lines processed
    0:Error or number of printed lines
    System Return Value
    ERROR
    0Success
    1Argument error
    100Oracle error
    DBERR
    文字列Database error number
    DBERRMSG
    文字列Database eeror message
    DBUSER
    文字列Connected username to database
    Requirements
    dboralib.slb
    Example
    //[result example]
    //
    //    DEPTNO DNAME      LOC
    //        10 ACCOUNTING NEW YORK
    //        20 RESEARCH   DALLAS
    //        30 SALES      CHICAGO
    //        40 OPERATIONS BOSTON
    //        50 LOGISTICS  LOS ANGELE
    //
    
    require 'dboralib.slb'
    
    run()
    exit
    
    function run()
    
    	connect scott/tiger
    	sql select DEPTNO, DNAME, LOC from DEPT;
    
    	if DBERR eq 0
    		sqlformat(10, 10, 10)
    		sqlprint(0, stdout)
    	else
    		print(DBERRMSG, stdout)
    	endif
    
    	logout
    
    endfunction
    
    Topへ
    sqrt()
    Description
    Returns the square root of a given number
    Syntax
    ret = sqrt(e)
    Parameters
    e:
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    14Argument is negative
    Example
    //[result example]
    //
    // input number:3
    // sqrt(3) = 1.732051
    //
    
    exit get_sqrt()
    
    function get_sqrt()
    
    	local input = 0
    
    	input = getopt('input number: ')
    	print("sqrt("&input&") = "& sqrt(input) )
    
    endfunction
    
    
    Topへ
    stddev()
    Description
    Returns the standard deviation of array variable
    Syntax
    ret = stddev(array)
    Parameters
    array:Array to determine the standard deviation
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // Standard deviation is 6.244998
    // 
    
    exit Run()
    
    function Run()
    
    	local arr[3] = {18, 9, 6}
    	local stddev_arr
    
    	stddev_arr = stddev(arr)
    
    	print('Standard deviation is ${stddev_arr}', stdout)
    
    endfunction
    
    
    Topへ
    sum()
    Description
    Returns the summed value of array variable
    Syntax
    ret = sum(array)
    Parameters
    array:Array to sum the values
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // The sum total is 6.000000
    //
    
    exit Run()
    
    function Run()
    
    	local arr[3] = {1, 2, 3}
    	local sum_arr
    
    	sum_arr = sum(arr)
    
    	print('The sum total is ${sum_arr}', stdout)
    
    endfunction
    
    
    Topへ
    SOURCE
    Description
    Name of the file that is currently executed (including extention)
    Read / Write
    r
    Type
    string
    initial value
    undefined
    Topへ
    STDERR
    Description
    Virtual file number in standard error output
    Read / Write
    r
    Type
    number
    initial value
    2
    See Also
    Topへ
    STDLOG
    Description
    Read / Write
    r
    Type
    number
    initial value
    3
    See Also
    Topへ
    STDOUT
    Description
    Virtual file number in standard output
    Read / Write
    r
    Type
    number
    initial value
    1
    See Also
    Topへ
    setenv()
    Description
    Sets the environmental variable specified by argument
    Syntax
    ret = setenv(string1,string2)
    Parameters
    string1:Environment variable name
    string2:setting value
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    //ABC=sample
    //
    
    run()
    exit
    
    function run()
    
    	setenv('ABC', 'sample')
    	print('ABC=${getenv("ABC")}')
    
    endfunction
    
    
    Topへ
    sleep()
    Description
    Suspend the execution of program for specified period (second)
    Syntax
    ret = sleep(sec)
    Parameters
    sec:Sleep time (seconds)
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    //input suspend time(sec): 30
    //now suspending...
    //30 seconds suspended.
    //
    
    sleeptime()
    exit
    
    function sleeptime()
    
    	local input_time = 10
    
    	input_time = getopt('input susptend time(sec): ')
    	print('now suspending...')
    	sleep(input_time)
    	print('${input_time} seconds susptended.')
    
    endfunction
    
    Topへ
    system()
    Description
    Executes OS command
    Syntax
    ret = system(string)
    Parameters
    string:command line
    Return Value
    0:Error or exit code of command
    1 or more:exit code
    -1:Error
    System Return Value
    ERROR
    0Success
    1Argument error
    6Process startup fails
    Example
    run()
    exit(0)
    
    function run()
    
    	local s_file
    	local n_rc = 0
    
    	s_file = getopt('delete file: ')
    
    	print("\n*** system(\"cmd /c del /q " & s_file & "\") ***\n", stdout)
    
    	// system
    	n_rc = system('cmd /c del /q ' & s_file)
    
    	if n_rc == 0
    		print("completed.", stdout)
    	endif
    
    	print("--------------------------------", stdout)
    
    endfunction
    
    Topへ
    shift()
    Description
    Shifts the first value of the array off and returns it
    Shited element is omitted from the source array. The array is shortened by one element and rest of the elements is moved down.
    The combination of push and shift will enable easy implementation of FIFO queue.
    Syntax
    ret = shift(array)
    Parameters
    array:Array to shift an element
    Example
    //[result example]
    //
    // --------------------------------
    // a_array[0] => elem1
    // a_array[1] => elem2
    // a_array[2] => elem3
    //
    // *** s_elem = shift(a_array) ***
    //
    // a_array[0] => elem2
    // a_array[1] => elem3
    //
    // s_elem => elem1
    // --------------------------------
    //
    
    run()
    exit(0)
    
    function run()
    
    	local a_array = { 'elem1', 'elem2', 'elem3' }
    	local s_elem
    	local i
    
    	print("--------------------------------", stdout)
    	loop i=0; i<count(a_array); i++
    		print("a_array[" & i & "] => " & a_array[i], stdout)
    	endloop
    
    	print("\n*** s_elem = shift(a_array) ***\n", stdout)
    
    	// shift
    	s_elem = shift(a_array)
    
    	loop i=0; i<count(a_array); i++
    		print("a_array[" & i & "] => " & a_array[i], stdout)
    	endloop
    	print("", stdout)
    
    	print("s_elem => " & s_elem)
    
    	print("--------------------------------", stdout)
    
    endfunction
    
    
    
    Topへ
    sort()
    Description
    Sorts array based on the conditions.
    Order condistions are as follows:
    + : ascending sort in string comparison order
    + : descending sort in string comparison order
    +N : ascending sort in numeric comparison order
    + : descending sort in numeric comparison order
    Null character string: No sorting
    Multiple arrays can be sorted as a table
    In this case, first, all array is sorted in array1. If the value is the same in array1, they will be sorted in array2. This continues in the same manner.
    string2 is the order condition for array2.
    Syntax
    ret = sort(count,string1,array1,string2, array2, { … })
    Parameters
    count:Number of elements in array
    string1:Sort condition
    array1:Array to be sorted
    string2, array2, { … }:Add when multiple arrays are sorted at a time.
    You can specify multiple sort conditions and arrays as a pair.
    Return Value
    1:Success
    0:Fail
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // 3.000000
    // 6.000000
    // 9.000000
    // 18.000000
    // 27.000000
    // 100.000000
    //
    
    exit Run()
    
    function Run()
    
    	local arr[6] = {18, 9, 6, 27, 100, 3}
    	local sort_arr
    	local i
    
    	sort(6, '+N', arr)
    
    	loop i=0; i<count(arr); i++
    		print('${arr[i]}', stdout)
    	endloop
    
    endfunction
    
    
    Topへ
    split()
    Description
    Splits a string into a list of strings by a specified delimiter and returns the list as array variable.
    Multiple delimiters can be specified.
    Syntax
    ret = split(delim,string)
    Parameters
    delim:Delimiter
    string:Character string
    Return Value
    0:Error
    array:Array of split character strings
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // input words : to be or not to be that is the question
    // word[0] : to
    // word[1] : be
    // word[2] : or
    // word[3] : not
    // word[4] : to
    // word[5] : be
    // word[6] : that
    // word[7] : is
    // word[8] : the
    // word[9] : question
    //
    
    run()
    exit
    
    function run()
    
    	local input_str
    	local w_array, i
    
    	input_str = getopt('input words : ')
    	w_array = split(' ', input_str)
    
    	loop i=0; i<count(w_array); i++
    		print('word[${i}] : ${w_array[i]}', stdout)
    	endloop
    
    endfunction
    
    Topへ
    strdate()
    Description
    Returns Dates in YYYYMMDD format after converting the given time in the number of seconds since the epoch (00:00:00, January 1, 1970)
    Syntax
    ret = strdate(sec)
    Parameters
    sec:Time elapsed from 0:00, January 1, 1970 (seconds)
    Return Value
    string:Date in YYYYMMDD
    NULL:Error
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    Topへ
    strtime()
    Description
    Returns Time in HHMMSS format after converting the given time in the number of seconds since the epoch (00:00:00, January 1, 1970)
    Syntax
    ret = strtime(sec)
    Parameters
    sec:Time elapsed from 0:00, January 1, 1970 (seconds)
    Return Value
    string:Time in HHMMSS
    NULL:Error
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    Topへ
    systemtime()
    Description
    Measures the execution time of process(program)
    Returns the time in acutual number for each argument (second)
    Syntax
    ret = systemtime(sys,user,rtime)
    Parameters
    sys:CPU time executed in privilege mode
    user:CPU time executed in user mode
    rtime:Time required for execution
    Return Value
    1:Success
    System Return Value
    ERROR
    0Success
    Example
    //[result example]
    //
    // ....0
    // ....1
    // ....2
    // ....3
    // ....4
    // ....5
    // ....6
    // ....7
    // ....8
    // ....9
    // sys=0.000000 : user=0.000000 : rtime=10.024000
    //
    
    run()
    exit
    
    function run()
    	local t_sys, t_user, t_rtime, j
    	
    	loop j=0; j<10; j++
    		print('....${j}')
    		sleep(1)
    	endloop
    	
    	systemtime(t_sys, t_user, t_rtime)
    	print('sys=${t_sys} : user=${t_user} : rtime=${t_rtime}')
    
    endfunction
    
    
    Topへ
    substr()
    Description
    Extracts a substring out of STRING. Returns the string started at the Mth position in STRING with the length specified by N parameters.
    If M is non-negative, search the first character in STRING, counting from the first of STRING.
    If M is negative, leaves that many characters off the end of the string.
    You cannot specify 0 to M parameter
    If N is omitted, returns everything to the end of the string.
    You cannot specify the value less than 1to N parameter
    Syntax
    ret = substr(string,m,n)
    Parameters
    string:Character string to be converted
    m:Start location
    n:Number of strings to be extracted
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // 1:CD
    // 2:EF
    //
    
    run()
    exit
    
    function run()
    	local a = 'ABCDEFG'
    	
    	print(substr(a,3,2),stdout)
    	print(substr(a,-3,2),stdout)
    endfunction
    
    
    Topへ

    © Insight Technology, Inc. 1996-2003 All Rights Reserved.