0
1
Fork 0
hedera-web-mindshore/js/sql/multi-stmt.js

50 lines
673 B
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
var Stmt = require ('./stmt');
/**
* The equivalent of a SQL multi statement.
**/
2016-09-26 09:28:47 +00:00
module.exports = new Class
({
2016-09-26 09:28:47 +00:00
Extends: Stmt
,stmts: []
,addStmt: function (stmt)
{
return this.stmts.push (stmt);
}
,getStmt: function (stmtIndex)
{
return this.stmts[index];
}
,isReady: function ()
{
if (this.stmts.length == 0)
return false;
for (var i = 0; i < this.stmts.length; i++)
if (!this.stmts[i].isReady ())
return false;
return true;
}
,render: function (batch)
{
var sql = '';
for (var i = 0; i < this.stmts.length; i++)
{
if (i > 0)
sql += ";\n";
sql += this.stmts[i].render (batch);
}
return sql;
}
});