读书人

dbaccess shell调用sql话语和procedur

发布时间: 2012-08-10 12:19:33 作者: rapoo

dbaccess shell调用sql语句和procedure的区别 output

写了一个存储过程,在小松鼠上运行,一直报错:

Error: java.sql.SQLException: A syntax error has occurred., SQL State: 42000, Error Code: -201
Error occured in:
CREATE PROCEDURE "informix".p_project_ne_alarm_toemos()

后来知道,可以是 ; 号导致的原因,小松鼠见到分号就认为会话结束了。

把存储过程写procedure.sql,用dbaccess alarm procedure.sql就可以创建成功了。

在调用存储过程的时候,发现自己理解有错误:

ExecuteProcedure()
{
dbname="$1"
procedure="$2"
sqltxt="execute procedure "
#pre_sql="output to pipe cat without headings " 执行的SQL有输出的时候才用的上这句;

sqltxt="$sqltxt""$procedure"
echo "$sqltxt" | dbaccess "$dbname"
}

如果不注释掉标红的,总是提示:

-809 SQL Syntax error has occurred.

The INSERT statement in this LOAD/UNLOAD/INFO statement has invalid syntax.
Review it for punctuation and use of keywords.

原因:output、unload、load这些都是bolt-ons added to DB-Access;只有执行的SQL或存储过程有输出的时候才用output to pipe cat without headings ;

注释掉标红的就可以执行了。

读书人网 >其他数据库

热点推荐