我有一种情况,我将会话用户作为参数传递给存储过程,并获得一个接收器值,我想在变量中获得该值,这样我就可以将其传递给xsjs文件中的其他函数来发送电子邮件。
我正在从会话用户获取发件人,并执行concat以获取发件人电子邮件。
我调用ReadAuditUser存储过程将查看appuser(会话用户(是否有效
-
如果ReadAuditUser存储过程发现appuser是有效用户,则存储过程将返回一条记录,该记录将返回接收器
-
如果ReadAuditUser存储过程发现appuser是无效用户,则存储过程将返回"null"。
我想从getReceivername((捕获那个接收器,就像我从getUsername((函数捕获appuser一样。
请告诉我哪里出了问题。
function getUsername() {
var username = $.session.getUsername();
return username;
}
var appuser = getUsername();
var str2 = "@abc.com";
var sender_email = appuser.concat(str2);
function getReceivername() {
var xreceiver = "";
var conn = $.db.getConnection();
var query = 'call "AA"."PROCEDURE::ReadAuditUser"(?)';
var pstmt = conn.prepareCall(query);
pstmt.setString(1, appuser);
pstmt.execute();
var rs = pstmt.getResultSet();
if (rs.next()) {
if (rs.getString(1) === 'null') {
xreceiver = rs.getString(1);
} else {
xreceiver = rs.getString(1);
}
}
}
rs.close();
pstmt.close();
conn.close();
var receiver = getReceivername();
var str1 = "@abc.com";
var receiver_email = receiver.concat(str1);
function getUsername() {
var username = $.session.getUsername();
return username;
}
var appuser = getUsername();
var str2 = "@abc.com";
var sender_email = appuser.concat(str2);
function getReceivername() {
var xreceiver = "";
var conn = $.db.getConnection();
var query = 'call "AA"."PROCEDURE::ReadAuditUser"(?)';
var pstmt = conn.prepareCall(query);
pstmt.setString(1, appuser);
pstmt.execute();
var rs = pstmt.getResultSet();
if (rs.next()) {
if (rs.getString(1) === 'null') {
xreceiver = rs.getString(1);
} else {
xreceiver = rs.getString(1);
}
}
return xreceiver; /* have to add this code line and it works*/
}
rs.close();
pstmt.close();
conn.close();
var receiver = getReceivername();
var str1 = "@abc.com";
var receiver_email = receiver.concat(str1);