create-function-sql ( class -- statement )


Vocabulary
db.postgresql

Inputs
classan object


Outputs
statementan object


Definition


: create-function-sql ( class -- statement )
[
[ dup remove-id ] dip "create function add_" 0% dup 0%
"(" 0% over
[ "," 0% ] [ type>> lookup-type 0% ] interleave ")" 0%
" returns bigint as '" 0% "insert into " 0% dup 0%
"(" 0% over [ ", " 0% ] [ column-name>> 0% ] interleave
") values(" 0% swap
[ ", " 0% ] [ drop bind-name% ] interleave "); " 0%
"select currval(''" 0% 0% "_" 0%
find-primary-key first column-name>> 0%
"_seq'');' language sql;" 0%
] query-make ;