私は erlang でこの関数を開発します:
get_user_cin_by_token(Token) ->
Q = qlc:q([{X#person.idcard} || X <- mnesia:table(person),
X#person.token =:= Token]),
case do(Q) of
[H] ->
{ok, H};
[] ->
{error, notfound}
end.
これは、この関数を実行したときの結果の例です:
{ok,{"07049200"}}
私の目標は、{}なしで「07049200」だけを表示することです
私はこの関数でテストします:
test3()->
case get_user_cin_by_token("93090612") of
{ok, H}-> G=string:substr(H, 2, length(H)-1),
io:format("~s~n",[G]);
{error, notfound}->io:format("error")
end.
しかし、このエラーが表示されます:
** exception error: bad argument
in function length/1
called as length({"07049200"})