1

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?

2

You should not define a Tcl procedure inside body of SQL function. Instead use only following line as function implementation (and nothing more):

expr {sqrt([lindex $argv 0])}

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.