SAP HANA XS 的xsjs举例

2020-11-27 15:49:19 浏览数 (1)

代码语言:javascript复制
    function doImport() {
    var data = '', conn = $.db.getConnection(), pstmt;  

    if($.request.body){
        data = $.request.body.asString();     
    }

    var conn = $.db.getConnection();
    var pstmt = conn.prepareStatement( 'INSERT INTO "TEST"."UPLOAD" (ID, MIMETYPE, DATA) VALUES(?,?,?)' );

    pstmt.setInteger(1,1);
    pstmt.setString(2,"text/plain");
    pstmt.setString(3,data);

    pstmt.execute();
    pstmt.close();

    conn.commit();
    conn.close();

    doResponse(200,'');

    $.response.contentType = 'text/plain';
    $.response.setBody('Upload ok');
    $.response.status = 200;
}

0 人点赞