SYNTAX ERROR MYSQL (confirmed from manual)
Posted by: rgte rerh
Date: June 21, 2013 04:23AM

int main (){
long int r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13; //random no. for KSEQ k2 k4 k5 k10.. AND SIMILARLY.....
char filename[] = "myfile.txt";
FILE *pFile;
int count=0;
long int i;

if (mysql_query(con, "CREATE TABLE BENCH(KSEQ INT, K500K INT, K250K INT, K100K INT, K40K INT, K10K INT, K1K INT, K100 INT, K25 INT, K10 INT, K5 INT, K4 INT, K2 INT, s1 TEXT,s2 TEXT)")) {
finish_with_error(con);
}

pFile = fopen ("myfile.txt","w");

i=1;
while (i<1001){

r1=i;
r2 = rand() %(2) + 1;
r3 = rand() %(4) + 1;
r4 = rand() %(5) + 1;
r5 = rand() %(10) + 1;
r6 = rand() %(25) + 1;
r7 = rand() %(100) + 1;
r8= rand() %(1000) + 1;
r9= rand() %(10000) + 1;
r10 = rand() %(40000) + 1;
r11 = rand() %(100000) + 1;
r12 = rand() %(250000) + 1;
r13 = rand() %(500000) + 1;

fprintf (pFile, "INSERT INTO BENCH VALUES(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,'adsdgaig','adsgaigHFDHDH')\n" , r1,r13,r12,r11,r10,r9,r8,r7,r6,r5,r4,r3,r2);
i++;}


fclose (pFile);


FILE *file = fopen ( filename, "r" );

if (file != NULL)
{
char buffer[100]; // to store all the lines
i=0;

//PASSING BUFFER AS AN INSERT QUERY
while (fgets(buffer,100,file) != '\0'){ //READS LINE BY LINE
if (mysql_query(con,buffer)){
finish_with_error(con);
}
}

mysql_close(con);}

system("Pause");
return 0;

}

END OF CODE.



IN the line corresponding to insertion of values , i.e:

fprintf (pFile,"INSERT INTO BENCH VALUES(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld, %ld,%ld,%ld,%ld,%ld,'adsdgaig','adsgaigFDHDIO')\n", r1,r13,r12,r11,r10,r9,r8,r7,r6,r5,r4,r3,r2);

If i change adsgaigFDHDIO as adsdgaig then the compiler is not showing any error but in the above case it does show syntax error.

I tried changing type from TEXT to VARCHAR but nothing happens.



Edited 3 time(s). Last edit at 06/21/2013 04:28AM by rgte rerh.

Options: ReplyQuote


Subject
Views
Written By
Posted
SYNTAX ERROR MYSQL (confirmed from manual)
2952
June 21, 2013 04:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.