SQLite Forum

Benefits of using SQLite functions
Login
This is a rather novice question I'm sure but could you please tell me if declaring a SQLite function results in efficiency of some sort or is mostly for convenience? Specifically, I was trying to understand if these two are really different in whether or not they bring database data into Tcl or handle it all in SQLite land, so to speak, and whether or not they write one large piece of data to disk in a single operation or perform a separate write operation for each individual update.

Thank you for considering my question.

proc normalize {string {form nfc}} {
    exec uconv -f utf-8 -t utf-8 -x "::$form;" << $string
}

dbws function normalize -returntype text -deterministic -directonly { normalize }

dbws eval { update src_original set uni_norm = normalize(original) }

versus:

dbws eval { select id, original from src_original } rowstep {
 set n [ normalize $rowstep(original) ]
 dbws eval { update src_original set uni_norm = $n where id = $rowstep(id) }
}