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  

F

  • Built-in variable
  • Built-in function
  • fetch()
    Description
    Fetches a specified number of rows by SIZE from the result of SQL statement by the sql() function
    By calling fetch() sequentially, you can aquire from the rows after the rows previously fetched.
    If the result rows of the function fetch() are smaller than the SIZE, it returns the smaller result rows, instead of the SIZE
    If the SIZE is set to 0, it returns all data.
    Note that it may consume so much system resources if the result rows are too much data.
    The fetch() returns a result as an array
    If the DIRECTION is set to 0, or not specified, it returns one row of data specified in each element.
    One row of data also stores the data in associative array. It stores column data in each element of array.
    If the DIRECTION is set to 1, it returns the result in associative array. It also stores the specified field data in each element of the array.
    To access the data, it uses the field names as keys.
    Syntax
    ret = fetch(count,direction)
    Parameters
    count:Number of rows to be fetched
    direction:Method of storing the return value
    Return Value
    array:Fetched line
    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へ
    floor()
    Description
    Returns the largest value that is equal to or less than an actual count
    Syntax
    ret = floor(n)
    Parameters
    n:
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // input number:2.759
    // floor(2.759) = 3
    //
    
    exit get_floor()
    
    function get_floor()
    
    	local input = 0
    
    	input = getopt('input number: ')
    	print("floor("&input&") = "& floor(input) )
    
    endfunction
    
    
    Topへ
    FALSE
    Description
    Boolean value (FALSE)
    Read / Write
    r
    Type
    number
    initial value
    0
    Topへ
    flush()
    Description
    Flush the disk cache without closing the file.
    A specified file must be opened in read mode
    Normally, this function is not used
    Syntax
    ret = flush(filehandle)
    Parameters
    filehandle:File number
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    5File number error
    Example
    //[result example]
    //
    // 1 : hello world
    // 2 : foge
    // 3 : foo
    // 4 : goo
    // 5 : boo
    //
    
    get_fileline_to_flush()
    exit
    
    function get_fileline_to_flush()
    
    	local i
    	local lineString = ''
    	local fno
    
    	fno = open('foo.txt', read)
    
    	loop i=1; ; i++
    		lineString = readline(fno)
    		if ERROR != 0
    			break
    		endif
    
    		print('${i} : ${lineString}', STDOUT)
    		flush(STDOUT)
    
    	endloop
    
    	close(fno)
    
    endfunction
    
    
    Topへ
    formattime()
    Description
    Converts the time in the number of seconds since the epoch (00:00:00, January 1, 1970) into the time in a specified format
    FORMAT is composed of at least one format element. Percent sign (%) is added before the format element.
    If a format element does not include the percent sign (%) before the letter, it is not converted and returned as a string.
    FORMAT is specified by the following format element.
    %a: Abbreviated name (e.g. Mon, Sun) of the day of the week
    %A: Full name of the day of the week
    %b: Abbreviated name (e.g. Jun, Sep) of the month of the year
    %B: Full name of the month of the year
    %c: Date and time based on the current locale
    %C: Date and time based on the current locale (Tuesday, March 14, 1995, 12:41:29)
    %d: Day of month (01-31)
    %#d: Day of month (1-31: 0 in the 1st position from the left is removed)
    %H: Hour of day (00-23)
    %#H: Hour of day (0-23: 0 in the 1st position from the left is removed)
    %I: Hour of day (01-12)
    %#I: Hour of day (1-12: 0 in the 1st position from the left is removed)
    %j: Day of year (001-366)
    %#j: Day of year (1-366: 0 in the positions from the left is removed)
    %m: Month (01-12)
    %#m: Month (1-12: 0 in the position from the left is removed)
    %M: Minute (00-59)
    %#M: Minute (0-59: 0 in the position from the left is removed)
    %p: AM or PM based on locale
    %S: Second (00-59)
    %#S: Second (0-59: 0 in the position from the left is removed)
    %U: Week of year (00-51: Sunday is the first day of the week)
    %#U: Week of year (0-51: Sunday is the first day of the week, 0 in the position from the left is removed)
    %w: Day of week (0-6: Sunday is 0)
    %#w: Day of week (0-6: Sunday is 0, 0 in the position from the left is removed)
    %W: Week of year (00-51: Monday is the first day of the week)
    %#W: Week of year (0-51: Monday is the first day of the week, 0 in the position from the left is removed)
    %x: Date based on the current locale
    %#x: Date based on the current locale (Tuesday, March 14, 1995)
    %X: Time based on the current locale
    %y: Last two digits of the year (00-99)
    %#y: Last two digits of the year (00-99: 0 in the 2nd digit removed)
    %Y: A complete 4-digit year
    %#Y: A complete 4-digit year (0 in the first digit is removed)
    %z(%Z): Name of time zone. %z should be left blank if time zone is not specified.
    %%: Percent sign (%)
    Syntax
    ret = formattime(sec,format)
    Parameters
    sec:Time elapsed from 0:00, January 1, 1970 (seconds)
    format:Format
    Return Value
    string:Conversion result
    NULL:Error or conversion result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // * 4 digit year number                      [%Y ] : 2004
    //   ・
    //   ・
    //   ・
    // * date and time                            [%C ] : Fri Jan 23 16:56:15 JST 2004
    // * date and time                            [%c ] : Fri Jan 23 16:56:15 2004
    // * date (name base)                         [%#x] : %#x
    // * date (number base)                       [%x ] : 01/23/04
    // * time                                     [%X ] : 16:56:15
    // * AM/PM                                    [%p ] : PM
    // * time zone                                [%z ] : %z
    // * same as %z                               [%Z ] : JST
    // * persent sign                             [%% ] : %
    //
    
    exit getFormatTime()
    
    function getFormatTime()
    
    	local b_time, f_time, msg, opt, i
    	local aFormat = { /* [0]: format, [1]: description */\
    					  { '%Y',  '4 digit year number' } \
    					, { '%#Y', 'same as %Y' } \
    					, { '%y',  'last 2 digit year number (00-99)' } \
    					, { '%#y', 'last 2 digit year number ( 0-99)' } \
    					, { '%m',  'month number (01-12)' } \
    					, { '%#m', 'month number ( 1-12)' } \
    					, { '%B',  'complete month name' } \
    					, { '%b',  '3 letter month name' } \
    					, { '%U',  'week of the year (Sunday is first (00-51)' } \
    					, { '%#U', 'week of the year (Sunday is first ( 0-51)' } \
    					, { '%W',  'week of the year (Monday is first (00-51)' } \
    					, { '%#W', 'week of the year (Monday is first ( 0-51)' } \
    					, { '%A',  'complete day of the week name' } \
    					, { '%a',  '3 letter day of the week name' } \
    					, { '%w',  'day of the week number (0-6)' } \
    					, { '%#w', 'same as %w' } \
    					, { '%d',  'day number (01-31)' } \
    					, { '%#d', 'day number ( 1-31)' } \
    					, { '%H',  'hour (00-23)' } \
    					, { '%#H', 'hour ( 0-23)' } \
    					, { '%I',  'hour (01-12)' } \
    					, { '%#I', 'hour ( 1-12)' } \
    					, { '%M',  'minute (00-59)' } \
    					, { '%#M', 'minute ( 0-59)' } \
    					, { '%S',  'second (00-59)' } \
    					, { '%#S', 'second ( 0-59)' } \
    					, { '%j',  'day of the year (001-366)' } \
    					, { '%#j', 'day of the year (  1-366)' } \
    					, { '%C',  'date and time' } \
    					, { '%c',  'date and time' } \
    					, { '%#x', 'date (name base)' } \
    					, { '%x',  'date (number base)' } \
    					, { '%X',  'time' } \
    					, { '%p',  'AM/PM' } \
    					, { '%z',  'time zone' } \
    					, { '%Z',  'same as %z' } \
    					, { '%%',  'persent sign' } \
    					}
    
    	b_time = curtime()
    
    	loop i=0; i<count(aFormat); i++
    		msg = rpad(aFormat[i][1], 40)
    		opt = rpad(aFormat[i][0], 3)
    		f_time = formattime(b_time, aFormat[i][0])
    		print('* ' & msg & ' [' & opt & '] : ' & f_time, stdout)
    	endloop
    
    endfunction
    
    Topへ
    file_mod_time()
    Description
    Returns the last modified time in the number of seconds since 00:00:00 UTC, January 1, 1970
    Syntax
    ret = file_mod_time(filename)
    Parameters
    filename:File name for checking the last update time.
    Return Value
    1 or more:Last file update
    0:Fail
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    //modified time = 2003/11/20 15:21:07
    //
    
    run()
    exit
    
    function run()
    	local mod_time
    	
    	mod_time = file_mod_time('sample_file_mod_time.eel')
    	print('modified time = ${formattime(mod_time, "%Y/%m/%d %H:%M:%S")}')
    
    endfunction
    
    
    Topへ
    filecopy()
    Description
    Copies file
    Syntax
    ret = filecopy(filename1,filename2)
    Parameters
    filename1:source file name
    filename2:destination file name
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    13File copy error
    Example
    run()
    exit
    
    function run()
    
    	filecopy('sample_filecopy.eel', 'copy_file1')
    
    endfunction
    
    
    Topへ
    filedelete()
    Description
    Deletes file
    Syntax
    ret = filedelete(filename)
    Parameters
    filename:file name to be deleted
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    12File delete error
    Example
    run()
    exit
    
    function run()
    
    	filecopy('sample_filedelete.eel', 'copy_file4')
    	filedelete('copy_file4')
    
    endfunction
    
    
    Topへ
    filemove()
    Description
    Moves file
    Syntax
    ret = filemove(filename1,filename2)
    Parameters
    filename1:source file name
    filename2:destination file name
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    16File copy error
    Example
    run()
    exit
    
    function run()
    
    	filecopy('sample_filemove.eel', 'copy_file2')
    	filemove('copy_file2', 'copy_file3')
    
    endfunction
    
    
    Topへ
    fileformat()
    Description
    Sets the format of the data read from a text file by the fileread()
    If the LEN is set to the number, it returns the number specified by LEN of the string with column name specified by COLNAME.
    If the LEN is set to the the delimiter, the fileread() function accepts string charcters between delimiters as one field.
    If the pair of LEN and COLNAME is specified sequentially, it delimits the string and makes multiple fields.
    You can specify the first row to start reading by setting the START. If not specified, the START is set to 0.
    You can specify the last row to finish reading by setting the END. If not specified, the END is set to 0.
    Syntax
    ret = fileformat(start,end,colname,len,colname, len, { … })
    Parameters
    start:Start line
    end:End line
    colname:Array name (character string)
    len:Number of characters or delimiters
    colname, len, { … }:
    Return Value
    0:Error
    1:Success
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // 01/01/2004 Thursday is New Year's Day
    // 02/14/2004 Saturday is St. Valentain's Day
    // 04/01/2004 Thursday is April Fool's Day
    // 10/31/2004 Sunday   is Helloween
    // 12/25/2004 Saturday is Christmas
    //
    
    run()
    exit
    
    function run()
    	local fileName = 'c:testdata01.txt'
    	local tab
    	local i
    
    	fileformat(0, 0, 'C1', ',', 'C2', ',', 'C3')
    	xsql select C1, C2, C3 from fileread('${fileName}');
    	tab = xfetch(0)
    	xclose()
    
    	loop i=0;i<count(tab); i++
    		print('${tab[i]["C1"]} ${tab[i]["C2"]} is ${tab[i]["C3"]}', stdout)
    	endloop
    
    endfunction
    
    /*
    [testdata01.txt]
    01/01/2004,Thursday,New Year's Day
    02/14/2004,Saturday,St. Valentain's Day
    04/01/2004,Thursday,April Fool's Day
    10/31/2004,Sunday  ,Helloween
    12/25/2004,Saturday,Christmas
    */
    
    Topへ
    fileread()
    Description
    Pseudo function
    File contents can be accessed by considering as a virtual table.
    A single row in a file is considered as a row. This row is split and each piece is considered as column.
    Column name is specified by colname.
    If the LEN is set to the integer, it reads the character string as a column name specified in colname.
    If the LEN is set to the delimiter, it reads the character strings up to the first delimiter as a single line.
    If the LEN is set to the number, it returns the number specified by LEN of the string with column name specified by COLNAME.
    If the LEN is set to the the delimiter, the fileread() function accepts string charcters between delimiters as one field.
    Syntax
    ret = fileread(filename,colname,len,colname1, len1, { … })
    Parameters
    filename:
    colname:
    len:
    colname1, len1, { … }:
    Return Value
    0:Success
    11:Argument error
    12:File open error
    System Return Value
    ERROR
    0Success
    11Argument error
    12File open error
    Example
    //[result example]
    //
    // 01/01/2004 Thursday is New Year's Day
    // 02/14/2004 Saturday is St. Valentain's Day
    // 04/01/2004 Thursday is April Fool's Day
    // 10/31/2004 Sunday   is Helloween
    // 12/25/2004 Saturday is Christmas
    //
    
    run()
    exit
    
    function run()
    	local fileName = 'c:testdata01.txt'
    	local tab
    	local i
    
    	xsql select C1, C2, C3 from fileread('${fileName}', 'C1', ',', 'C2', ',', 'C3');
    	tab = xfetch(0)
    	xclose()
    
    	loop i=0;i<count(tab); i++
    		print('${tab[i]["C1"]} ${tab[i]["C2"]} is ${tab[i]["C3"]}', stdout)
    	endloop
    
    endfunction
    
    /*
    [testdata01.txt]
    01/01/2004,Thursday,New Year's Day     
    02/14/2004,Saturday,St. Valentain's Day
    04/01/2004,Thursday,April Fool's Day   
    10/31/2004,Sunday  ,Helloween          
    12/25/2004,Saturday,Christmas          
    */
    
    Topへ

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