Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Extracting Numerous records

by Ombongi.Moraa (Novice)
on Jan 27, 2014 at 10:47 UTC ( #1072208=perlquestion: print w/ replies, xml ) Need Help??
Ombongi.Moraa has asked for the wisdom of the Perl Monks concerning the following question:

1 XXXX A B C

2 AAAA A B C

3 YYYY A B C

4 XXXX A B C

5 XXXX A B C

6 YYYY A B C

My MySQL table will take the above structure; The query the user sends is counterchecked against values in the 2nd column. At times, like the case of identities XXXX and YYYY, there are multiple rows for the identity; All my responses (a response is a merger of cols. 3, 4..) must fit into 160-characters (sms) so only one row can be sent as a reply at a time; However, since there are multiple records of that identity, the user will want to receive all this info.

When the user sends first request with “XXXX”, the first time, I send out a response telling them 3 records were found for that user. They should reply with anything within e.g. 5 minutes, to get the next record.

2nd request (<5mins after 1st request), I send them row1 info; 3rd request, I send back row4 info ... timestamp between two subsequent requests must be at most 5 minutes – I end up creating some kind of a sms session. > 5 mins , “session expires”, they must start all over again.

Please advise on the best way to process request and extract the next record if a request comes in within a session. I hope what I'm trying to achieve has been explained clearly

Comment on Extracting Numerous records
Re: Extracting Numerous records
by FloydATC (Hermit) on Jan 27, 2014 at 13:23 UTC

    I could be way off since I know nothing about the actual application, but here's what I think:

    To keep results consistent for the end user in the face of potential updates to the database between the initial and follow-up requests, I would probably keep a separate table containing the active "sessions" and the query results associated with that session. (Or store them by other means)

    To illustrate:

    1. User searches for "XXXX" which yields 3 hits(1, 4 and 5)
    2. Database record 5 is updated and no longer matches "XXXX"
    3. User requests match no.3, should receive record 5 which would no longer match if the initial query was executed again. He would probably be very confused if that record suddenly wasn't available. ("You just told me there were 3 matches!") Even if this will potentially send outdated info.
    -- FloydATC

    Time flies when you don't know what you're doing

Re: Extracting Numerous records
by TomDLux (Vicar) on Jan 27, 2014 at 15:40 UTC

    I would set up the application / web page so that the first time, it merely sends the query. After that, it asks for the query and record # N.

    That way you don't have to store status for users or interactions, don't have to clean up expired stuff. And does it matter if a query comes 5 minutes and 1 second after a previous one? Or if someone asks for record #2, without ever getting record #1?

    As Occam said: Entia non sunt multiplicanda praeter necessitatem.

Re: Extracting Numerous records
by pvaldes (Chaplain) on Jan 27, 2014 at 16:22 UTC
    Not sure if I'm understanding the idea, but this seems more a question about sql queries or about sending/receiving plain text sms, so I wonder how are you adding perl to this equation. Maybe putting all the needed info in a stream and chunk the stream?. Can we see some code?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1072208]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2014-09-20 01:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls