Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

pr_country_list.h

Go to the documentation of this file.
00001 /*
00002  * $Id: pr_country_list.h,v 1.2 2002/12/10 13:38:12 dsamersoff Exp $
00003  *
00004  */
00005 
00006 #ifndef pr_country_list_h 
00007 #define pr_country_list_h
00008 
00009 using namespace std;
00010 #include <list>
00011 #include <dsSQLWrapper.h>
00012 
00013 class pr_country_list_rset : public dsSQLRset
00014 {
00015 public:
00016     
00017     char country_tag[4];
00018     char country_name[71];  
00019     char A2_code[3];
00020     char A3_code[4];
00021     long NUM_code;
00022     
00023     
00024     virtual void Dump(ostream& os)
00025     {
00026         os <<  "country_tag:   '"  << country_tag   << endl;
00027         os <<  "country_name:  '"  << country_name  << endl;
00028         os <<  "A2_code:       '"  << A2_code       << endl;
00029         os <<  "A3_code:       '"  << A3_code       << endl;
00030         os <<  "NUM_code:      '"  << NUM_code      << endl;
00031     }
00032     
00033     void Define(dsSQLAccessor *pg, void *cursor)
00034     {
00035         dsOCI *oraPg = static_cast<dsOCI *>(pg);
00036         OCIStmt *oraCursor = (OCIStmt *) cursor;
00037 
00038         oraPg->DefineByPos(cursor,1,SQLT_STR, country_tag,  sizeof(country_tag)  );
00039         oraPg->DefineByPos(cursor,2,SQLT_STR, country_name, sizeof(country_name) );
00040         oraPg->DefineByPos(cursor,3,SQLT_STR, A2_code,      sizeof(A2_code)      );
00041         oraPg->DefineByPos(cursor,4,SQLT_STR, A3_code,      sizeof(A3_code)      );
00042         oraPg->DefineByPos(cursor,5,SQLT_INT, &NUM_code,    sizeof(NUM_code)     );
00043     }
00044 
00045     pr_country_list_rset(pr_country_list_rset *rs)
00046     {
00047         strcpy(country_tag,   rs->country_tag);
00048         strcpy(country_name, rs->country_name);
00049         
00050         strcpy(A2_code,  rs->A2_code);
00051         strcpy(A3_code,  rs->A3_code);
00052         NUM_code  = rs->NUM_code;
00053     }
00054     
00055     pr_country_list_rset()
00056     { memset(country_tag,  0 , sizeof(country_tag)  );
00057       memset(country_name, 0 , sizeof(country_name) );
00058       memset(A2_code,      0 , sizeof(A2_code)      );
00059       memset(A3_code,      0 , sizeof(A3_code)      );
00060       NUM_code = 0;
00061     }
00062 
00063 };
00064 
00065 
00066 
00067 class pr_country_list : public dsSPListWrapper<pr_country_list_rset>
00068 {
00069 
00070 public:
00071 
00072   void combo_body(ostream& os)
00073    {
00074         list<pr_country_list_rset *>::iterator iter;
00075 
00076         os << "<OPTION value='USA' SELECTED>United States</OPTION>" << endl;
00077         os << "<OPTION value='CAN'>Canada</OPTION>" << endl;
00078 
00079          for (iter = _lst.begin(); iter != _lst.end(); ++iter)
00080           {
00081             os << "<OPTION value='" <<  (*iter)->country_tag << "'>" << (*iter)->country_name << "</OPTION>" << endl;
00082           }
00083    }
00084 
00085 
00086   virtual void execute(dsOCI *pg)
00087     {
00088         _fl->log(0xFF, "PR_COUNTRY_LIST");
00089 
00090          const char query[] = 
00091                       "BEGIN PK_SIGNUP.PR_COUNTRY_LIST(:cursor); END;" );
00092 
00093         OCIStmt *cursor;
00094 
00095         OCIStmt *stmt = pg->PrepareCall(query);
00096         pg->BindCursor(stmt, "cursor", &cursor);
00097 
00098            pg->Execute( stmt );
00099 
00100         rs.define(pg, cursor);
00101 
00102         while ( OCI_SUCCESS == pg->fetch( cursor ) )
00103          { 
00104            _lst.push_back( new pr_country_list_rset(rs) );
00105          }
00106 
00107          pg->ReleaseCall(stmt);
00108     }
00109 
00110 };
00111 
00112 
00113 #endif

Generated on Mon May 16 18:26:58 2005 for libdms4 by doxygen1.3-rc2