Hi guys,
need ur help regarding the above matter. I've write a code for if statement but it didnt work as expected when I run the program. Below is my code:
// Get ChannelID
strcpy(src, row[11]);
if (strcmp (src, "1") == 0)
{
if (sprintf(query2, "select * from Register where MasterAccNo = 'NONE'") == 0);
{
strcpy (src, "2P_SMS_RegisteredXPax");
strcpy(src2, src);
printf ("%s\n",src2);
sprintf(string2,"%s|%s|%s|%s|%s,%s|%s,%s|%s|%s|%s|||||%s|",
row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], var2, newDate, src2);
sprintf(mobileno,"%s", row[0]);
printf ("%s\n",string2);
writeLogFile(string2, mobileno);
//i++;
}
if (sprintf(query3, "select * from Register where substring(MasterNumber,2,1) = '1' and MasterAccNo <> 'NONE'") == 0);
{
strcpy (src, "2P_SMS_PostpaidAccount");
strcpy(src3, src);
printf ("%s\n",src3);
sprintf(string3,"%s|%s|%s|%s|%s,%s|%s,%s|%s|%s|%s|||||%s|",
row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], var2, newDate, src3);
sprintf(mobileno,"%s", row[0]);
printf ("%s\n",string3);
writeLogFile(string3, mobileno);
//i++;
}
//else
if (sprintf(query4, "select * from Register where substring(MasterNumber,2,1) <> '1' and MasterAccNo <> 'NONE'") == 0);
{
strcpy (src, "2P_SMS_TM");
strcpy(src4, src);
printf ("%s\n",src4);
sprintf(string4,"%s|%s|%s|%s|%s,%s|%s,%s|%s|%s|%s|||||%s|",
row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], var2, newDate, src4);
sprintf(mobileno,"%s", row[0]);
printf ("%s\n",string4);
writeLogFile(string4, mobileno);
//i++;
}
}
i++;
When I run this program, it executes all three conditions. Supposedly, only 1 condition/query matched and will be executed and then write into a file but then, in this case, all three queries executed caused 3 same data written into a file.
The result written in the file when I run this program is:
0135767903|WONG HWA HUONG|49022811355468||4A, LRG MERDEKA 2,96000 SIBU|,|96000|MALAYSIA|30-11-2006|||||2P_SMS_RegisteredXPax|
0135767903|WONG HWA HUONG|49022811355468||4A, LRG MERDEKA 2,96000 SIBU|,|96000|MALAYSIA|30-11-2006|||||2P_SMS_PostpaidAccount|
0135767903|WONG HWA HUONG|49022811355468||4A, LRG MERDEKA 2,96000 SIBU|,|96000|MALAYSIA|30-11-2006|||||2P_SMS_TM|
supposedly this account will be 2P_SMS_TM
Any help?
Many thanks