Without knowing anything else, all I can suggest is:
SELECT last_insert_rowid() as value
There's no need to cast or convert it.
Did you find the solution for your problem? I've just faced with exactly the same one.