[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-plusplus
Subject:    sql_create_basic_N questions
From:       Steve Newell <snewell () neovest ! com>
Date:       2001-04-18 19:25:39
[Download RAW message or body]


I am using sql_create_basic_N to generate structures that mirror my database
tables.  The problem I have is that some of the fields in my database are
"blobs" that need to be escaped before insertion.
 
Questions:
 
1. I am using a string to represent the data in the structure:

sql_create_basic_2(StoryBody, 0, 0,
       INT32, StoryID,
       string, Body);    // this is actually a blob

Is there a better data structure for this?
 
2. The data that I am trying to store has nulls scattered throughout.  When
I create the insert string using the following code, it only puts in the
data up to the first null.  That's a side effect of the string, so I have
tried escaping the string before I create the insert statement.  That
doesn't seem to work either.  Apparently, MySql is ignoring the escaped
characters.
 

StoryBody    sb;
 
sb.StoryID = -1;
string tmpS(blobSize, blob);
sb.Body = tmpS;
 
escape_string(sb.Body);
 
 Query q = m_dbconn->query();
 stringstream strbuf; 
 
 try {
  string tmpQS = "INSERT INTO STORYBODY (Body) VALUES('";
 
      strbuf << "INSERT INTO STORYBODY (Body) VALUES(" << quote <<  sb.Body
<< ")";
      q.exec(strbuf.str());
} catch(BadQuery e) {
    // handle error here
}

Any help would be greatly appreciated.
 
Thanks,
 
Steve


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic