134{
135
136 std::ifstream
outfile(
m_outFileName.value().c_str(), std::ifstream::in | std::ifstream::binary);
137
138 std::vector<std::string> newoutfilelines;
139 std::string outfileline;
140 while( getline(outfile, outfileline) )
141 if( outfileline != "\n" && outfileline != "\r" && !outfileline.empty() )
142 {
143 const auto strBegin = outfileline.find_first_not_of(" \t");
144 const auto strEnd = outfileline.find_last_not_of(" \t");
145 const auto strRange = strEnd - strBegin + 1;
146 if (strBegin != std::string::npos) outfileline = outfileline.substr(strBegin, strRange);
147 newoutfilelines.push_back(outfileline);
148 }
150
151 std::ofstream newoutfile(
m_outFileName.value().c_str(), std::ofstream::out | std::ofstream::trunc);
152 for(auto it = newoutfilelines.begin(); it != newoutfilelines.end(); ++it)
153 {
154 if(it != newoutfilelines.begin()) newoutfile << "\n";
156 }
157 newoutfile.close();
159
160 int fileSize = 0;
162 {
163 outfile.seekg(0, std::ios::end);
166 }
167 else {
169 return false;
170 }
171
173
174 std::ofstream prefile;
176 prefile << "insert into AGDD_data (\n";
177 prefile << "AGDD_data_id,\n";
178 prefile << "VERS,\n";
179 prefile << "VNAME,\n";
180 prefile << "LENAGDD,\n";
181 prefile << "NLINE,\n";
182 prefile << "data\n";
183 prefile << ") values (XXX_DATA_ID_KOUNTER,\n";
184
185 prefile << " 7,'";
186
187 prefile << TheAmdcName.substr(0,4) <<
"'," << fileSize-1 <<
","<<
int( (fileSize + 2) / 4 )<<
",\n";
188 prefile << "empty_clob()\n";
189 prefile << ");\n";
190 prefile << "insert into AGDD_data2tag values (XXX_DATA2TAG_KOUNTER,XXX_DATA_ID_KOUNTER);\n";
191 prefile << "DECLARE\n";
192 prefile << " lobloc CLOB;\n";
193 prefile << " req utl_http.req;\n";
194 prefile << " resp utl_http.resp;\n";
195 prefile << " text VARCHAR2(32767);\n";
196 prefile << " amount INTEGER(10) := 0;\n";
197 prefile << " offset INTEGER(10) := 0;\n";
198 prefile << " TRUE BOOLEAN;\n";
199 prefile << "BEGIN\n";
200 prefile << " SELECT data INTO lobloc\n";
201 prefile << " FROM AGDD_data\n";
202 prefile << " WHERE AGDD_data_id = XXX_DATA_ID_KOUNTER FOR UPDATE;\n";
203 prefile << " offset := DBMS_LOB.GETLENGTH(lobloc)+2;\n";
204 prefile << " req := utl_http.begin_request(\n";
205 prefile << " 'WEB_ADDRESS_FOR_TEMP_DATA_FILEAGDDtemp.data');\n";
206 prefile << " resp := utl_http.get_response(req);\n";
207 prefile << " LOOP\n";
208 prefile << " text := ' ';\n";
209 prefile << " UTL_HTTP.READ_TEXT(resp, text, NULL);\n";
210 prefile << " /* DBMS_OUTPUT.PUT_LINE(text); */\n";
211 prefile << " amount := length(text);\n";
212 prefile << " DBMS_LOB.WRITEAPPEND(lobloc,amount,text);\n";
213 prefile << " END LOOP;\n";
214 prefile << " utl_http.end_response(resp);\n";
215 prefile << " EXCEPTION\n";
216 prefile << " WHEN utl_http.end_of_body\n";
217 prefile << " THEN utl_http.end_response(resp);\n";
218 prefile << "END;\n";
219 prefile << "/\n";
220 prefile.close();
221
222 return true;
223
224}