Sorry,

I keep replying to my own posts, but I keep trying different things to figure 
out the problem.

I ran select for all other columns in the table and I was able to get data, but 
when I run select for MD5Sum column I do not get anything.


I ran .dump command to dump the data to a file, and ran .read command to read 
it into a different database. Now, I could do a select based upon MD5Sum column.

Next I edited the output file and changed the table name. I ran .read and 
loaded the data into new table in original database. Now, I could do a select 
based upon MD5Sum column.

Any idea what could be wrong?



Hemant Shah
E-mail: hj...@yahoo.com


--- On Mon, 9/27/10, Hemant Shah <hj...@yahoo.com> wrote:

> From: Hemant Shah <hj...@yahoo.com>
> Subject: Re: [sqlite] sqlite cannot find the row
> To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org>
> Date: Monday, September 27, 2010, 5:43 PM
> Instead of in-memory database, I
> created database in a file and tried to do select with same
> results.
> 
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.521968|10101|10101|4801345|fd5cb2d226b48d5dd4645d4fe7ca12cf
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.522843|10101|10101|4801345|48cc79ae3c9029c82883843737f98ca1
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.523982|10101|10101|4801345|2522b8b56698cb805170497ebdab5858
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.524920|10101|10101|4801345|4ae983c9b1946dbc905d12333353b71a
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.525914|10101|10101|4801345|7d081eda7db33ea363b6c6655688f08d
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.526910|10101|10101|4801345|105344cb171ecaf81798df75b8d3562e
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.527911|10101|10101|4801345|34ab03b3543b1f0b2ca2f505fc6330f7
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.528910|10101|10101|4801345|8c72bd2c854598f9e817f9d85282aae8
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.529911|10101|10101|4801345|69b5c4d087a270b5b671a1765123ae8b
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.530910|10101|10101|4801345|28c45b4ab9414819bb4c75ff37bf5a7e
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.531911|10101|10101|4801345|2c726e0c63bda2d30e3f9ea38df5ece0
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.532920|10101|10101|4801345|77ac658bcc98321e298cd52d07dcc8d5
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.534031|10101|10101|4801345|0a41725b5b1a183ebf40489f2037f00d
> 
> 1285625918|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.535178|10101|10101|4801345|652575b633b6f4aefe5b6ddb5b085c06
> 
> 1285625919|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.536085|10101|10101|4801345|3a632902e3e07bc7c20e130baf941a33
> 
> 1285625919|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.537085|10101|10101|4801345|5a44897aef3d81d70dee8246d4a7748f
> 
> 1285625919|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.538077|10101|10101|4801345|fd6a9a130a5c3bb46ee0e20bf6f02b52
> 
> 1285625919|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.539090|10101|10101|4801345|2efba1c039c0f41361945a27a3e651cd
> 
> 1285625919|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.37.540077|10101|10101|4801345|1fde5a8f289b299139c26260c75a6df0
> 
> 1285625920|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.40.481153|10101|10101|4801345|6d7fd3d66e0eb709c38440546a9e3a15
> 
> 1285625920|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.40.481746|10101|10101|4801345|f236a2ecf56f038ff132b91ba94287f4
> 
> sqlite>
> 
> sqlite>
> 
> sqlite>
> 
> sqlite> select * from find_retransmissions where
> InsTimeStamp=1285625920;
> 
> 1285625920|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.40.481153|10101|10101|4801345|6d7fd3d66e0eb709c38440546a9e3a15
> 
> 1285625920|10.208.54.32|239.90.91.101|2010-09-27
> 17.18.40.481746|10101|10101|4801345|f236a2ecf56f038ff132b91ba94287f4
> 
> sqlite> select * from find_retransmissions where
> MD5Sum='f236a2ecf56f038ff132b91ba94287f4';
> 
> sqlite>
> 
> select * displays whole table. If I do select using another
> column I get appropriate rows, but if I do select on MD5Sum
> column it returns nothing.
> 
> 
> 
> Hemant Shah
> E-mail: hj...@yahoo.com
> 
> 
> --- On Mon, 9/27/10, Hemant Shah <hj...@yahoo.com>
> wrote:
> 
> > From: Hemant Shah <hj...@yahoo.com>
> > Subject: Re: [sqlite] sqlite cannot find the row
> > To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org>
> > Date: Monday, September 27, 2010, 4:22 PM
> > Sorry about that. No I do not have
> > single quotes around ?.
> > 
> > strcpy(SqlString, "INSERT INTO
> > find_retransmissions(InsTimeStamp, SrcIp, DstIp,
> TimeStamp,
> > SrcP ort, DstPort, SeqNum,  MD5Sum) VALUES
> > (?,?,?,?,?,?,?,?)");
> > 
> > sprintf(SqlString, "SELECT SrcIp, DstIp, TimeStamp,
> > SrcPort, DstPort, SeqNum FROM find_retransmissions
> WHERE
> > MD5Sum = ?");
> > 
> > 
> > I do not have quotes in both statemens, but insert
> > statement works.
> > 
> > 
> > Hemant Shah
> > E-mail: hj...@yahoo.com
> > 
> > 
> > --- On Mon, 9/27/10, Black, Michael (IS) <michael.bla...@ngc.com>
> > wrote:
> > 
> > > From: Black, Michael (IS) <michael.bla...@ngc.com>
> > > Subject: Re: [sqlite] sqlite cannot find the row
> > > To: "General Discussion of SQLite Database"
> <sqlite-users@sqlite.org>
> > > Date: Monday, September 27, 2010, 2:27 PM
> > > Your code is chopped off and I
> > > suspect the problem is on the remainder of this
> line:
> > >  
> > > sprintf(SqlString, "SELECT SrcIp, DstIp,
> TimeStamp,
> > > SrcPort, DstPort, SeqNum
> > > 
> > > For example, did you put single quotes around the
> ?
> > > parameter?
> > >  
> > >  
> > > Michael D. Black
> > > Senior Scientist
> > > Advanced Analytics Directorate
> > > Northrop Grumman Information Systems
> > >  
> > > 
> > > ________________________________
> > > 
> > > From: sqlite-users-boun...@sqlite.org
> > > on behalf of Hemant Shah
> > > Sent: Mon 9/27/2010 2:22 PM
> > > To: General Discussion of SQLite Database
> > > Subject: EXTERNAL:Re: [sqlite] sqlite cannot find
> the
> > row
> > > 
> > > 
> > > 
> > > Here is the snippet of code:
> > > 
> > > int GetMessageFromDB(char *MD5Sum, struct
> ReceiveNode
> > > *FromDb)
> > > {
> > >    int ReturnCode;
> > >    sqlite3_stmt *SelectStmtHandle;
> > > 
> > >    sprintf(SqlString, "SELECT SrcIp, DstIp,
> > > TimeStamp, SrcPort, DstPort, SeqNum
> > >    ReturnCode = sqlite3_prepare(DbHandle,
> > > SqlString, -1, &SelectStmtHandle, NULL
> > >    if (ReturnCode != SQLITE_OK ||
> > > SelectStmtHandle == NULL)
> > >    {
> > >       sqlite3_reset(SelectStmtHandle);
> > >       printf("Cannot prepare select
> > > statement. %s\n", sqlite3_errmsg(DbHandle));
> > >       return(2);
> > >    }
> > > 
> > >    sqlite3_bind_text(SelectStmtHandle, 1,
> > > MD5Sum, strlen(MD5Sum), SQLITE_TRANSIE
> > >    ReturnCode =
> > > sqlite3_step(SelectStmtHandle);
> > >    if (ReturnCode != SQLITE_ROW)
> > >    {
> > >       sqlite3_reset(SelectStmtHandle);
> > >       printf("Row not found. ReturnCode: %d,
> > > Error Message:%s, Error Code: %d\n"
> > >          
> > >    ReturnCode, sqlite3_errmsg(DbHandle),
> > > sqlite3_errcode(DbHandle));
> > >       return(2);
> > >    }
> > > 
> > >    strcpy(FromDb->SourceIP,
> > > sqlite3_column_text(SelectStmtHandle, 0));
> > >    strcpy(FromDb->DestIP,
> > > sqlite3_column_text(SelectStmtHandle, 1));
> > >    strcpy(FromDb->TimeStamp,
> > > sqlite3_column_text(SelectStmtHandle, 2));
> > >    FromDb->SourcePort =
> > > sqlite3_column_int(SelectStmtHandle, 3);
> > >    FromDb->DestPort =
> > > sqlite3_column_int(SelectStmtHandle, 4);
> > >    FromDb->SeqNum =
> > > sqlite3_column_int(SelectStmtHandle, 5);
> > >    strncpy(FromDb->MD5Sum, MD5Sum,
> > > MD5SUMLEN);
> > >    sqlite3_finalize(SelectStmtHandle);
> > >    return(1);
> > > }
> > > 
> > > int GetMessageFromDB(char *MD5Sum, struct
> ReceiveNode
> > > *FromDb)
> > > {
> > >    int ReturnCode;
> > >    sqlite3_stmt *SelectStmtHandle;
> > > 
> > >    sprintf(SqlString, "SELECT SrcIp, DstIp,
> > > TimeStamp, SrcPort, DstPort, SeqNum
> > >    ReturnCode = sqlite3_prepare(DbHandle,
> > > SqlString, -1, &SelectStmtHandle, NULL
> > >    if (ReturnCode != SQLITE_OK ||
> > > SelectStmtHandle == NULL)
> > >    {
> > >       sqlite3_reset(SelectStmtHandle);
> > >       printf("Cannot prepare select
> > > statement. %s\n", sqlite3_errmsg(DbHandle));
> > >       return(2);
> > >    }
> > > 
> > >    sqlite3_bind_text(SelectStmtHandle, 1,
> > > MD5Sum, strlen(MD5Sum), SQLITE_TRANSIE
> > >    ReturnCode =
> > > sqlite3_step(SelectStmtHandle);
> > >    if (ReturnCode != SQLITE_ROW)
> > >    {
> > >       sqlite3_reset(SelectStmtHandle);
> > >       printf("Row not found. ReturnCode: %d,
> > > Error Message:%s, Error Code: %d\n"
> > >          
> > >    ReturnCode, sqlite3_errmsg(DbHandle),
> > > sqlite3_errcode(DbHandle));
> > >       return(2);
> > >    }
> > > 
> > >    strcpy(FromDb->SourceIP,
> > > sqlite3_column_text(SelectStmtHandle, 0));
> > >    strcpy(FromDb->DestIP,
> > > sqlite3_column_text(SelectStmtHandle, 1));
> > >    strcpy(FromDb->TimeStamp,
> > > sqlite3_column_text(SelectStmtHandle, 2));
> > >    FromDb->SourcePort =
> > > sqlite3_column_int(SelectStmtHandle, 3);
> > >    FromDb->DestPort =
> > > sqlite3_column_int(SelectStmtHandle, 4);
> > >    FromDb->SeqNum =
> > > sqlite3_column_int(SelectStmtHandle, 5);
> > >    strncpy(FromDb->MD5Sum, MD5Sum,
> > > MD5SUMLEN);
> > >    sqlite3_finalize(SelectStmtHandle);
> > >    return(1);
> > > }
> > > 
> > > if (FindDuplicateMessage(ReceiveBuf) == 1)
> > > {
> > >     GetMessageFromDB(ReceiveBuf.MD5Sum,
> > > &FromDb);
> > > }
> > > 
> > > 
> > > 
> > > When I execute this functions I get following
> output.
> > > 
> > > 
> > > Cannot insert into database. column MD5Sum is
> not
> > unique
> > > error code = SQLITE_CONSTRAINT
> > > Row not found. ReturnCode: 101, Error Message:not
> an
> > error,
> > > Error Code: 0
> > > 
> > > 
> > > 101 is SQLITE_DONE. So I get SQLITE_DONE instead
> of
> > > SQLITE_ROW.
> > > 
> > > 
> > > 
> > > Hemant Shah
> > > E-mail: hj...@yahoo.com
> > > 
> > > 
> > > 
> > > 
> > > 
> > > -----Inline Attachment Follows-----
> > > 
> > > _______________________________________________
> > > sqlite-users mailing list
> > > sqlite-users@sqlite.org
> > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> > > 
> > 
> > 
> >       
> > _______________________________________________
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> > 
> 
> 
>       
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 


      
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to