00001 #include "clssdf.h"
00002
00003 namespace class_def {
00004
00005 void class_definition::print_update( std::ostream& os ) const {
00006 std::vector<key_attribute>::const_iterator pa;
00007 std::vector<attribute*>::const_iterator ppa;
00008
00009 os << "int " << _name << "::update() {" << std::endl << std::endl;
00010
00011 if (_functional_attributes.size()!=0) {
00012
00013 os << " init_static_attributes();" << std::endl << std::endl;
00014
00015 os << " EXEC SQL UPDATE " << _name << " SET" << std::endl;
00016 for (ppa=_non_key_attributes.begin();;) {
00017 os << " " << (*ppa)->get_name() << "=:" << (*ppa)->get_Name();
00018 ppa++;
00019 if (ppa==_non_key_attributes.end()) {
00020 os << std::endl;
00021 break;
00022 } else {
00023 os << "," << std::endl;
00024 }
00025 }
00026 os << " WHERE" << std::endl;
00027 for (pa=_key_attributes.begin();;) {
00028 os << " " << pa->get_name() << "=:" << pa->get_Name();
00029 pa++;
00030 if (pa==_key_attributes.end()) {
00031 os << ";" << std::endl << std::endl;
00032 break;
00033 } else {
00034 os << " AND" << std::endl;
00035 }
00036 }
00037
00038 os << " _sql_err();" << std::endl << std::endl;
00039
00040 }
00041
00042 os << " return 1;" << std::endl;
00043
00044 os << "}" << std::endl << std::endl;
00045 }
00046 }