匿名块如何接收外部传入参数
方法一:
通过ksql -v
[kingbase@singlekbdb ~]$ ksql -Usystem -p54321 test -v id=2 -c '\i 1.sql;' ksql:1.sql:9: 注意: time is 2020-09-18 00:00:00 ANONYMOUS BLOCK [kingbase@singlekbdb ~]$ vi 1.sql \set SQLTERM / DECLARE v_date date; BEGIN select nd into v_date from t2 where id = :id; raise notice 'time is %',v_date; END; /
方法二:
test=# \set id 2 test=# test=# DECLARE test-# v_date text; test-# BEGIN test-# select name into v_date from t1 where id = :id; test-# raise notice 'time is %',v_date; test-# END; test-# / NOTICE: time is bbbbbbbb ANONYMOUS BLOCK Time: 0.833 ms test=#
KINGBASE研究院