Re: insert my_ulonglong data with C API
Thanks a lot! But my test is not successful. Please help me. This is my test code: #ifdef WIN32 #include windows.h #endif #include mysql.h #include stdio.h main() { union ull { unsigned char a[8]; my_ulonglong id; } ull; for(int i=0;i8;i++) ull.a[i]=(unsigned char)255; char s[200]; sprintf(s,%llu\n,ull.id); printf(%s\n,s); return 0; } On Windows its output is: 4294967295 It's still a 4bytes integer. Regards, Gu Lei - Original Message - From: Dan Nelson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: mysql@lists.mysql.com Sent: Wednesday, March 15, 2006 3:34 PM Subject: Re: insert my_ulonglong data with C API In the last episode (Mar 15), said: Hello,everyone! My table has a bigint column which needs store 8bytes integer. I looked up in Mysql Menual. It seems that , if I use C API I can only use preapared statement functions to insert bigint values. I can not use mysql_real_query or mysql_query to insert bigint values because I do not know how to convert a my_ulonglong to a string or character array. sprintf(buf, insert into mytable values ( %llu ), myulonglongint); -- Dan Nelson [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: insert my_ulonglong data with C API
Hi, 2006/3/15, 古雷 [EMAIL PROTECTED]: Thanks a lot! But my test is not successful. Please help me. This is my test code: #ifdef WIN32 #include windows.h #endif #include mysql.h #include stdio.h main() { union ull { unsigned char a[8]; my_ulonglong id; } ull; for(int i=0;i8;i++) ull.a[i]=(unsigned char)255; char s[200]; sprintf(s,%llu\n,ull.id); printf(%s\n,s); return 0; } On Windows its output is: 4294967295 It's still a 4bytes integer. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_format_specification_fields_.2d_.printf_and_wprintf_functions.asp try : sprintf(s,%I64d\n,ull.id); -- Pooly Webzine Rock : http://www.w-fenec.org/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: insert my_ulonglong data with C API
In the last episode (Mar 15), ?? said: Thanks a lot! But my test is not successful. Please help me. This is my test code: #ifdef WIN32 #include windows.h #endif #include mysql.h #include stdio.h main() { union ull { unsigned char a[8]; my_ulonglong id; } ull; for(int i=0;i8;i++) ull.a[i]=(unsigned char)255; char s[200]; sprintf(s,%llu\n,ull.id); printf(%s\n,s); return 0; } On Windows its output is: 4294967295 It's still a 4bytes integer. Maybe your compiler doesn't understand the %llu syntax. If it's a posix-compatible compiler, try this (although if it was posix, %llu would have worked, so this probably won't either): #include inttypes.h ... sprintf(s,%PRIu64\n,ull.id); Or read your compiler documentation to verify that can print 64-bit integers at all. -- Dan Nelson [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: insert my_ulonglong data with C API
Nelson: Thanks a lot. I found that sprintf(s,%llu\n,ull.id); works with gcc but not with VC6.0 . Thanks. Regards, Gu Lei - Original Message - From: Dan Nelson [EMAIL PROTECTED] To: ?? [EMAIL PROTECTED] Cc: mysql@lists.mysql.com Sent: Wednesday, March 15, 2006 11:27 PM Subject: Re: insert my_ulonglong data with C API In the last episode (Mar 15), ?? said: Thanks a lot! But my test is not successful. Please help me. This is my test code: #ifdef WIN32 #include windows.h #endif #include mysql.h #include stdio.h main() { union ull { unsigned char a[8]; my_ulonglong id; } ull; for(int i=0;i8;i++) ull.a[i]=(unsigned char)255; char s[200]; sprintf(s,%llu\n,ull.id); printf(%s\n,s); return 0; } On Windows its output is: 4294967295 It's still a 4bytes integer. Maybe your compiler doesn't understand the %llu syntax. If it's a posix-compatible compiler, try this (although if it was posix, %llu would have worked, so this probably won't either): #include inttypes.h ... sprintf(s,%PRIu64\n,ull.id); Or read your compiler documentation to verify that can print 64-bit integers at all. -- Dan Nelson [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
insert my_ulonglong data with C API
Hello,everyone! My table has a bigint column which needs store 8bytes integer. I looked up in Mysql Menual. It seems that , if I use C API I can only use preapared statement functions to insert bigint values. I can not use mysql_real_query or mysql_query to insert bigint values because I do not know how to convert a my_ulonglong to a string or character array. Am I right? Any ideas? Thanks. Regards, Gu Lei
Re: insert my_ulonglong data with C API
In the last episode (Mar 15), said: Hello,everyone! My table has a bigint column which needs store 8bytes integer. I looked up in Mysql Menual. It seems that , if I use C API I can only use preapared statement functions to insert bigint values. I can not use mysql_real_query or mysql_query to insert bigint values because I do not know how to convert a my_ulonglong to a string or character array. sprintf(buf, insert into mytable values ( %llu ), myulonglongint); -- Dan Nelson [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]