SQLite studio does not support square root function, so I have defined it in function editor as
proc SqrtA {num} { set ans [expr {sqrt($num)}] return $ans }
with function nameSqrtA
and one input argument, lang. tcl but when I am using it in query editor, I am not getting the square root.
For example I had tried for:
select SqrtA(9);
Can anyone please help me, in how to include square root function in SQLite studio?
Best Answer
You should not define a Tcl procedure inside body of SQL function. Instead use only following line as function implementation (and nothing more):
If you define a
proc
inside function definition you will be creating a new Tcl procedure each time you call the SQL function, which makes no sense, especially when you don't call that procedure in the end.Anyway, stick to the simple implementation as mentioned above. That should do the work.