PI 7.1 JDBC Receiver Adapter Configuration(一)

    项目中经常会遇到使用JDBC Adapter的方式直接插入或更新数据库的需求,在这里记录一下,省得时间长不做又忘了。PI中如果使用JDBC Receiver Adapter,在定义Data Type时必须遵循一定的格式,而且根据Action(Delete、Update、Insert等)不同,格式也不完全一致。具体的格式可以参照:http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm

     先按照所要做的操作在ESR中建立对应的数据类型,我做的是先删除表数据,然后插入新数据,(因为客户之前提了个这样的需求,所要先做个例子试试),Data Type如下:


    第一个Statement 是为了删除表数据,因为是要全部删除,所要没加Key的结构,如果是有条件的删除,要在table后再加一个Key的,指定删除条件;第二个Statement是为了插入数据,在这里如果Action是用Update_Insert,也要加Key的结构,指定更新条件。

    重要的是Message Mapping,其中Action可根据要求赋值:INSERT、UPDATE、SELECT或UPDATE_INSERT等。Table是可选的,如果用了在这里赋值你要操作的表名既可。还有一点,我用的是Oracle数据库,当表里有日期类型的字段时,是要先在Mapping中做一下To_Date的转换,同时要给hasQuot属性赋值yes|no,否则会报错。

    hasQuot= YES|NO During construction of the WHERE condition of the SQL statement, the table column type determines whether the default is to set the values in quotation marks (text column types) or not (numerical column types). In a few cases (for example, when using functions), it may be necessary to override this. This attribute enables you to do this. If YES, quotation marks are always set round the values for which this attribute is set in the SQL syntax. If NO, quotation marks are never set. Only use this attribute in individual cases.


如果是日期时间型:



 

猜你喜欢

转载自zhangyy327.iteye.com/blog/1152222
pi
7.1