Re: Help Required!
Check here. You will find examples here. http://www.geocities.com/jahan.geo [EMAIL PROTECTED] wrote: Hi, I am building the insert string for inserting into particular table t1 using C program. The below string is stored in a variable. say sqlstmt = 'INSERT INTo T1 values(:id,:ename);' The values for the field's id, name will come from the front end. The sql string will be executed using Pro *C in Oracle. Pro *C can get the values of Id and ename fields which are initialized in the C program and can execute the sql statement in Oracle database. The record got inserted successfully. Can we get the MySQL Equivalent so that we can use the same in our C program? Do we have bind variable or host variable concepts in MySQL? In MySQL prompt we tried with @, i.e. set the values of id, ename as set @id = 10, @ename = 'Sample'; Next we used the below command and it worked fine. Insert into t1 values(@id,@ename). Can we use the same @ for the binding values in C' Program for mysql so that it substitutes the value of fields? Thanks for help in advance. Please help. Regards, Narasimha Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL C API questions
Hey check the MySQL C API By Example site. http://www.geocities.com/jahan.geo Yes you have to convert the data always and its zero terminated. Mads Kristensen wrote: Hi all. I'm using the MySQL C API to interface with my MySQL 4.1 server and I have the following questions: When I do a SELECT of some integer data value what is actually returned is a string representation of the integer value and since I need this integer value in my client I have to convert it. Is it possible to get MySQL to return the actual integer value instead? If not, and I actually have to convert the value every time, I have another related question: Are the values returned zero-terminated? Or do I have to use the lengths that I can fetch with mysql_fetch_lengths? The reason that I ask this question is that if the fields are not zero-terminated I have to copy the values into a temporary buffer, zero-terminate that buffer and the do the conversion every time... This seems like a lot of wasted work ;-) Best regards, Mads Kristensen -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Connecting to MySQL using C API
Have you tried my MySQL C API Site ? I have posted some C API examples here. http://www.geocities.com/jahan.geo Aftab Jahan Subear Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.DhakaStockExchangeGame.com Tel: +880-2-7519050 /* Get customized T-Shirts with logo for your IT company for 12 units @ US$14 ~ US$16. Order quantity must be atleast USD$5000++. IT company to IT company. */ premal mishra wrote: I'm using MySQL version 4.0.20a on win98. Compiler is Bloodshed Dev-C++ version 4. My program compiles and links but gives a page fault error on running. I'm linking the '\mysql\lib\opt\mysqlclient.lib' file. Linker gives the warning ignoring duplicate section '.text' CODE: #include config-win.h #include mysql.h #include stdio.h int main(int argc, char *argv[]) { MYSQL mysql; MYSQL *connection; connection= mysql_real_connect(mysql, localhost, root, premal, test, 0, NULL, 0); return 0; } Regards Premal. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: How can I store Images in the MySQL Database
Have you tried my MySQL C API Site ? I have posted some C API examples here. http://www.geocities.com/jahan.geo Aftab Jahan Subear Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh Tel: +880-2-7519050 /* Get customized T-Shirts with logo for your IT company for 12 units @ US$14 ~ US$16. Order quantity must be atleast USD$5000++. IT company to IT company. */ Mulley, Nikhil wrote: Hi Lists , My Query is How Can I store Images in the MySQL Database , and how to Index them , can anybosy help me on this please I am starting out a Online Photo Gallery and want to share them , and I want to make the search available, Does anybody has already done on this ? Please help me in this. Regards, Nikhil. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Live in Puget Sound?
Hey come n visit Dhaka + Learn( free) MySQL, have a holiday too.!!! Bill wrote: I am looking for someone that uses mysql and lives in the Puget Sound area. I am willing to pay someone for a little personalized help in getting started with the basics. I know very little about databases, but know I need to have the capability on my web site for many reasons. I would like this person to be willing to come to my home in Des Moines, WA. I will pay travel time also. If interested contact Bill Cory at 253-946-0114 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Best way to access field name in C
Hey have you checked thi shttp://www.geocities.com/jahan.geo/mysql_c_by_example.html? Matthew Boehm wrote: What is the best way to access a specific field in C? Its really easy in PHP... PHP --- $res = mysql_real_query($mysql,SELECT col1, col2 FROM table); while($row = mysql_fetch_row($res)) { print $row['col1']; print $row['col2']; } Is the only way/best way to do the above in C by using a nested for-loop? Ex: fields = mysql_fetch_fields(res); while((row=mysql_fetch_row(res)) { for(x=0;xnumFields;x++) { sprintf(output, Column name: %s Column Value: %s\n, fields[x].name, row[x]); } } Seems painful and extra-loopy to do it in C. Is there a better way? Thanks, Matthew -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Help needed with MySQL C API-based client (segfault)
have you tried ? http://www.geocities.com/jahan.geo/mysql_c_by_example.html Ruben Safir Secretary NYLXS wrote: On Fri, Sep 19, 2003 at 09:18:22AM +0500, Vikram Vaswani wrote: Hello, I need to write a simple C client for a project. I am using the MySQL C API. Attached is the code. It occassionally segfaults with no visible pattern. Could someone help me figure out why? Or any other comments on the code to help me make it better? You know, I used to read this mailing list religiously before it became flooded with W32 questions and PHP users. And I've stay susbscribed but I haven't posted to it in many many months. iIn fact, I didn't notice I wasn't any longer subscribed. So I'm writing this application in C and GTK and I was thinking, it's finally time to learn to write some MYSQL C API stuff. I've written a lot of Oracle C programs in years past. And now I'm looking at the C API stuff and wow, it is not readly understandable. I open up the mysql mail file with mutt, and bang, this is on the top! I was going to ask the list if anyone has an exmaple of the basic needs for a MYSQL program which makes a connection, sends a querry. Checks the potention errors, and maps the most basic column types to C types. The docs say to look at examples in the source directory, but those aren't yet clear to me to understand. Ruben /* client.c */ #include stdio.h #include mysql.h int main() { /* declare structures and variables */ char query[255]; int i, j, count; MYSQL mysql; MYSQL_RES *result; MYSQL_ROW row; MYSQL_FIELD *field; /* initialize MYSQL structure */ mysql_init(mysql); /* connect to database */ if (!(mysql_real_connect(mysql, NULL, root, , db1, 0, NULL, 0))) { fprintf(stderr, Error in connection: %s\n, mysql_error(mysql)); } for( ;; ) { printf(query? ); gets(query); if (strcmp(query,exit) == 0) { break; } /* execute query */ /* if error, display error message */ /* else check the type of query and handle appropriately */ if (mysql_query(mysql, query) != 0) { fprintf(stderr, Error in query: %s\n, mysql_error(mysql)); } else { if (result = mysql_store_result(mysql)) { /* SELECT query */ /* retrieve result set */ int numRecords = mysql_num_rows(result); int numFields = mysql_num_fields(result); for (i = 0; i numRecords; i++) { row = mysql_fetch_row(result); for (j = 0; j numFields; j++) { //field= mysql_fetch_field(result); fprintf(stdout, %s, row[j]); j != (numFields-1) ? printf(, ) : printf(\n); } } fprintf(stdout, ** Query successful, %d rows retrieved **\n, numRecords); } else { if (mysql_field_count(mysql) == 0) { /* non-SELECT query */ fprintf(stdout, ** Query successful, %d rows affected **\n, mysql_affected_rows(mysql)); } else { fprintf(stderr, Error in reading result set: %s\n, mysql_error(mysql)); } } } /* clean up */ mysql_free_result(result); } mysql_close(mysql); } -- I wouldn't recommend sex, drugs, and insanity for everyone, but it works for me. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.SubedarTechnologies.com http://www.DhakaStockExchangeGame.com/ http://www.CEOBangladesh.com/ http://www.NYSEGame.com tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: bad too many connections error (os x)
This also may caused by the TTL of the http socket and the launched zombie forks by the http/php server ( the FIN_WAIT_2 problem!!). Thats what it happend to me . I dunno who waited for who, and became zombie, was it MySQL waiting for timeout or was socket wating to timeout. You can test this easily. Simultaneously issue same instance of the service in question from same network and watch the netstat and top -t. -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook Alex Greg wrote: Michael Winston wrote: On Sep 1, 2004, at 9:10 AM, V. M. Brasseur wrote: Michael Winston wrote: Hi- We've been running into a pretty serious problem for the past several versions of mysql 4.0 running on OS X (both client and server). Every once in a while we wake up to find the too many connections error coming up. There really aren't too many connections (we have our max set to 99) - it's the type of message that appears when a wrong password is used too many times (and I'm 100% sure this isn't happening). Now, the problem is that once this message starts appearing we can't even connect with mysqladmin as root. That extra connection that mysql promises doesn't exist. The only way we can shut down mysql is to perform a 'kill -9' (then restart the server and repair all the tables). And we can't reproduce this problem at will. This is driving us nuts. Before I report this as a bug I wanted to know if anyone else has seen something like this or has any suggestions of how to narrow down the problem. Thanks! Michael We've run into this problem ourselves, also using 4.0 but on a 64bit AIX. The problem we found was that some queries were firing off threads which never ended. These threads blocked other threads, which blocked other threads... A logjam resulted with all connections ended up being used by the offending threads. The fix was to *ahem* fix our queries so they'd close their database connections once they were complete. You may wish to do a code inspection and verify that every open connection has a matching close. Hmmm. All of our connections are coming from php-generated web pages. PHP automatically closes the connection at the end of the script. Unless I completely misunderstand how this stuff works. Plus, this problem only happens once every few weeks. If some of our queries are causing this, I would expect the problem to occur more often. I'll look into this, though. Thanks, Michael You'll also find this problem if you have some badly-optimised queries, or writes that take a long time to run on a frequently-accessed table. For example, if you have a table that frequently accessed and run a slow update on it, any thread trying to read from that table will block. If you get more selects happening to that table coming in while it's still locked, your number of connections in use will shoot upwards rapidly until the slow update finishes and the table is unlocked. Have a look in your slow query log (or turn it on if it's not enabled) to look for any queries like this. Regards, -- Alex -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: c api and creating looped queries
I have arranged some MySQL C API examples at http://www.geocities.com/jahan.geo/mysql_c_by_example.html Larry Brown wrote: On Sat, 2004-08-28 at 00:48, I wrote: I know this is more along the lines of a c question; however, I am trying to write a loop to iterate insertions into a mysql database and was hoping someone would have a quick fix for this. I am used to using php with the luxury of the following syntax some loop giving values $column1 and $column2 usually from some array or parsing of a file $query = mysql_query( insert into my_table values ( null, '$column1', 'some description $column2' ); next iteration Can anyone just show a one liner of how to do this in c where the values are column1 and column2? I know there is a string concatenation function, it just seems so clumsey to write it out, get the string length of each of the two variables and create a new longer line. I won't be suprised if that is what I have to do though. ( being new to c and finding out how much more work it entails:-) ). Hope this make since at nearly 1 am. Been a long day... OK, hate to answer my own question but sprintf is what I was looking for. It is hard to switch languages! Especially in this direction. ;-) -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.SubedarTechnologies.com http://www.DhakaStockExchangeGame.com/ http://www.CEOBangladesh.com/ http://www.NYSEGame.com tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: mysql c-api 1064 mysql_real_query: issue with upgrade to 4.1.3
Can you check the client version and server version from c api? you can copy paste it from (ehem) http://www.geocities.com/jahan.geo/mysql_c_by_example.html VY wrote: Hi, For some reason, all my sql queries fail with a 1064; These were all working under mysql-4.0 but had to upgrade to 4.1 so i could use nested subqueries i have attached a simple 10 line c-code as proof of concept. Obviously there is nothing wrong with the query... #include stdio.h #include stdlib.h #include unistd.h #include string.h #include mysql.h static MYSQL handle; int main() { char query[1500]; int c; mysql_init(handle); if (!mysql_real_connect(handle, localhost, mysql, mysql, honey_db, 0, NULL, 0)) { fprintf(stderr, connect failed %s\n, mysql_error(handle)); exit(1); } sprintf(query, select * from test); printf(%s\n, query); c = mysql_real_query(handle, query, strlen(query)+500); if (c) { printf(query failed...%d %d\n, c, mysql_errno(handle)); printf(mysql_error(handle)); } } The output is as follows (the first two lines are my debug output) select * from test query failed...1 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1: I have tried both FreeBSD mysql-standard-4.1.3-beta-unknown-freebsd4.7-i386 and the linux-4.1.3 rpm with identical results. Please let me know what im doing wrong The table test exists in honey_db and is accessible by the mysql user. Thanks! __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.SubedarTechnologies.com http://www.DhakaStockExchangeGame.com/ http://www.CEOBangladesh.com/ http://www.NYSEGame.com tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
MySQL C API Examples
I have arranged some MySQL C API examples at http://www.geocities.com/jahan.geo/mysql_c_by_example.html Comments/ Suggestion welcome. -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.SubedarTechnologies.com ( down now ) http://www.DhakaStockExchangeGame.com/ ( down now ) http://www.CEOBangladesh.com/( down now ) http://www.NYSEGame.com( down now ) tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: AW: C compared to C++/Java; Was: Re: InnoDB Hot Backup + MySQL em bedded?
I would say using C in C++ compiler or C++ itself is best. come see my http://www.DhakaStockExchangeGame.com , its totally written C++. My upcoming NYSEGame.com is also using C++. This time I made 4 base classes to handle the whole thing . Soon I will make those class public. Pete McNeil wrote: Hello, Personally, I think it's a matter of choosing the best tool for the job. For myself and my team, Java is the work horse particularly - suited for rapid application development and when there is a strong cross platform requirement. This means that Java tends to dominate our utilities and user-interface code. When heavy lifting is required we move to C++. Java's object model is simplistic (both a strength and a weakness). C++ is extremely flexible and efficient. To a greater extent, C/C++ will let you do a lot of things you really shouldn't. Java isn't immune to this. After all, bad engineering is bad engineering. In both cases it's up to the programmer to keep things where they should be. As for seeing a lot of bad Java programs and a lot of bad C/C++ programs... In my experience I've seen about the same of both... but a bad C/C++ program is less likely to survive deployment than a bad Java program. My $0.03. _M At 04:39 AM 2/21/2004, Franz, Fa. PostDirekt MA wrote: Hi, this discussion is useless, object or procedure is not realy the question. You need to know how to build a good programm, if you cannot create a good programm, no matter what language. The amount of realy bad java-programs (90% i have seen were realy bad) shows, that it is maybe not a good idea, to make programming to easy :o) . There are a lot of people, thinkink a complex task is better done with an oo-language. My boss is this opinion and had already 2 memleaks in C++, he searched for one 6 weeks. So the truth seems to be, that an oo-language (especially java) makes it easy to programm complex tasks, but what comes out in the end is worth. I prefer TCL because on my opinion it is the best of both worlds ( i never had a memleak except with a bad API written in C). Complex tasks should be done from skilled programmers - thats all. mfg Klaus -Ursprüngliche Nachricht- Von: Heikki Tuuri [mailto:[EMAIL PROTECTED] Gesendet: Samstag, 21. Februar 2004 09:30 An: [EMAIL PROTECTED] Betreff: C compared to C++/Java; Was: Re: InnoDB Hot Backup + MySQL embedded? Jochem, - Original Message - From: Jochem van Dieten [EMAIL PROTECTED] Newsgroups: mailing.database.myodbc Sent: Saturday, February 21, 2004 2:10 AM Subject: Re: InnoDB Hot Backup + MySQL embedded? Sasha Pachev wrote: Heikki Tuuri wrote: C versus object-oriented lanuguages like C++/Java is a topic I have discussed a lot with programmers. I believe that traditional procedural approaches and languages, like C, are the best for 'systems programming', by which I mean implementing anything with complex data structures and lots of parallelism. A DBMS is a typical example of such a complex program. 3) A weakness of C compared to Java is memory management. In C you can easily write programs that leak memory or run over allocated buffers. In practice, it has turned out to be relatively easy to keep these memory management bugs at a tolerable level in our C programs, so that a move to a language with automatic memory management is not needed. In Java is it easy to write a program that wastes large amounts of memory, which is worse than a leak. In C, you are full from the start, and then you leak a drop at a time until you are empty. In Java , you are empty from the start, and you have nothing to leak anyway even if you could :-) http://citeseer.nj.nec.com/shah01java.html here is a .pdf version of the paper: http://gist.cs.berkeley.edu/~mashah/java-paper/paper.pdf The authors used a 2 x Pentium III 667 MHz, Linux-2.2.16, Sun JDK 1.3, and Java HotSpot Server JVM 1.3.0. to implement a 'data-flow' query processor. Their conclusion is that the memory management and the garbage collection of Java is inefficient. The graph that they present shows an up to 2.5-fold performance degradation with the Java garbage collector, compared to their own tailored memory management system. I worked with Entity Systems Oy in the 1980s. We developed a Lisp interpreter and a compiler, and a Prolog interpreter. At that time, the inefficiency of the garbage collection in Lisp and Prolog was a serious problem. I am not familiar with more modern garbage collection algorithms, but the paper of Shah et al. suggests that there are still problems today. In the 1980s, the research group of Mike Stonebraker initially started implementing Postgres in a mixture of Lisp and C, but they later abandoned Lisp. Jochem Regards, Heikki -- I don't get it immigrants don't work and steal our jobs - Loesje -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204
Re: Pending results blocking mysql-server
I am interested to help, you can email me the call graph or source. I nearly have nothing much to do ( no client, teching guiter now!!! ha ha). I am using the C API 100% flawlessly in my http://www.DhakaStockExchangeGame.com/ Still using it -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.SubedarTechnologies.com http://www.DhakaStockExchangeGame.com/ http://www.CEOBangladesh.com/ http://www.NYSEGame.com tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook Stefan Hinz wrote: Klaus, we are porting an application from ORACLE to MySQL. The application does lot of queries and has and times out a query, if no result is back after 10 seconds. It handles queries parrallel and rasies or lowers the amount of connection variable (the programm is a server itself). After a while, there is very big load on the MySQL-server (up to 90) and 'show processlist' shows very many connections with queries that are in 'sending data'-state. But after they are timed out, this results will never be fetched, but the threads for them are kept a very long time. With lot of queries, it even happens, that a connection to the mysql-server is blocked. i think it would be the best to get rid of hte pending results on the server, that are not fetched after let's say 20 seconds. Which variable do i need to set to achieve this (if possible). The program uses the C-API. The serve is 4.017 with MyISAM-Tables on SUSE-LINUX SLES 8.0, Ext3-filesystem, a 3Ghz xeleron, 1.5G MEM. Please help me, after i convienced my boss to use MySQL for this duty (which took about 18 month), this might be very dangerous for my carreer. Would it be possible to call mysql_free_result() from your application? You might be able to set a timer in your app, calling that function after, for example, 20 seconds. http://www.mysql.com/doc/en/mysql_free_result.html Regards, -- Stefan Hinz [EMAIL PROTECTED] iConnect GmbH http://iConnect.de Heesestr. 6, 12169 Berlin (Germany) Telefon: +49 30 7970948-0 Fax: +49 30 7970948-3 [filter fodder: sql, mysql, query] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Segmentation Fault/Core dump
It will more easier if you post the sample.c. you can try compiling with -ggdb to debug Leif Johnston wrote: Any thoughts on what might be causing this error? I am runing both on cygwin under windows 2000 with 4.0.16 and using gcc to compile, linking using gcc sample.c -o sample.exe -I/usr/include/mysql -L/lib/mysql/opt/ -lmysqlclient -lmySQL -lz -lm I assume that something in the libraries may not be correct or that I need to check some other parameter but I am at a loss. Thanks Leif -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.SubedarTechnologies.com http://www.DhakaStockExchangeGame.com/ http://www.CEOBangladesh.com/ http://www.NYSEGame.com tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Subtracting date fields
try SELECT id,(TO_DAYS(firstdate)- TO_DAYS(postdate)) AS diff FROM calendar well you have to put the bigger date on the lhs. Kenneth Letendre wrote: Hello, I'm trying to get the difference (in days) between dates stored in two date fields. My query: SELECT id,(firstdate- postdate) AS diff FROM calendar This works fine if the two dates are in the same month, but not otherwise. MySQL appears to be treating the two dates as base-10 integers rather than dates. E.g.: 2004-01-07 (20,040,107) - 2003-12-31 (20,031,231) = 8876 How do I get MySQL to treat these date fields as date fields in this case? Thanks, Kenneth -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.SubedarTechnologies.com http://www.DhakaStockExchangeGame.com/ http://www.CEOBangladesh.com/ http://www.NYSEGame.com tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Memory leaks using MySQL C Api
Hey wait a minute. Where did you get the my_free(), may be you are trying to say mysql_free(), but then that is used only if result set is used/called. But the code does not show any result set call. ie. mysql_use_result() or mysql_store_result(). So, the question now, how come there is a leak here. I dont see any, does anyone see any? Chris Nolan wrote: Hi! You're looking for the function my_free(). Enjoy! Regards, Chris John McCaskey wrote: I have the following code: //try the mysql connection mysql_init(mysql_connection); if(!mysql_real_connect(mysql_connection, db_host, db_user, db_pass, db_db, 0, NULL, 0)) { flockfile(stderr); fprintf(stderr, %s: Failed to connect to database: Error: %s\n, timestamp, mysql_error(mysql_connection)); funlockfile(stderr); mysql_close(mysql_connection); return(2); } mysql_close(mysql_connection); This code is creating a memory leak. Am I missing some cleanup calls? I'm under the impression all I should need to do is call mysql_close to clean up the connection? I'm testing this using mtrace, if I place a return directly above the code segment it reports no leaks, if I place it direcly below the fragment there are several variables reported as not being freed. Any ideas? John A. McCaskey -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.SubedarTechnologies.com http://www.DhakaStockExchangeGame.com/ http://www.CEOBangladesh.com/ http://www.NYSEGame.com tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Recommended Course
Hey why not travel to Dhaka in my tour learn package. I teach 1. C/C++ on Unix/Win32/MFC 2. MySQL C API uses with MySQL 3. C+CGI+MySQL+MySQL C API 3. MySQL Administration Tour learn package available vice-versa tooo!!! If you can provide passage. Marc Dver wrote: This might be a bit of a repeat, but I didn't get too many responses. Can someone recommend a course in the Northeast of the US that teaches the details of the use of mysql? Sincerely, Marc DVer -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.DhakaStockExchangeGame.com/ - [EMAIL PROTECTED] http://www.CEOBangladesh.com/ - [EMAIL PROTECTED] http://www.geocities.com/jahan.geo/ - [EMAIL PROTECTED] sms://+447765341890 tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: apostrophe error
Try using QUOTE function. Asif Iqbal wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi All I have been using mysql database to collect my syslog data. It was working fine. However recently I had few logs that had apotrophe and I failed to insert those lines into my database. It said syntax error. Is there any patch anything I can put and recompile mysql so it won't fail while inserting log lines that has apotrophe (') in it ? Thanks a lot - -- Asif Iqbal PGP Key: E62693C5 There's no place like 127.0.0.1 -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.1 (SunOS) iD8DBQE//LS0UAgaF+Ymk8URAs3xAJ0W8c3tSgWd6xE45qLB25KTSJRv3wCffEb3 eDhzNcJuik1HH3J8CQYj77A= =eUX1 -END PGP SIGNATURE- -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.DhakaStockExchangeGame.com/ - [EMAIL PROTECTED] http://www.CEOBangladesh.com/ - [EMAIL PROTECTED] http://www.geocities.com/jahan.geo/ - [EMAIL PROTECTED] sms://+447765341890 tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
1142: Issue in 4.1.0-alpha
Hi ya, Is it dissolved in the new versions ? Only three posting so far on that. I just keep forgetting 1142 and always endup digging the source!! root as user solves the problem. -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.DhakaStockExchangeGame.com/ - [EMAIL PROTECTED] http://www.CEOBangladesh.com/ - [EMAIL PROTECTED] http://www.geocities.com/jahan.geo/ - [EMAIL PROTECTED] sms://+447765341890 tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Bug in mysql.h header file
Hi P Arunachalam , Add this to your program . Make sure header files exist ( its there anyway). #ifdef WIN32 #include windows.h #include winsock2.h #pragma warning (disable: 4514 4786) #pragma warning( push, 3 ) #define VERSION 4.1 #endif Enjoy... P Arunachalam wrote: Hi, I have made all the changes suggested by you in VC++ 6.0 i.e., I have inluded the Library file wsock32.lib into the existing library list in 'Project Settings'(Alt-F7') and checked the path setting of mysql header file and library file in Tools -- Options menu's Directory tab. but still it need the inclusion of header file winsock.H into my C program... otherise it shows the list of errors. name of my C program file is 'mysql.c' Error executing cl.exe. MYSQL.OBJ - 102 error(s), 1 warning(s) So pls verify and give me details... arun. --- info [EMAIL PROTECTED] wrote: This is not a bug, you need to set your project/programming environment in VC++ to include support for sockets. I haven't written any non socket programs in several years, so it's part of my standard set-up. MySQL is client/server and uses sockets. You do need to link with a socket library. In the case of VC++ this is Winsock (wsock32.lib). I normally include support for sockets in my stdfx.h (#include afxsock.h // MFC socket extensions). This is included with your VC++ installation and not part of mysql source. Then, add wsock32.lib, mysqlclient.lib and any other external library you need to link with in your 'Project Settings'(Alt-F7'). These are added under the 'Link' tab in the 'Input' category. Libraries are added in the 'Object/library module' field separated by spaces (e.g. 'wsock32.lib mysqlclient.lib'). Don't forget to add the path to the mysqlclient library in the 'Additional library path:' field. Pat... - Original Message - From: P Arunachalam [EMAIL PROTECTED] To: Patrick Sherrill [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, December 16, 2003 6:36 AM Subject: Bug in mysql.h header file I was trying to establish connection to MySQL through a simple C program using it's C API mysqL_init(), mysql_reak_connect(), ... in VC++ Editor. It shows Errors ; Compiling... MYSQL.C c:\mysql\include\mysql_com.h(116) : error C2061: syntax error : identifier 'SOCKET' MYSQL.OBJ - 102 error(s), 1 warning(s) I have corrected this errors by including winsock.h header file into my program. After including winsock.h my program work fine and produce my expected results. Herewith I have included the Sample C Program too for your reference... Incase it is a bug you please produce the correct version of mysql.h header file to me. Thanks. regards, Arun. --- Patrick Sherrill [EMAIL PROTECTED] wrote: Statically linking using C API only you will need mysqlclient.lib For odbc interface you'll need to make odbc calls in your code and use myodbc.dll (Install myodbc on the client). You can mix calls, but why would you. I have found the C API to be the best solution for us. We statically link for dll avoidance. You can get the source or pre-built client libraries from the MySQL web site. I hope this helps. Pat... [EMAIL PROTECTED] CocoNet Corporation SW Florida's First ISP 825 SE 47th Terrace Cape Coral, FL 33904 - Original Message - From: P Arunachalam [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, December 11, 2003 4:31 AM Subject: reg C API from MySQL Yahoo! India Mobile: Download the latest polyphonic ringtones. Go to http://in.mobile.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] Yahoo! India Mobile: Download the latest polyphonic ringtones. Go to http://in.mobile.yahoo.com -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.DhakaStockExchangeGame.com/ - [EMAIL PROTECTED] http://www.CEOBangladesh.com/ - [EMAIL PROTECTED] http://www.geocities.com/jahan.geo/ - [EMAIL PROTECTED] sms://+447765341890 tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: foreign keys.
If you have foreign key then add a key for each, so the CREATE TABLE foo ( ID INT PRIMARY KEY, note VARCHAR(50), Fname VARCHAR(50), Lname VARCHAR(50), FOO_ID INT, INDEX(FOO_ID), KEY(Fname,Lname), #here this one--if it does not work,its not me FOREIGN KEY (FOO_ID) REFERENCES foo(ID), FOREIGN KEY (Fname, Lname) REFERENCES Blah (Fname, Lname) ) TYPE=INNODB; Mofeed Shahin wrote: On Mon, 15 Dec 2003 09:22 pm, Victoria Reznichenko wrote: Mofeed Shahin [EMAIL PROTECTED] wrote: On Mon, 15 Dec 2003 12:42 pm, Paul DuBois wrote: At 11:09 +1030 12/15/03, Mofeed Shahin wrote: I'm trying to create a bunch of tables in MySQL. I'm having problems creating the following table : CREATE TABLE foo( ID INT PRIMARY KEY, note VARCHAR(50), FOO_ID INT, FOREIGN KEY (FOO_ID) REFERENCES foo(ID) ) TYPE=INNODB; The error I get is the following : ERROR 1005: Can't create table './moftest/foo.frm' (errno: 150) I found out that errno 150 means that it didn't like the Foreign key constraint. Does MySQL not support this type of Foreign Key constraint ? If does. However, a foreign key must be indexed, and you have declared no index on FOO_ID. Try this: CREATE TABLE foo( ID INT PRIMARY KEY, note VARCHAR(50), FOO_ID INT, INDEX (FOO_ID), FOREIGN KEY (FOO_ID) REFERENCES foo(ID) ) TYPE=INNODB; Thanks, but I just did, and I got the same error message. Paul's example works fine for me. What version of MySQL do you use? yeah, sorry Paul's example works here as well. But the actual create statement I'm using here is failing. My create statement is stightly different, and I didn't think it would make a difference (ooops!!). So here is the actual create statement that is failing ; CREATE TABLE Blah ( ID INT PRIMARY KEY, Fname VARCHAR (50), Lname VARCHAR (50), UNIQUE (Fname, Lname) ) TYPE=INNODB; CREATE TABLE foo ( ID INT PRIMARY KEY, note VARCHAR(50), Fname VARCHAR(50), Lname VARCHAR(50), FOO_ID INT, INDEX(FOO_ID), FOREIGN KEY (FOO_ID) REFERENCES foo(ID), FOREIGN KEY (Fname, Lname) REFERENCES Blah (Fname, Lname) ) TYPE=INNODB; Once again sorry for the confusion. It must be a problem with adding the second foreign key. Mof. -- Aftab Jahan Subedar CEO/Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh http://www.DhakaStockExchangeGame.com/ - [EMAIL PROTECTED] http://www.CEOBangladesh.com/ - [EMAIL PROTECTED] http://www.geocities.com/jahan.geo/ - [EMAIL PROTECTED] sms://+447765341890 tel://+88027519050 EMail://[EMAIL PROTECTED] - Directly to my notebook -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: C API: undefined reference
alright. looking at your directory this should be ok. gcc seeLog.c -o seeLog -I/usr/include -L/usr/lib/mysql -lmysqlclient ;) Aftab Jahan Subedar Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh sms://+447765341890 tel://+88027519050 [EMAIL PROTECTED] http://www.DhakaStockExchangeGame.com/ hAj wrote: Hello Jahan, on 2003.11.11 07:43, Aftab Jahan Subedar at [EMAIL PROTECTED] wrote: use the following options to compile gcc seeLog.c -o seeLog -I/usr/local/include -L/usr/local/lib/mysql -lmysqlclient Strangely, your options and mine came out with the same error: The first is yours and 2nd is mine. ~/www -gcc seeLog.c -o seeLog -I/usr/local/include -L/usr/local/lib/mysql -lmysqlclient /tmp/ccuX7I5J.o: In function `main': /tmp/ccuX7I5J.o(.text+0x2a): undefined reference to `mysql_connect' collect2: ld returned 1 exit status ~/www -gcc seeLog.c -o seeLog -I/usr/include -L/usr/lib -lmysqlclient /tmp/ccZxcaCR.o: In function `main': /tmp/ccZxcaCR.o(.text+0x2a): undefined reference to `mysql_connect' collect2: ld returned 1 exit status What does this undefined reference really imply, that the lib binary is broken ? Below is to show you where the .h and lib file I need are located on this particular system I'm trying to run the thing: ~/www -find / -name '*mysql.h*' 2- /home/temp/installd/buildapache/php-4.3.3/ext/dbx/dbx_mysql.h /home/temp/installd/buildapache/php-4.3.3/ext/mysql/libmysql/mysql.h /home/temp/installd/buildapache/php-4.3.3/ext/mysql/php_mysql.h /home/cpapachebuild/buildapache/php-4.3.3/ext/dbx/dbx_mysql.h /home/cpapachebuild/buildapache/php-4.3.3/ext/mysql/libmysql/mysql.h /home/cpapachebuild/buildapache/php-4.3.3/ext/mysql/php_mysql.h /usr/include/mysql/mysql.h ~/www -find / -name '*mysqlclient*' 2- /usr/lib/mysql/libmysqlclient.a /usr/lib/mysql/libmysqlclient.la /usr/lib/mysql/libmysqlclient_r.a /usr/lib/mysql/libmysqlclient_r.la /usr/lib/libmysqlclient.so /usr/lib/libmysqlclient.so.12 /usr/lib/libmysqlclient.so.12.0.0 /usr/lib/libmysqlclient_r.so /usr/lib/libmysqlclient_r.so.12 /usr/lib/libmysqlclient_r.so.12.0.0 /usr/lib/libmysqlclient.so.10 /usr/lib/libmysqlclient.so.10.0.0 /usr/lib/libmysqlclient_r.so.10 /usr/lib/libmysqlclient_r.so.10.0.0 /usr/lib/libmysqlclient.so.9 /usr/lib/libmysqlclient.so.6 Best, hAj Aftab Jahan Subedar Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh sms://+447765341890 tel://+88027519050 [EMAIL PROTECTED] http://www.DhakaStockExchangeGame.com/ hAj wrote: Hello MySQL pros worldwide, ~/www -cat seeLog.c #define USE_OLD_FUNCTIONS #include stdio.h #include mysql/mysql.h int main() { MYSQL mysql; MYSQL *mysqldb = NULL; mysqldb = mysql_connect(mysql, geneofcube.net, USERID, PASSWORD); return 0; } ~/www -gcc seeLog.c -o seeLog -I/usr/include -L/usr/lib -lmysqlclient use the following options to compile -I/usr/local/include -L/usr/local/lib/mysql -lmysqlclient jahan /tmp/ccEj3tmv.o: In function `main': /tmp/ccEj3tmv.o(.text+0x2a): undefined reference to `mysql_connect' collect2: ld returned 1 exit status ~/www - As shown above, I'm having a problem getting rid of a compilation error (undefined reference) coming out with a very simple c code (seeLog.c) which I wrote for a testing purpose. Got no I idea what I'm doing wrong or missing here. I'd appreciate any of your suggestions. Best, hAj -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
MySQL Success Story
Dear Lists MySQL, I have just released the site http://www.DhakaStockExchangeGame.com/ which uses MySQL database and CGICC heavily. I Like MySQL, cuz, I can twist,turn,roll and whatever I want with its MySQL C API. Thank you MySQL, you all are really good. Dont become sooo commercial. Aftab Jahan Subedar Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh sms://+447765341890 tel://+88027519050 [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
MySQL Success Story
Dear Lists MySQL, I have just released the site www.DhakaStockExhcnageGame.com which uses MySQL database and CGICC heavily. I Like MySQL, cuz, I can twist,turn,roll and whatever I want with its MySQL C API. Thank you MySQL, you all are really good. Dont become sooo commercial. Aftab Jahan Subedar Subedar Technologies Subedar Baag Bibir Bagicha #1 North Jatrabari Dhaka 1204 Bangladesh sms://+447765341890 tel://+88027519050 [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
mysql_last_value() update
/* Copyright (c) 2003 Aftab Jahan Subedar mysql_last_value() Version 3.2 -- Replaces NULL column(s) with value from last available column value. Scenario Table to be operated on. table_a --- record id color 1001 BLACK 2NULLPINK NULL 002 WHITE 3NULLBLUE NULL NULLGREEN NULL 003 YELLOW 4004 BALCK Table that is converted to. table_b --- record id color 1001 BLACK 2001 PINK 2002 WHITE 3002 BLUE 3002 GREEN 3003 YELLOW 4004 BALCK This is free for public. Commercial uses require license from Aftab Jahan Subedar Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 81/1-A North Jatrbari Dhaka 1204 Bangladesh sms://+447765341890 sms://+880171859159 http://www.ceobangladesh.com http://www.DhakaStockExchangeGame.com http://www.geocities.com/jahan.geo -- source code found here +880171859159 sms +447765341890 [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Has Problem? Feel free to report. License Fee: USD 25 or equivalent for Lifetime . Bank information: i. Aftab Jahan Subedar Sort Code: 800283 Account No. 07271988 Bank Of Scotland Newington Branch 51 South Clerk Street Edinburgh EH8 9PP UK ii. Aftab Jahan Subedar Savings Account No. 794-2-4403321-4 [Sort Code 794] Standard Chartered Bank 32 36 Jalan 52/4 Petaling Jaya Selangor Malaysia iii.Aftab Jahan Subedar Savings Account No. 18 1757 393 01 [Sort Code 18] Standard Chartered Bank 53 Kawran Bazar, G.P.O Box #3668 Dhaka 1215 Bangladesh compile instruction: cc -o mysql_last_value mysql_last_value.c -I/usr/local/include/mysql -L/usr/local/lib/mysql -lmysqlclient usage: ./mysql_last_value -u user -h host -d last_value_test -f table_from -t table_to -r replace_field1 replace_fieldn -v -p secretpassword Parameters: -d database -f from which table to copy from -t to which table to be copied to -r replace field names separated with space. upto 20 fields. -v display verbose -v -v display insert statement ;( example: ./mysql_last_value -d last_value_test -f table_a -t table_b -r record id -v ./mysql_last_value -d last_value_test -f table_a -t table_b -r record -v Training available on C/C++, CGI, Unix , MySQL (or other API) in Bangladesh and abroad. */ #include stdio.h #include fcntl.h #include stdlib.h #include unistd.h #include string.h #include ctype.h #include mysql.h /* for freeing easily*/ char*host = NULL; char*user = NULL; char*passwd = NULL; char*database = NULL; char*sql_insert_to = NULL; char*sql_insert_from = NULL; int verbose = 1; int use_supplied = 0; char*last_value=NULL; char*replace_field_name=NULL; char*criterion=NULL; char*insert_statement=NULL; char*replace_value[20]; unsigned int*puiQuotes=NULL; char*pcQuery=NULL; MYSQL mysql; MYSQL_RES *pResult=NULL; unsigned int*puiIndexOfReplaceField=NULL; unsigned intuiNumOfReplaceField=0; unsigned long *pulFieldLengths; unsigned int uiReplaceIndex=0; void usage(void); void free_all(void); char *strupr(char *str); /*int strcmpp(const char *p1, const char *p2);*/ void append_insert(unsigned long length,char *value); unsigned int get_replace_index(unsigned int uiCurrentIndex); void replace_field(MYSQL_ROW pTuple,unsigned int uiFieldIndex,unsigned int uiReplaceIndex); void copy_field(MYSQL_ROW pTuple,unsigned int uiFieldIndex); void append_insert(unsigned long length,char *value) { unsigned long old_length=0; char *p
Re: Newbie question...memo field
The following program will solve your problem. Feel free to miss use ;) -- Aftab Jahan Subedar Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 81/1-A North Jatrbari Dhaka 1204 Bangladesh sms://+447765341890 sms://+880171859159 http://www.ceobangladesh.com http://www.DhakaStockExchangeGame.com http://www.geocities.com/jahan.geo /* Copyright (c) 2003 Aftab Jahan Subedar mysql_last_value() Version 3.1 -- Replaces NULL column(s) with value from last available column value. Scenario Table to be operated on. table_a --- record id color 1001 BLACK 2NULLPINK NULL 002 WHITE 3NULLBLUE NULL NULLGREEN NULL 003 YELLOW 4004 BALCK Table that is converted to. table_b --- record id color 1001 BLACK 2001 PINK 2002 WHITE 3002 BLUE 3002 GREEN 3003 YELLOW 4004 BALCK This is free for public. Commercial uses require license from Aftab Jahan Subedar Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 81/1-A North Jatrbari Dhaka 1204 Bangladesh sms://+447765341890 sms://+880171859159 http://www.ceobangladesh.com http://www.DhakaStockExchangeGame.com http://www.geocities.com/jahan.geo -- source code found here +880171859159 sms +447765341890 [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Has Problem? Feel free to report. License Fee: USD 25 or equivalent for Lifetime . Bank information: i. Aftab Jahan Subedar Sort Code: 800283 Account No. 07271988 Bank Of Scotland Newington Branch 51 South Clerk Street Edinburgh EH8 9PP UK ii. Aftab Jahan Subedar Savings Account No. 794-2-4403321-4 [Sort Code 794] Standard Chartered Bank 32 36 Jalan 52/4 Petaling Jaya Selangor Malaysia iii.Aftab Jahan Subedar Savings Account No. 18 1757 393 01 [Sort Code 18] Standard Chartered Bank 53 Kawran Bazar, G.P.O Box #3668 Dhaka 1215 Bangladesh compile instruction: cc -o mysql_last_value mysql_last_value.c -I/usr/local/include/mysql -L/usr/local/lib/mysql -lmysqlclient usage: ./mysql_last_value -u user -h host -d last_value_test -f table_from -t table_to -r replace_field1 replace_fieldn -v -p secretpassword Parameters: -d database -f from which table to copy from -t to which table to be copied to -r replace field names separated with space. upto 20 fields. -v display verbose -v -v display insert statement ;( example: ./mysql_last_value -d last_value_test -f table_a -t table_b -r record id -v ./mysql_last_value -d last_value_test -f table_a -t table_b -r record -v Training available on C/C++, Unix , MySQL (or other API) in Bangladesh and abroad. */ #include stdio.h #include fcntl.h #include stdlib.h #include unistd.h #include string.h #include ctype.h #include mysql.h /* for freeing easily*/ char*host = NULL; char*user = NULL; char*passwd = NULL; char*database = NULL; char*sql_insert_to = NULL; char*sql_insert_from = NULL; int verbose = 1; int use_supplied = 0; char*last_value=NULL; char*replace_field_name=NULL; char*criterion=NULL; char*insert_statement=NULL; char*replace_value[20]; unsigned int*puiQuotes=NULL; char*pcQuery=NULL; MYSQL mysql; MYSQL_RES *pResult=NULL; unsigned int*puiIndexOfReplaceField=NULL; unsigned intuiNumOfReplaceField=0; unsigned long *pulFieldLengths; unsigned int uiReplaceIndex=0; void usage(void); void free_all(void); char *strupr(char *str); /*int strcmpp(const char *p1, const char *p2);*/ void append_insert(unsigned long length
Re: Need help in querying two tables
SELECT [field list] FROM archivetable,currenttable WHERE archivetable.username=currenttable.username notes: can use join,left,right,select inside select aka subselect check the manual for detail Regards, -- Aftab Jahan Subedar Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 81/1-A North Jatrbari Dhaka 1204 Bangladesh sms://+447765341890 sms://+880171859159 http://www.ceobangladesh.com http://www.DhakaStockExchangeGame.com http://www.geocities.com/jahan.geo Fred van Engen wrote: Hi, On Fri, Aug 01, 2003 at 11:55:36PM +0800, Jaime Teng wrote: Now, I have two of these tables (archivetable,currenttable). My problem is how do I perform a single query such that I get results from these two tables: mysql select * from archivetable,currenttable; +++-+-+ | sessionid | username | logon | logoff | +++-+-+ | 03 | dangco77 | 1996-09-25 20:51:59 | 1996-09-25 21:07:00 | | 06 | mccarthy | 1996-09-26 06:15:35 | 1996-09-26 06:20:00 | | 07 | sigmaph| 1996-09-26 06:25:48 | 1996-09-26 06:28:00 | | 09 | sigmaph| 1996-09-26 08:31:53 | 1996-09-26 08:51:00 | | 1000265891 | okame | 2003-08-01 13:38:24 | 2003-08-01 13:43:42 | | 1000265893 | kbs| 2003-08-01 13:38:30 | 2003-08-01 13:38:48 | | 1000265897 | bdo-albaro | 2003-08-01 13:38:54 | 2003-08-01 14:07:06 | +++-+-+ of course that last query isnt correct but thats the result I want. You can use a UNION to do this, but you need MySQL 4.x. It won't work in 3.23.x or before. Look in the manual for details. any suggestion? I read about using JOIN but I have no idea how to\ make it work for my need. Joins are used for combining records from multiple tables, which is not what you seem to want to do. Regards, Fred. Regards, -- Aftab Jahan Subedar Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 81/1-A North Jatrbari Dhaka 1204 Bangladesh sms://+447765341890 sms://+880171859159 http://www.ceobangladesh.com http://www.DhakaStockExchangeGame.com http://www.geocities.com/jahan.geo -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Using query file from console
try the shortest. mysql yoursource.sql ;) -- Aftab Jahan Subedar Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 81/1-A North Jatrbari Dhaka 1204 Bangladesh sms://+447765341890 sms://+880171859159 http://www.ceobangladesh.com http://www.DhakaStockExchangeGame.com http://www.geocities.com/jahan.geo Fred van Engen wrote: Hi, On Fri, Aug 01, 2003 at 04:55:09PM +0200, Lorenzo Rossi wrote: I need to run a query written in a file from inside mysql console, not shell prompt. Anyone can help me? mysql help MySQL commands: Note that all text commands must be first on line and end with ';' help(\h)Display this help. ? (\?)Synonym for `help'. clear (\c)Clear command. connect (\r)Reconnect to the server. Optional arguments are db and host. edit(\e)Edit command with $EDITOR. ego (\G)Send command to mysql server, display result vertically. exit(\q)Exit mysql. Same as quit. go (\g)Send command to mysql server. nopager (\n)Disable pager, print to stdout. notee (\t)Don't write into outfile. pager (\P)Set PAGER [to_pager]. Print the query results via PAGER. print (\p)Print current command. quit(\q)Quit mysql. rehash (\#)Rebuild completion hash. source (\.)Execute a SQL script file. Takes a file name as an argument. status (\s)Get status information from the server. tee (\T)Set outfile [to_outfile]. Append everything into given outfile. use (\u)Use another database. Takes database name as argument. Connection id: 171359 (Can be used with mysqladmin kill) mysql So it looks like you could try the 'source' command. Copying the query through your clipboard is another option. Regards, Fred. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Running mysql (complete newbie)
The permissions should be as follows: /usr/local/mysql/data/ mysql owner 600 is no problem if the linux.err does not exist create one touch linux.err now u can try. I hope it helps. -- Aftab Jahan Subedar Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 81/1-A North Jatrbari Dhaka 1204 Bangladesh sms://+447765341890 sms://+880171859159 http://www.ceobangladesh.com http://www.DhakaStockExchangeGame.com http://www.geocities.com/jahan.geo / Peter Bradley wrote: Hi again Mike, thanks for your help, but no luck there either. the permissions are 755 with mysql as owner and daemon as group cheers Peter On Wed, 2003-07-30 at 18:52, O'K Web Design wrote: Hi Peter It might not be the /tmp directory. This is taken from your original post. I did check to see if mysqld was running, but of course it wasn't. I also tried the perl script run-all-tests, but it just reported mysql wasn't running ('Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' when connecting to DBI:mysql:database=test;host=test;host=localhost with user: '' password: '') You might want to check the permissions on the /var/lib/mysql directory as well. Mike - Original Message - From: Peter Bradley [EMAIL PROTECTED] To: O'K Web Design [EMAIL PROTECTED] Sent: July 30, 2003 1:03 AM Subject: Re: Running mysql (complete newbie) Hi Mike, Hmmm. Don't think so. /tmp is drwxrwxrwt Cheers Peter On Wed, 2003-07-30 at 18:43, O'K Web Design wrote: Hi Peter It sounds like you have a directory permission problem. I had one just this week. Just make sure that mysql can write to /tmp. Mike - Original Message - From: Peter Bradley [EMAIL PROTECTED] To: msql general mailing list [EMAIL PROTECTED] Sent: July 30, 2003 12:50 AM Subject: Running mysql (complete newbie) Hi guys and gals, I'm a complete newbie to mysql, so please bear with me. Today I downloaded mysql4.0 binary distribution and installed it on my SuSE Linux 8.1 box. I've unzipped it and put it in: /usr/local/mysql-standard-4.0.14-pc-linux-i686 and I've created a symbolic link to give me /usr/local/mysql I then ran scripts/mysql_install_db (as root). The output was: = | |linux:/usr/local/mysql # ./scripts/mysql_install_db |Installing all prepared tables |030730 4:24:13 ./bin/mysqld: Shutdown Complete | | |To start mysqld at boot time you have to copy |support-files/mysql.server |to the right place for your system | |PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! |This is done with: |./bin/mysqladmin -u root password 'new-password' |./bin/mysqladmin -u root -h linux password 'new-password' |See the manual for more instructions. | |NOTE: If you are upgrading from a MySQL = 3.22.10 you should run |the ./bin/mysql_fix_privilege_tables. Otherwise you will not be |able to use the new GRANT command! | |You can start the MySQL daemon with: |cd . ; ./bin/mysqld_safe | |You can test the MySQL daemon with the benchmarks in the 'sql-bench' |directory: |cd sql-bench ; perl run-all-tests | |Please report any problems with the ./bin/mysqlbug script! | |The latest information about MySQL is available on the web at |http://www.mysql.com |Support MySQL by buying support/licenses at https://order.mysql.com | |linux:/usr/local/mysql # | === I then tried to start mysql as a normal user and got: | |[EMAIL PROTECTED]:/usr/local/mysql bin/safe_mysqld --log |[1] 2693 |[EMAIL PROTECTED]:/usr/local/mysql Starting mysqld daemon with databases |from /usr/local/mysql/data |bin/safe_mysqld: line 296: /usr/local/mysql/data/linux.err: Permission |denied |rm: cannot remove `/tmp/mysql.sock': Operation not permitted |bin/safe_mysqld: line 1: /usr/local/mysql/data/linux.err: Permission |denied |tee: /usr/local/mysql/data/linux.err: Permission denied |030730 04:27:40 mysqld ended |tee: /usr/local/mysql/data/linux.err: Permission denied | |== So I tried as root and got: | |linux:/usr/local/mysql # ./bin/safe_mysqld --log |[1] 2740 |linux:/usr/local/mysql # Starting mysqld daemon with databases from |/usr/local/mysql/data |030730 04:30:05 mysqld ended | I did check to see if mysqld was running, but of course it wasn't. I also tried the perl script run-all-tests, but it just reported mysql wasn't running ('Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' when connecting to DBI:mysql:database=test;host=test;host=localhost with user: '' password: '') Can anyone help? Thanks Peter -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http
Re: Crash on mysql_real_connect on FreeBSD 4.7
Hi, has your problem solved ? Would u post the code here ? Matt Davies wrote: Thank you for your direction. I posted on both lists under the hope that I could find someone out there with experience using the API - whether the C api or the C++ - and who may have encountered a similar problem. I have been googling for days and found mostly stuff related to PHP and MySQL, but very few items regarding the API. So, under good practice of researching the problem first and then turning to the lists for help I am doing that now. Hope someone out there has some insight and may be able to help me. Thanks in advance. --Original Message- -From: Sinisa Milivojevic [mailto:[EMAIL PROTECTED] -Sent: Saturday, July 19, 2003 6:19 AM -To: Matt Davies -Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] -Subject: Re: Crash on mysql_real_connect on FreeBSD 4.7 - - -On Fri, 18 Jul 2003 14:22:13 -0600 -Matt Davies [EMAIL PROTECTED] wrote: - - - Hey all, - - Have a very peculiar problem. First off - - - OS: FreeBSD 4.7 - MySQL version: Ver 12.20 Distrib 4.0.13, for unknown-freebsd4.7 (i386) - (I have also compiled 3.23.53) - - The problem: - I have written a class that connects to and disconnects from the - database. Everything works fine when I instantiate this class in another - class to do some work, but when that class instantiates yet another - class then it seems as though mysql_real_connect bombs, and I have a - core file. - - -This list is dedicated to MySQL++ API and you do not seem to be -using that one. - -Etiher write to [EMAIL PROTECTED] or use debugger to see what is -wrong with your program. - --- - -Regards, - --- -For technical support contracts, go to https://order.mysql.com/?ref=msmi - __ ___ ___ __ - / |/ /_ __/ __/ __ \/ /Mr. Sinisa Milivojevic [EMAIL PROTECTED] - / /|_/ / // /\ \/ /_/ / /__ MySQL AB -/_/ /_/\_, /___/\___\_\___/ Fulltime Developer and Support Coordinator - ___/ www.mysql.com Larnaca, Cyprus - --- -MySQL++ Mailing List -For list archives: http://lists.mysql.com/plusplus -To unsubscribe: -http://lists.mysql.com/[EMAIL PROTECTED] - -- Aftab Jahan Subedar Software Engineer Subedar Technologies Subedar Baag Bibir Bagicha #1 81/1-A North Jatrbari Dhaka 1204 Bangladesh sms://+447765341890 sms://+880171859159 http://www.ceobangladesh.com http://www.DhakaStockExchangeGame.com http://www.geocities.com/jahan.geo -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: mysql.sock
Probably it did not start at all. check if it started. ps -ax|grep mysql John Nichel wrote: Oliver Etzel - GoodnGo.COM (R) wrote: Hello all, after Installing mysql I started the mysql daemon.. The I tried to log in to my mysql database and got the message could not find mysql.sock in /tmp. In the mysql-configuration file /etc/my.cnf (in my redhat system 8.0) I changed the place for the socket file from socket=/var/lib/mysql/mysql.sock to socket=/tmp/mysql.sock. That doesnt work. What can I do? Perhaps put a link ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock in /tmp Oliver When you look in /tmp, is mysql.sock there? Is it somewhere else on your system (# find / -name mysql.sock)? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]