URL:cf
POST资料:{"n":"function or procedure name","fp":"function or procedure","p":[[参数mode,参数型态#,参数值]]}
回传:(PostgreSQL function回传的值)
例一:
请求:
curl -v -H "Content-Type:Application/json" -H 'Authorization:abHEi47obYMiCi193xjEiWIFpOouNmkd' -H 'X-Auth-Database:dev5' -d '{"n":"close_accounts","fp":"f","p":[["i",491,"1"],["i",457,2019],["i",457,12],["i",79,"tw"]]}' https://34.terarows.com/fastcgi/api/cf |
可以把这道请求想像成要在dev5数据库上面执行这道SQL指令:
|
回传:
"@362 \"8\", @364 \"9\"" |
例二:呼叫PostgreSQL function
假设dev5数据库有这个table和procedure:
CREATE TABLE t( c1 INTEGER ); CREATE FUNCTION my_func(OUT a INTEGER,b INTEGER) AS $$ INSERT INTO t VALUES (b) RETURNING b+1 $$ LANGUAGE SQL; |
请求:
curl -v -H "Content-Type:Application/json" -H 'Authorization:abHEi47obYMiCi193xjEiWIFpOouNmkd' -H 'X-Auth-Database:dev5' -d '{"n":"my_func","fp":"f","p":[["i",457,5]]}' https://34.terarows.com/fastcgi/api/cf |
可以把这道请求想像成要在dev5数据库上面执行这道SQL指令:
|
回传:
"@362 \"8\", @364 \"6\"" |
例三:呼叫PostgreSQL procedure
假设dev5数据库有这个table和procedure:
CREATE TABLE t( c1 INTEGER ); CREATE PROCEDURE my_proc(OUT a INTEGER,b INTEGER) AS $$ INSERT INTO t VALUES (b) RETURNING b+1 $$ LANGUAGE SQL; |
请求:
curl -v -H "Content-Type:Application/json" -H 'Authorization:abHEi47obYMiCi193xjEiWIFpOouNmkd' -H 'X-Auth-Database:dev5' -d '{"n":"my_proc","fp":"p","p":[["o",NULL,NULL],["i",457,5]]}' https://34.terarows.com/fastcgi/api/cf |
可以把这道请求想像成要在dev5数据库上面执行这道SQL指令:
|
回传:
"@362 \"8\", @364 \"6\"" |