text: /**
  	* \file WznmQRtj1NRtblock.cpp
  	* Dbs and XML wrapper for table TblWznmQRtj1NRtblock (implementation)
  	* \copyright (C) 2016-2020 MPSI Technologies GmbH
  	* \author Alexander Wirthmueller (auto-generation)
  	* \date created: 5 Dec 2020
    */
  // IP header --- ABOVE
  
  #include "WznmQRtj1NRtblock.h"
  
  using namespace std;
  using namespace Sbecore;
  using namespace Xmlio;
  
  /******************************************************************************
   class WznmQRtj1NRtblock
   ******************************************************************************/
  
  WznmQRtj1NRtblock::WznmQRtj1NRtblock(
  			const ubigint qref
  			, const ubigint jref
  			, const uint jnum
  			, const ubigint ref
  			, const string stubRef
  		) {
  	this->qref = qref;
  	this->jref = jref;
  	this->jnum = jnum;
  	this->ref = ref;
  	this->stubRef = stubRef;
  };
  
  void WznmQRtj1NRtblock::writeJSON(
  			Json::Value& sup
  			, bool jnumattr
  			, bool shorttags
  		) {
  	Json::Value& me = sup.append(Json::Value(Json::objectValue));
  
  	if (jnumattr) me["jnum"] = jnum;
  	if (shorttags) {
  		me["ref"] = stubRef;
  	} else {
  		me["stubRef"] = stubRef;
  	};
  };
  
  void WznmQRtj1NRtblock::writeXML(
  			xmlTextWriter* wr
  			, string difftag
  			, bool jnumattr
  			, bool shorttags
  		) {
  	if (difftag.length() == 0) difftag = "WznmQRtj1NRtblock";
  
  	xmlTextWriterStartElement(wr, BAD_CAST difftag.c_str());
  	if (jnumattr) xmlTextWriterWriteAttribute(wr, BAD_CAST "jnum", BAD_CAST to_string(jnum).c_str());
  	if (shorttags) {
  		writeString(wr, "ref", stubRef);
  	} else {
  		writeString(wr, "stubRef", stubRef);
  	};
  	xmlTextWriterEndElement(wr);
  };
  
  /******************************************************************************
   class ListWznmQRtj1NRtblock
   ******************************************************************************/
  
  ListWznmQRtj1NRtblock::ListWznmQRtj1NRtblock() {
  };
  
  ListWznmQRtj1NRtblock::ListWznmQRtj1NRtblock(
  			const ListWznmQRtj1NRtblock& src
  		) {
  	nodes.resize(src.nodes.size(), NULL);
  	for (unsigned int i = 0; i < nodes.size(); i++) nodes[i] = new WznmQRtj1NRtblock(*(src.nodes[i]));
  };
  
  ListWznmQRtj1NRtblock::~ListWznmQRtj1NRtblock() {
  	clear();
  };
  
  void ListWznmQRtj1NRtblock::clear() {
  	for (unsigned int i = 0; i < nodes.size(); i++) if (nodes[i]) delete nodes[i];
  	nodes.resize(0);
  };
  
  unsigned int ListWznmQRtj1NRtblock::size() const {
  	return(nodes.size());
  };
  
  void ListWznmQRtj1NRtblock::append(
  			WznmQRtj1NRtblock* rec
  		) {
  	nodes.push_back(rec);
  };
  
  ListWznmQRtj1NRtblock& ListWznmQRtj1NRtblock::operator=(
  			const ListWznmQRtj1NRtblock& src
  		) {
  	WznmQRtj1NRtblock* rec;
  
  	if (&src != this) {
  		clear();
  		for (unsigned int i = 0; i < src.size(); i++) {
  			rec = new WznmQRtj1NRtblock(*(src.nodes[i]));
  			nodes.push_back(rec);
  		};
  	};
  
  	return(*this);
  };
  
  void ListWznmQRtj1NRtblock::writeJSON(
  			Json::Value& sup
  			, std::string difftag
  		) {
  	if (difftag == "") difftag = "ListWznmQRtj1NRtblock";
  
  	Json::Value& me = sup[difftag] = Json::Value(Json::arrayValue);
  	for (unsigned int i = 0; i < nodes.size(); i++) nodes[i]->writeJSON(me, true, true);
  };
  
  void ListWznmQRtj1NRtblock::writeXML(
  			xmlTextWriter* wr
  			, string difftag
  		) {
  	// generate top XML tag
  	if (difftag.length() == 0) difftag = "ListWznmQRtj1NRtblock";
  
  	// XML output
  	xmlTextWriterStartElement(wr, BAD_CAST difftag.c_str());
  		for (unsigned int i = 0; i < nodes.size(); i++) nodes[i]->writeXML(wr, "row", true, true);
  	xmlTextWriterEndElement(wr);
  };
  
  /******************************************************************************
   class TblWznmQRtj1NRtblock
   ******************************************************************************/
  
  TblWznmQRtj1NRtblock::TblWznmQRtj1NRtblock() {
  };
  
  TblWznmQRtj1NRtblock::~TblWznmQRtj1NRtblock() {
  };
  
  bool TblWznmQRtj1NRtblock::loadRecBySQL(
  			const string& sqlstr
  			, WznmQRtj1NRtblock** rec
  		) {
  	return false;
  };
  
  ubigint TblWznmQRtj1NRtblock::loadRstBySQL(
  			const string& sqlstr
  			, const bool append
  			, ListWznmQRtj1NRtblock& rst
  		) {
  	return 0;
  };
  
  ubigint TblWznmQRtj1NRtblock::insertRec(
  			WznmQRtj1NRtblock* rec
  		) {
  	return 0;
  };
  
  ubigint TblWznmQRtj1NRtblock::insertNewRec(
  			WznmQRtj1NRtblock** rec
  			, const ubigint jref
  			, const uint jnum
  			, const ubigint ref
  			, const string stubRef
  		) {
  	ubigint retval = 0;
  	WznmQRtj1NRtblock* _rec = NULL;
  
  	_rec = new WznmQRtj1NRtblock(0, jref, jnum, ref, stubRef);
  	insertRec(_rec);
  
  	retval = _rec->qref;
  
  	if (rec == NULL) delete _rec;
  	else *rec = _rec;
  
  	return retval;
  };
  
  ubigint TblWznmQRtj1NRtblock::appendNewRecToRst(
  			ListWznmQRtj1NRtblock& rst
  			, WznmQRtj1NRtblock** rec
  			, const ubigint jref
  			, const uint jnum
  			, const ubigint ref
  			, const string stubRef
  		) {
  	ubigint retval = 0;
  	WznmQRtj1NRtblock* _rec = NULL;
  
  	retval = insertNewRec(&_rec, jref, jnum, ref, stubRef);
  	rst.nodes.push_back(_rec);
  
  	if (rec != NULL) *rec = _rec;
  
  	return retval;
  };
  
  void TblWznmQRtj1NRtblock::insertRst(
  			ListWznmQRtj1NRtblock& rst
  		) {
  };
  
  void TblWznmQRtj1NRtblock::updateRec(
  			WznmQRtj1NRtblock* rec
  		) {
  };
  
  void TblWznmQRtj1NRtblock::updateRst(
  			ListWznmQRtj1NRtblock& rst
  		) {
  };
  
  void TblWznmQRtj1NRtblock::removeRecByQref(
  			ubigint qref
  		) {
  };
  
  void TblWznmQRtj1NRtblock::removeRstByJref(
  			ubigint jref
  		) {
  };
  
  bool TblWznmQRtj1NRtblock::loadRecByQref(
  			ubigint qref
  			, WznmQRtj1NRtblock** rec
  		) {
  	return false;
  };
  
  ubigint TblWznmQRtj1NRtblock::loadRstByJref(
  			ubigint jref
  			, const bool append
  			, ListWznmQRtj1NRtblock& rst
  		) {
  	return 0;
  };
  
  #if defined(SBECORE_MAR) || defined(SBECORE_MY)
  /******************************************************************************
   class MyTblWznmQRtj1NRtblock
   ******************************************************************************/
  
  MyTblWznmQRtj1NRtblock::MyTblWznmQRtj1NRtblock() :
  			TblWznmQRtj1NRtblock()
  			, MyTable()
  		{
  	stmtInsertRec = NULL;
  	stmtUpdateRec = NULL;
  	stmtRemoveRecByQref = NULL;
  	stmtRemoveRstByJref = NULL;
  };
  
  MyTblWznmQRtj1NRtblock::~MyTblWznmQRtj1NRtblock() {
  	if (stmtInsertRec) delete(stmtInsertRec);
  	if (stmtUpdateRec) delete(stmtUpdateRec);
  	if (stmtRemoveRecByQref) delete(stmtRemoveRecByQref);
  	if (stmtRemoveRstByJref) delete(stmtRemoveRstByJref);
  };
  
  void MyTblWznmQRtj1NRtblock::initStatements() {
  	stmtInsertRec = createStatement("INSERT INTO TblWznmQRtj1NRtblock (jref, jnum, ref) VALUES (?,?,?)", false);
  	stmtUpdateRec = createStatement("UPDATE TblWznmQRtj1NRtblock SET jref = ?, jnum = ?, ref = ? WHERE qref = ?", false);
  	stmtRemoveRecByQref = createStatement("DELETE FROM TblWznmQRtj1NRtblock WHERE qref = ?", false);
  	stmtRemoveRstByJref = createStatement("DELETE FROM TblWznmQRtj1NRtblock WHERE jref = ?", false);
  };
  
  bool MyTblWznmQRtj1NRtblock::loadRecBySQL(
  			const string& sqlstr
  			, WznmQRtj1NRtblock** rec
  		) {
  	MYSQL_RES* dbresult; MYSQL_ROW dbrow;
  	WznmQRtj1NRtblock* _rec = NULL;
  
  	bool retval = false;
  
  	if (mysql_real_query(dbs, sqlstr.c_str(), sqlstr.length())) {
  		string dbms = "MyTblWznmQRtj1NRtblock::loadRecBySQL() / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_QUERY, {{"dbms",dbms}, {"sql",sqlstr}});
  	};
  
  	dbresult = mysql_store_result(dbs);
  	if (!dbresult) {
  		string dbms = "MyTblWznmQRtj1NRtblock::loadRecBySQL() / store result / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_QUERY, {{"dbms",dbms}, {"sql",sqlstr}});
  	};
  
  	if (mysql_num_rows(dbresult) == 1) {
  		dbrow = mysql_fetch_row(dbresult);
  
  		_rec = new WznmQRtj1NRtblock();
  
  		if (dbrow[0]) _rec->qref = atoll((char*) dbrow[0]); else _rec->qref = 0;
  		if (dbrow[1]) _rec->jref = atoll((char*) dbrow[1]); else _rec->jref = 0;
  		if (dbrow[2]) _rec->jnum = atol((char*) dbrow[2]); else _rec->jnum = 0;
  		if (dbrow[3]) _rec->ref = atoll((char*) dbrow[3]); else _rec->ref = 0;
  
  		retval = true;
  	};
  
  	mysql_free_result(dbresult);
  
  	*rec = _rec;
  	return retval;
  };
  
  ubigint MyTblWznmQRtj1NRtblock::loadRstBySQL(
  			const string& sqlstr
  			, const bool append
  			, ListWznmQRtj1NRtblock& rst
  		) {
  	MYSQL_RES* dbresult; MYSQL_ROW dbrow; ubigint numrow; ubigint numread = 0;
  	WznmQRtj1NRtblock* rec;
  
  	if (!append) rst.clear();
  
  	if (mysql_real_query(dbs, sqlstr.c_str(), sqlstr.length())) {
  		string dbms = "MyTblWznmQRtj1NRtblock::loadRstBySQL() / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_QUERY, {{"dbms",dbms}, {"sql",sqlstr}});
  	};
  
  	dbresult = mysql_store_result(dbs);
  	if (!dbresult) {
  		string dbms = "MyTblWznmQRtj1NRtblock::loadRstBySQL() / store result / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_QUERY, {{"dbms",dbms}, {"sql",sqlstr}});
  	};
  
  	numrow = mysql_num_rows(dbresult);
  
  	if (numrow > 0) {
  		rst.nodes.reserve(rst.nodes.size() + numrow);
  
  		while (numread < numrow) {
  			dbrow = mysql_fetch_row(dbresult);
  
  			rec = new WznmQRtj1NRtblock();
  
  			if (dbrow[0]) rec->qref = atoll((char*) dbrow[0]); else rec->qref = 0;
  			if (dbrow[1]) rec->jref = atoll((char*) dbrow[1]); else rec->jref = 0;
  			if (dbrow[2]) rec->jnum = atol((char*) dbrow[2]); else rec->jnum = 0;
  			if (dbrow[3]) rec->ref = atoll((char*) dbrow[3]); else rec->ref = 0;
  			rst.nodes.push_back(rec);
  
  			numread++;
  		};
  	};
  
  	mysql_free_result(dbresult);
  
  	return(numread);
  };
  
  ubigint MyTblWznmQRtj1NRtblock::insertRec(
  			WznmQRtj1NRtblock* rec
  		) {
  	unsigned long l[3]; my_bool n[3]; my_bool e[3];
  
  	MYSQL_BIND bind[] = {
  		bindUbigint(&rec->jref,&(l[0]),&(n[0]),&(e[0])),
  		bindUint(&rec->jnum,&(l[1]),&(n[1]),&(e[1])),
  		bindUbigint(&rec->ref,&(l[2]),&(n[2]),&(e[2]))
  	};
  
  	if (mysql_stmt_bind_param(stmtInsertRec, bind)) {
  		string dbms = "MyTblWznmQRtj1NRtblock::insertRec() / bind / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  	if (mysql_stmt_execute(stmtInsertRec)) {
  		string dbms = "MyTblWznmQRtj1NRtblock::insertRec() / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  	rec->qref = mysql_stmt_insert_id(stmtInsertRec);
  	
  	return rec->qref;
  };
  
  void MyTblWznmQRtj1NRtblock::insertRst(
  			ListWznmQRtj1NRtblock& rst
  		) {
  	for (unsigned int i = 0; i < rst.nodes.size(); i++) insertRec(rst.nodes[i]);
  };
  
  void MyTblWznmQRtj1NRtblock::updateRec(
  			WznmQRtj1NRtblock* rec
  		) {
  	unsigned long l[4]; my_bool n[4]; my_bool e[4];
  
  	MYSQL_BIND bind[] = {
  		bindUbigint(&rec->jref,&(l[0]),&(n[0]),&(e[0])),
  		bindUint(&rec->jnum,&(l[1]),&(n[1]),&(e[1])),
  		bindUbigint(&rec->ref,&(l[2]),&(n[2]),&(e[2])),
  		bindUbigint(&rec->qref,&(l[3]),&(n[3]),&(e[3]))
  	};
  
  	if (mysql_stmt_bind_param(stmtUpdateRec, bind)) {
  		string dbms = "MyTblWznmQRtj1NRtblock::updateRec() / bind / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  	if (mysql_stmt_execute(stmtUpdateRec)) {
  		string dbms = "MyTblWznmQRtj1NRtblock::updateRec() / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  };
  
  void MyTblWznmQRtj1NRtblock::updateRst(
  			ListWznmQRtj1NRtblock& rst
  		) {
  	for (unsigned int i = 0; i < rst.nodes.size(); i++) updateRec(rst.nodes[i]);
  };
  
  void MyTblWznmQRtj1NRtblock::removeRecByQref(
  			ubigint qref
  		) {
  	unsigned long l; my_bool n; my_bool e;
  
  	MYSQL_BIND bind = bindUbigint(&qref,&l,&n,&e);
  
  	if (mysql_stmt_bind_param(stmtRemoveRecByQref, &bind)) {
  		string dbms = "MyTblWznmQRtj1NRtblock::removeRecByQref() / bind / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  	if (mysql_stmt_execute(stmtRemoveRecByQref)) {
  		string dbms = "MyTblWznmQRtj1NRtblock::removeRecByQref() / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  };
  
  void MyTblWznmQRtj1NRtblock::removeRstByJref(
  			ubigint jref
  		) {
  	unsigned long l; my_bool n; my_bool e;
  
  	MYSQL_BIND bind = bindUbigint(&jref,&l,&n,&e);
  
  	if (mysql_stmt_bind_param(stmtRemoveRstByJref, &bind)) {
  		string dbms = "MyTblWznmQRtj1NRtblock::removeRstByJref() / bind / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  	if (mysql_stmt_execute(stmtRemoveRstByJref)) {
  		string dbms = "MyTblWznmQRtj1NRtblock::removeRstByJref() / " + string(mysql_error(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  };
  
  bool MyTblWznmQRtj1NRtblock::loadRecByQref(
  			ubigint qref
  			, WznmQRtj1NRtblock** rec
  		) {
  	if (qref == 0) {
  		*rec = NULL;
  		return false;
  	};
  
  	return loadRecBySQL("SELECT * FROM TblWznmQRtj1NRtblock WHERE qref = " + to_string(qref), rec);
  };
  
  ubigint MyTblWznmQRtj1NRtblock::loadRstByJref(
  			ubigint jref
  			, const bool append
  			, ListWznmQRtj1NRtblock& rst
  		) {
  	return loadRstBySQL("SELECT * FROM TblWznmQRtj1NRtblock WHERE jref = " + to_string(jref) + " ORDER BY jnum ASC", append, rst);
  };
  #endif
  
  #if defined(SBECORE_PG)
  /******************************************************************************
   class PgTblWznmQRtj1NRtblock
   ******************************************************************************/
  
  PgTblWznmQRtj1NRtblock::PgTblWznmQRtj1NRtblock() :
  			TblWznmQRtj1NRtblock()
  			, PgTable()
  		{
  };
  
  PgTblWznmQRtj1NRtblock::~PgTblWznmQRtj1NRtblock() {
  };
  
  void PgTblWznmQRtj1NRtblock::initStatements() {
  	createStatement("TblWznmQRtj1NRtblock_insertRec", "INSERT INTO TblWznmQRtj1NRtblock (jref, jnum, ref) VALUES ($1,$2,$3) RETURNING qref", 3);
  	createStatement("TblWznmQRtj1NRtblock_updateRec", "UPDATE TblWznmQRtj1NRtblock SET jref = $1, jnum = $2, ref = $3 WHERE qref = $4", 4);
  	createStatement("TblWznmQRtj1NRtblock_removeRecByQref", "DELETE FROM TblWznmQRtj1NRtblock WHERE qref = $1", 1);
  	createStatement("TblWznmQRtj1NRtblock_removeRstByJref", "DELETE FROM TblWznmQRtj1NRtblock WHERE jref = $1", 1);
  
  	createStatement("TblWznmQRtj1NRtblock_loadRecByQref", "SELECT qref, jref, jnum, ref FROM TblWznmQRtj1NRtblock WHERE qref = $1", 1);
  	createStatement("TblWznmQRtj1NRtblock_loadRstByJref", "SELECT qref, jref, jnum, ref FROM TblWznmQRtj1NRtblock WHERE jref = $1 ORDER BY jnum ASC", 1);
  };
  
  bool PgTblWznmQRtj1NRtblock::loadRec(
  			PGresult* res
  			, WznmQRtj1NRtblock** rec
  		) {
  	char* ptr;
  
  	WznmQRtj1NRtblock* _rec = NULL;
  	bool retval = false;
  
  	if (PQntuples(res) == 1) {
  		_rec = new WznmQRtj1NRtblock();
  
  		int fnum[] = {
  			PQfnumber(res, "qref"),
  			PQfnumber(res, "jref"),
  			PQfnumber(res, "jnum"),
  			PQfnumber(res, "ref")
  		};
  
  		ptr = PQgetvalue(res, 0, fnum[0]); _rec->qref = atoll(ptr);
  		ptr = PQgetvalue(res, 0, fnum[1]); _rec->jref = atoll(ptr);
  		ptr = PQgetvalue(res, 0, fnum[2]); _rec->jnum = atol(ptr);
  		ptr = PQgetvalue(res, 0, fnum[3]); _rec->ref = atoll(ptr);
  
  		retval = true;
  	};
  
  	PQclear(res);
  
  	*rec = _rec;
  	return retval;
  };
  
  ubigint PgTblWznmQRtj1NRtblock::loadRst(
  			PGresult* res
  			, const bool append
  			, ListWznmQRtj1NRtblock& rst
  		) {
  	ubigint numrow; ubigint numread = 0; char* ptr;
  	WznmQRtj1NRtblock* rec;
  
  	if (!append) rst.clear();
  
  	numrow = PQntuples(res);
  
  	if (numrow > 0) {
  		rst.nodes.reserve(rst.nodes.size() + numrow);
  
  		int fnum[] = {
  			PQfnumber(res, "qref"),
  			PQfnumber(res, "jref"),
  			PQfnumber(res, "jnum"),
  			PQfnumber(res, "ref")
  		};
  
  		while (numread < numrow) {
  			rec = new WznmQRtj1NRtblock();
  
  			ptr = PQgetvalue(res, numread, fnum[0]); rec->qref = atoll(ptr);
  			ptr = PQgetvalue(res, numread, fnum[1]); rec->jref = atoll(ptr);
  			ptr = PQgetvalue(res, numread, fnum[2]); rec->jnum = atol(ptr);
  			ptr = PQgetvalue(res, numread, fnum[3]); rec->ref = atoll(ptr);
  
  			rst.nodes.push_back(rec);
  
  			numread++;
  		};
  	};
  
  	PQclear(res);
  
  	return numread;
  };
  
  bool PgTblWznmQRtj1NRtblock::loadRecByStmt(
  			const string& srefStmt
  			, const unsigned int N
  			, const char** vals
  			, const int* l
  			, const int* f
  			, WznmQRtj1NRtblock** rec
  		) {
  	PGresult* res;
  
  	res = PQexecPrepared(dbs, srefStmt.c_str(), N, vals, l, f, 0);
  	
  	if (PQresultStatus(res) != PGRES_TUPLES_OK)	{
  		string dbms = "PgTblWznmQRtj1NRtblock::loadRecByStmt(" + srefStmt + ") / " + string(PQerrorMessage(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  
  	return loadRec(res, rec);
  };
  
  ubigint PgTblWznmQRtj1NRtblock::loadRstByStmt(
  			const string& srefStmt
  			, const unsigned int N
  			, const char** vals
  			, const int* l
  			, const int* f
  			, const bool append
  			, ListWznmQRtj1NRtblock& rst
  		) {
  	PGresult* res;
  
  	res = PQexecPrepared(dbs, srefStmt.c_str(), N, vals, l, f, 0);
  
  	if (PQresultStatus(res) != PGRES_TUPLES_OK)	{
  		string dbms = "PgTblWznmQRtj1NRtblock::loadRstByStmt(" + srefStmt + ") / " + string(PQerrorMessage(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  
  	return loadRst(res, append, rst);
  };
  
  bool PgTblWznmQRtj1NRtblock::loadRecBySQL(
  			const string& sqlstr
  			, WznmQRtj1NRtblock** rec
  		) {
  	PGresult* res;
  
  	res = PQexec(dbs, sqlstr.c_str());
  
  	if (PQresultStatus(res) != PGRES_TUPLES_OK) {
  		string dbms = "PgTblWznmQRtj1NRtblock::loadRecBySQL() / " + string(PQerrorMessage(dbs));
  		throw SbeException(SbeException::DBS_QUERY, {{"dbms",dbms}, {"sql",sqlstr}});
  	};
  
  	return loadRec(res, rec);
  };
  
  ubigint PgTblWznmQRtj1NRtblock::loadRstBySQL(
  			const string& sqlstr
  			, const bool append
  			, ListWznmQRtj1NRtblock& rst
  		) {
  	PGresult* res;
  
  	res = PQexec(dbs, sqlstr.c_str());
  
  	if (PQresultStatus(res) != PGRES_TUPLES_OK) {
  		string dbms = "PgTblWznmQRtj1NRtblock::loadRstBySQL() / " + string(PQerrorMessage(dbs));
  		throw SbeException(SbeException::DBS_QUERY, {{"dbms",dbms}, {"sql",sqlstr}});
  	};
  
  	return loadRst(res, append, rst);
  };
  
  ubigint PgTblWznmQRtj1NRtblock::insertRec(
  			WznmQRtj1NRtblock* rec
  		) {
  	PGresult* res;
  	char* ptr;
  
  	ubigint _jref = htonl64(rec->jref);
  	uint _jnum = htonl(rec->jnum);
  	ubigint _ref = htonl64(rec->ref);
  
  	const char* vals[] = {
  		(char*) &_jref,
  		(char*) &_jnum,
  		(char*) &_ref
  	};
  	const int l[] = {
  		sizeof(ubigint),
  		sizeof(uint),
  		sizeof(ubigint)
  	};
  	const int f[] = {1, 1, 1};
  
  	res = PQexecPrepared(dbs, "TblWznmQRtj1NRtblock_insertRec", 3, vals, l, f, 0);
  
  	if (PQresultStatus(res) != PGRES_TUPLES_OK)	{
  		string dbms = "PgTblWznmQRtj1NRtblock::insertRec() / " + string(PQerrorMessage(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  
  	ptr = PQgetvalue(res, 0, PQfnumber(res, "qref")); rec->qref = atoll(ptr);
  
  	PQclear(res);
  	
  	return rec->qref;
  };
  
  void PgTblWznmQRtj1NRtblock::insertRst(
  			ListWznmQRtj1NRtblock& rst
  		) {
  	for (unsigned int i = 0; i < rst.nodes.size(); i++) insertRec(rst.nodes[i]);
  };
  
  void PgTblWznmQRtj1NRtblock::updateRec(
  			WznmQRtj1NRtblock* rec
  		) {
  	PGresult* res;
  
  	ubigint _jref = htonl64(rec->jref);
  	uint _jnum = htonl(rec->jnum);
  	ubigint _ref = htonl64(rec->ref);
  	ubigint _qref = htonl64(rec->qref);
  
  	const char* vals[] = {
  		(char*) &_jref,
  		(char*) &_jnum,
  		(char*) &_ref,
  		(char*) &_qref
  	};
  	const int l[] = {
  		sizeof(ubigint),
  		sizeof(uint),
  		sizeof(ubigint),
  		sizeof(ubigint)
  	};
  	const int f[] = {1, 1, 1, 1};
  
  	res = PQexecPrepared(dbs, "TblWznmQRtj1NRtblock_updateRec", 4, vals, l, f, 0);
  
  	if (PQresultStatus(res) != PGRES_COMMAND_OK) {
  		string dbms = "PgTblWznmQRtj1NRtblock::updateRec() / " + string(PQerrorMessage(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  
  	PQclear(res);
  };
  
  void PgTblWznmQRtj1NRtblock::updateRst(
  			ListWznmQRtj1NRtblock& rst
  		) {
  	for (unsigned int i = 0; i < rst.nodes.size(); i++) updateRec(rst.nodes[i]);
  };
  
  void PgTblWznmQRtj1NRtblock::removeRecByQref(
  			ubigint qref
  		) {
  	PGresult* res;
  
  	ubigint _qref = htonl64(qref);
  
  	const char* vals[] = {
  		(char*) &_qref
  	};
  	const int l[] = {
  		sizeof(ubigint)
  	};
  	const int f[] = {1};
  
  	res = PQexecPrepared(dbs, "TblWznmQRtj1NRtblock_removeRecByQref", 1, vals, l, f, 0);
  
  	if (PQresultStatus(res) != PGRES_COMMAND_OK) {
  		string dbms = "PgTblWznmQRtj1NRtblock::removeRecByQref() / " + string(PQerrorMessage(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  
  	PQclear(res);
  };
  
  void PgTblWznmQRtj1NRtblock::removeRstByJref(
  			ubigint jref
  		) {
  	PGresult* res;
  
  	ubigint _jref = htonl64(jref);
  
  	const char* vals[] = {
  		(char*) &_jref
  	};
  	const int l[] = {
  		sizeof(ubigint)
  	};
  	const int f[] = {1};
  
  	res = PQexecPrepared(dbs, "TblWznmQRtj1NRtblock_removeRstByJref", 1, vals, l, f, 0);
  
  	if (PQresultStatus(res) != PGRES_COMMAND_OK) {
  		string dbms = "PgTblWznmQRtj1NRtblock::removeRstByJref() / " + string(PQerrorMessage(dbs));
  		throw SbeException(SbeException::DBS_STMTEXEC, {{"dbms",dbms}});
  	};
  
  	PQclear(res);
  };
  
  bool PgTblWznmQRtj1NRtblock::loadRecByQref(
  			ubigint qref
  			, WznmQRtj1NRtblock** rec
  		) {
  	if (qref == 0) {
  		*rec = NULL;
  		return false;
  	};
  
  	ubigint _qref = htonl64(qref);
  
  	const char* vals[] = {
  		(char*) &_qref
  	};
  	const int l[] = {
  		sizeof(ubigint)
  	};
  	const int f[] = {1};
  
  	return loadRecByStmt("TblWznmQRtj1NRtblock_loadRecByQref", 1, vals, l, f, rec);
  };
  
  ubigint PgTblWznmQRtj1NRtblock::loadRstByJref(
  			ubigint jref
  			, const bool append
  			, ListWznmQRtj1NRtblock& rst
  		) {
  	ubigint _jref = htonl64(jref);
  
  	const char* vals[] = {
  		(char*) &_jref
  	};
  	const int l[] = {
  		sizeof(ubigint)
  	};
  	const int f[] = {1};
  
  	return loadRstByStmt("TblWznmQRtj1NRtblock_loadRstByJref", 1, vals, l, f, append, rst);
  };
  #endif
  