Isn't this simply a vector problem?
You have a vector where you store char pointers. The pointers returned from
sqlite3_column_text will be destroyed when you step afaik.
Try making it a vector<string> instead. Then you will implicitly make
copies of the text in your vector instead.
/Jonas
On Tue, Jun 10, 2008 at 4:12 PM, piotro <[EMAIL PROTECTED]> wrote:
> Hello. I really need help with this, because Im almost out of
> ideas here. Help please!
>
> sqldata is a vector< vector < char* > >
> row is a vector < char* >
>
> sqldata sql3wrapper::pobierzPodmiot(){
> const char* tail;
> sqlite3_stmt* statement;
>
> std::string query = squery("SELECT * FROM %;",PODMIOTY_TABLE);
>
> sqlite3_prepare_v2(interface,query.c_str(),-1,&statement,&tail);
> sqldata data;
> for(int a=0;sqlite3_step(statement)!=101;a++){
> row set;
> data.push_back(set);
> for(int az=1; az<sqlite3_column_count(statement); az++){
> data[a].push_back((char*)sqlite3_column_text(statement,az));
> }
> std::cout<<(data[a])[2]<<std::endl;
> }
> return data;
> sqlite3_finalize(statement);
> }
>
> this does cout properly. But when I'm using it in a different place:
>
> int main(){
> sqldata est = sql3wrapper().pobierzPodmiot();
>
> row one = est[0];
> row two = est[1];
> row three = est[2];
>
> std::cout<<'\n'<<std::endl;
> std::cout<<one[2]<<std::endl;
> std::cout<<two[2]<<std::endl;
> std::cout<<three[2]<<std::endl;
> }
>
> the data is couted properly, but the values are just the values coming
> from the last row.
>
> I have three rows of data in the sqlite database. Then I use the
> pobierzPodmiot
> function, get the data correctly, but when the function is used
> somewhere else,
> it hickups pretty much.
>
> Can someone come up with a solution or something, coping with this had
> been tiresome.
>
> Cheers!
>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users