List:MySQL++« Previous MessageNext Message »
From:Graham Reitz Date:August 12 2007 8:07pm
Subject:Re: Inserting with a column that uses auto_increment
View as plain text  
ahh....ok.   I'll try using different namespaces.  That's unfortunate  
and really suggests a larger design issue with the mysql++ library.    
It does, although, have many v. nice features.

thanks,
g

On Aug 12, 2007, at 1:43 PM, Jim Wallace wrote:

> Right.  The insert uses the macro name as table name, selects  
> don't, so
> the insert will have to have the table name.
>
> You may be able to get around it with namespaces.
>
> -----Original Message-----
> From: Graham Reitz [mailto:grahamreitz@stripped]
> Sent: Sunday, August 12, 2007 12:10 AM
> To: Jim Wallace
> Cc: plusplus@stripped
> Subject: Re: Inserting with a column that uses auto_increment
>
> Ok, that seems to work, thanks.   Another question:
>
> How do you create two sql_create macros with the same name? (doesn't
> compile)
>
> If I change the name of the sql_create_N(name,...) to something  
> else it
> won't let me insert it into the database because it has a different
> table name that doesn't match.
>
> Thanks,
> Graham
>
>
> On Aug 11, 2007, at 8:29 PM, Jim Wallace wrote:
>
>> I use auto_increment often.  The trick is to not include that column
>> in the sql_create_* macro.  This may mean you have > 1 macro for the
>> same table, one for insert w/o that column, and one for retrieval  
>> with
>
>> that column.  I often have > 1 macro for the same table depending on
>> how I'm using it.
>>
>> HTH
>>
>> -----Original Message-----
>> From: Graham Reitz [mailto:grahamreitz@stripped]
>> Sent: Saturday, August 11, 2007 2:27 AM
>> To: plusplus@stripped
>> Subject: Inserting with a column that uses auto_increment
>>
>> How do you prevent an insert as shown in the code below from putting
>> "bogus" data in an auto_increment field?
>>
>> It seems like the billing_id field, in the code below, inserts a
>> number based on the un-initialized value of client_id, instead of
>> letting the database auto_increment the value.  What's a good method
>> to deal with this, that allows the database to auto_increment a
>> database field?
>>
>> Thanks,
>> Graham
>>
>> /************ CODE ************/
>>
>> #include <mysql++.h>
>> #include <custom.h>
>>
>> using namespace mysqlpp;
>>
>> sql_create_2(clients, 1, 2,
>>               unsigned int,     client_id, // auto_incremented field
>>               unsigned int,     billing_id)
>>
>> void populate_client_info(clients& client_info) {
>>      client_info.billing_id = 1;
>> }
>>
>> int main (int argc, char* const argv[]) {
>>      Connection connection("db_name","ip_address","user",
>>                            "password",3306, false);
>>
>>      Query client_query = connection.query();
>>
>>      clients a_client;
>>      populate_client_info(a_client);
>>
>>      client_query.insert(a_client);
>>      client_query.execute();
>>
>>      return 0;
>> }
>>
>>
>> --
>> MySQL++ Mailing List
>> For list archives: http://lists.mysql.com/plusplus
>> To unsubscribe:    http://lists.mysql.com/plusplus?
>> unsub=grahamreitz@stripped
>>
>
>
> --
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:    http://lists.mysql.com/plusplus? 
> unsub=grahamreitz@stripped
>

Thread
Query insert() Seg Faulting using SSQLS, not sure why...Graham Reitz9 Aug
  • Re: Query insert() Seg Faulting using SSQLS, not sure why...Graham Reitz9 Aug
    • Re: Query insert() Seg Faulting using SSQLS, not sure why...Graham Reitz9 Aug
      • Re: Query insert() Seg Faulting using SSQLS, not sure why...Graham Reitz9 Aug
        • Re: Query insert() Seg Faulting using SSQLS, not sure why...Warren Young9 Aug
          • Re: Query insert() Seg Faulting using SSQLS, not sure why...Graham Reitz11 Aug
          • Re: Query insert() Seg Faulting using SSQLS, not sure why...Graham Reitz11 Aug
            • Re: Query insert() Seg Faulting using SSQLS, not sure why...Graham Reitz11 Aug
              • Inserting with a column that uses auto_incrementGraham Reitz11 Aug
                • RE: Inserting with a column that uses auto_incrementJim Wallace12 Aug
                  • Re: Inserting with a column that uses auto_incrementGraham Reitz12 Aug
                  • Re: Inserting with a column that uses auto_incrementGraham Reitz12 Aug
                    • RE: Inserting with a column that uses auto_incrementJim Wallace12 Aug
                      • Re: Inserting with a column that uses auto_incrementGraham Reitz12 Aug
                      • Re: Inserting with a column that uses auto_incrementWarren Young14 Aug
              • Re: Query insert() Seg Faulting using SSQLS, not sure why...Warren Young28 Dec
Re: Inserting with a column that uses auto_incrementGraham Reitz14 Aug
  • RE: Inserting with a column that uses auto_incrementJoel Fielder14 Aug
    • Re: Inserting with a column that uses auto_incrementGraham Reitz14 Aug
  • Re: Inserting with a column that uses auto_incrementWarren Young15 Aug
    • Re: Inserting with a column that uses auto_incrementGraham Reitz15 Aug
      • Re: Inserting with a column that uses auto_incrementWarren Young16 Aug
        • Re: Inserting with a column that uses auto_incrementGraham Reitz17 Aug
    • Re: Inserting with a column that uses auto_incrementGraham Reitz15 Aug