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  

P

  • Built-in variable
  • Built-in function
  • plsql()
    Description
    Executes procedures and packages
    If you want to get the value from the package, describe SQeeeL variable in the SQL statement directly and prefix the variable with ':'.
    Syntax
    ret = plsql(sql_statement)
    Parameters
    sql_statement:SQL statement
    Return Value
    1:Success
    0:Error
    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
    require 'dboralib.slb'
    
    run()
    exit
    
    function run()
    
    	connect scott/tiger
    	plsql dbms_stats.gather_schema_stats('scott');
    
    	if DBERR != 0
    		print(DBERRMSG, stdout)
    	endif
    
    	logout
    
    endfunction
    
    Topへ
    percent()
    Description
    Returns the percentage of the ratio of value of each element against the summed value in array variable.
    Syntax
    ret = percent(array)
    Parameters
    array:array
    Return Value
    array:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // 18 is 16.981132%.
    //  9 is 8.490566%.
    //  6 is 5.660377%.
    //  5 is 4.716981%.
    // 10 is 9.433962%.
    // 10 is 9.433962%.
    // 18 is 16.981132%.
    //  2 is 1.886792%.
    //  6 is 5.660377%.
    // 22 is 20.754717%.
    //
    
    exit Run()
    
    function Run()
    
    	local arr[10] = {18, 9, 6, 5, 10, 10, 18, 2, 6, 22}
    	local percent_arr
    
    	percent_arr = percent(arr)
    
    	local i
    
    	loop i=0; i<count(arr); i++
    		print('The rate for which ${arr[i]} accounts is ${percent_arr[i]}%.', stdout)
    	endloop
    
    endfunction
    
    
    Topへ
    pow()
    Description
    Returns the result of raising e (natural logarithm) to a given power (n)
    Syntax
    ret = pow(e,n)
    Parameters
    e:
    n:
    Return Value
    real number:Result
    0:Error or result
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // input number_x: 2
    // input number_x: 8
    // pow(2,8) = 256.000000
    //
    
    exit get_pow()
    
    function get_pow()
    
    	local input_x = 0
    	local input_y = 0
    
    	input_x = getopt('input number x: ')
    	input_y = getopt('input number y: ')
    	print("pow("&input_x&","&input_y&") = "& pow(input_x,input_y) )
    
    endfunction
    
    
    Topへ
    PAR
    Description
    Arguments used at command prompt
    Arguments are entered in an array in order of arguments passing to the command prompt.
    Read / Write
    r
    Type
    array
    initial value
    undefined
    Topへ
    PAR_CNT
    Description
    Number of arguments used at command prompt
    Read / Write
    r
    Type
    number
    initial value
    undefined
    Topへ
    PID
    Description
    Process ID
    Read / Write
    r
    Type
    number
    initial value
    undefined
    Topへ
    print()
    Description
    Outputs specified character string to the file
    The output file must be opened in write mode
    Syntax
    ret = print(string,filehandle)
    Parameters
    string:character string to be printed
    filehandle:File number
    Default: system variable STDOUT
    You can specify STDOUT, STDERR, and STDLOG which are defined as system variable.
    Return Value
    NULL:Fail or printed character string
    string:Printed character string
    System Return Value
    ERROR
    0Success
    1Argument error
    2Output error
    5File number error
    See Also
    Example
    //[result example]
    //
    // Hello
    // World !
    // ********************
    // HelloWorld !
    //
    
    
    make_newfile3()
    exit
    
    function make_newfile3()
    
    	local fno
    
    	fno = open('boo.txt', new)
    		print('Hello', fno)
    		print('World !', fno)
    		print('********************', fno)
    		printstring('Hello', fno)
    		printstring('World !', fno)
    	close(fno)
    
    endfunction
    
    
    
    Topへ
    printstring()
    Description
    Outputs specified character string to the file
    Equivalent to print, except for no line feed
    The output file must be opened in write mode
    Syntax
    ret = printstring(string,filehandle)
    Parameters
    string:Character string to be printed
    filehandle:File number
    Default: system variable STDOUT
    You can specify STDOUT, STDERR, and STDLOG which are defined as system variable.
    Return Value
    NULL:Fail or printed character string
    string:Printed character string
    System Return Value
    ERROR
    0Success
    1Argument error
    2Output error
    5File number error
    See Also
    Example
    //[result example]
    //
    // Hello
    // World !
    // ********************
    // HelloWorld !
    //
    
    
    make_newfile3()
    exit
    
    function make_newfile3()
    
    	local fno
    
    	fno = open('boo.txt', new)
    		print('Hello', fno)
    		print('World !', fno)
    		print('********************', fno)
    		printstring('Hello', fno)
    		printstring('World !', fno)
    	close(fno)
    
    endfunction
    
    
    
    Topへ
    pop()
    Description
    Pops and returns the last value from the array variable
    Poped element is omitted from the source array and the array is shortened by one element.
    The combination of pop and push functions will enable easy implementation of stack mechanism.
    Syntax
    ret = pop(array)
    Parameters
    array:Array to pop an element
    Example
    //[result example]
    //
    // --------------------------------
    // a_array[0] => elem1
    // a_array[1] => elem2
    // a_array[2] => elem3
    //
    // *** s_elem = pop(a_array) ***
    //
    // a_array[0] => elem1
    // a_array[1] => elem2
    //
    // s_elem => elem3
    // --------------------------------
    
    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 = pop(a_array) ***\n", stdout)
    
    	// pop
    	s_elem = pop(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へ
    push()
    Description
    Pushes the value onto the end of array variable
    Number of elements in array increases by 1
    If non-array variable is specified, the length of the array becomes two elements of which the original element will be 0th element and the pushed element will be the 1st element.
    The combination of push and pop functions will enable easy implementation of stack mechanism.
    Syntax
    ret = push(array,value)
    Parameters
    array:Array to add an element
    value:Element to be added
    Example
    run()
    exit(0)
    
    function run()
    
    	local a_array = { 'elem1', 'elem2', 'elem3' }
    	local s_str = 'aaa'
    	local i
    
    	print("[ sample1 ]\n", stdout)
    
    	loop i=0; i<count(a_array); i++
    		print("a_array[" & i & "] => " & a_array[i], stdout)
    	endloop
    
    	print("\n*** push(a_array, 'elem4') ***\n", stdout)
    
    	// push
    	push(a_array, 'elem4')
    
    	loop i=0; i<count(a_array); i++
    		print("a_array[" & i & "] => " & a_array[i], stdout)
    	endloop
    	print("\n", stdout)
    
    	print("[ sample2 ]\n", stdout)
    
    	print("s_str = 'aaa'", stdout)
    	print("\n*** push(s_str, 'bbb') ***\n", stdout)
    
    	// push
    	push(s_str, 'bbb')
    
    	loop i=0; i<count(s_str); i++
    		print("s_str[" & i & "] => " & s_str[i], stdout)
    	endloop
    
    	print("--------------------------------", stdout)
    
    endfunction
    
    
    
    Topへ

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