
Description
Undo the any works done by the DML statements (SELECT, INSERT, UPDATE, or DELETE) in the current transaction after the previous commitment.
You can roll back the current transaction when you execute the logout() or the exit statement

Syntax
ret = rollback()

Return Value

System Return Value
ERROR
DBERR
DBERRMSG
DBUSER
| 文字列 | | Connected username to database |

Requirements
dboralib.slb

Example
require 'dboralib.slb'
function run()
connect( 'scott/tiger' )
sql insert into DEPT (DEPTNO, DNAME, LOC) values (50, 'LOGISTICS', 'LOS ANGELES');
if DBERR != 0
rollback
else
commit
endif
logout
endfunction
//fetch//
function run2()
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
//sqlformat//
//sqlprint//
function run3()
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
//plsql//
function run4()
connect scott/tiger
plsql dbms_stats.gather_schema_stats('scott');
if DBERR != 0
print(DBERRMSG,stdout)
endif
logout
endfunction

Description
Reads one row per line and returns it as character string.
A specified file must be opened in read mode

Syntax
ret = readline(filehandle)

Parameters

Return Value
| NULL | : | Fail or printed character string | |
| string | : | Printed character string | |

System Return Value
ERROR
| 0 | | Success |
| 1 | | Argument error |
| 5 | | File number error |
| 15 | | No character strings to read |

Example
//[result example]
//
// 1 : hello world
// 2 : foge
// 3 : foo
// 4 : goo
// 5 : boo
get_fileline()
exit
function get_fileline()
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)
endloop
close(fno)
endfunction

Description
Replace a character string(search_string) in the user variable to another one(replacement_string)
If replacement_string is omitted, all character strings matching search_string will be removed. If search_string is not found, it returns search_string.

Syntax
ret = replace(string,search_string,replacement_string)

Parameters
| string | : | Character string to be converted |
| search_string | : | Search string |
| replacement_string | : | Character string to be replaced Default: NULL |

Return Value
| string | : | Converted character string | |

System Return Value

Example
//[result example]
//
// 1:123DEFG
// 2:DEFG
//
run()
exit
function run()
local a = 'ABCDEFG'
print(replace(a,'ABC','123'),stdout)
print(replace(a,'ABC',''),stdout)
endfunction

Description
Pads the string specified by STRING2 to right side of STRING1. Returns the part of string specified by N parameters
If the length in characters of the value of STRING1 is longer than N bytes, returns the part in STRING1 within N parameters.

Syntax
ret = rpad(string1,n,string2)

Parameters
| string1 | : | Character string to be converted |
| n | : | Length of character string after conversion |
| string2 | : | Character string to be padded Default: single blank space |

Return Value
| string | : | Converted character string | |

System Return Value

Example
//[result example]
//
// 1:12345
// 2:12345678ab
//
run()
exit
function run()
local a = '12345678'
local b = 'abcdefg'
print(rpad(a, 5,b))
print(rpad(a,10,b))
endfunction

Description
Deletes the characters from the right side of the character string until the specified character(deletion_char) is found.
Deletes blank space from the character string when the character(deletion_char) is not specified

Syntax
ret = rtrim(string,deletion_char)

Parameters
| string | : | Character string to be converted |
| deletion_char | : | Character string containing a letter to be deleted Default: single blank space |

Return Value
| string | : | Converted character string | |

System Return Value

Example
//[result example]
//
// xyxyyXxyINSIGHT
//
run()
exit
function run()
local a = 'xyxyyXxyINSIGHTxyy'
local b = 'yx'
print(rtrim(a, b))
endfunction