Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: continuously query

by bigup401 (Pilgrim)
on Dec 21, 2020 at 23:07 UTC ( [id://11125586]=note: print w/replies, xml ) Need Help??


in reply to Re: continuously query
in thread continuously query

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: continuously query
by NetWallah (Canon) on Dec 22, 2020 at 03:54 UTC
    There are a few issues with your post:
    • It would help if you provide SHORT, RUNNBLE CODE that demonstrates the issue
    • It would help if code were indented properly - that would allow others to see loop boundaries
    • You have misunderstood how to process the return value from fetchall_arrayref
    • You have a syntax error in "while ( $status eq 'PAID') ) {"
    • Your "redo" will not work the way you seem to expect
    Please try to understand and use standard perl "idioms" - they help make code more understandable and avoid bugs.

    Here is an idiomatic flow for your case:

    my $query = $dbh->prepare("SELECT ordernumber FROM orders ORDER BY cre +ated ASC"); $query->execute(); ####### FUNCATION (A) while( my $row = $query->fetchrow_arrayref() ) { my $ordernumber = $row->[0]; # First, and only field in returned +list # WHEN I PRINT THE OUTPUT IS # 545455 # 745454 # 645450 # NOW I WANT TO CHECK EACH ORDER NUMBER VIA LINK # ITS LIKE I WANT TO RUN HTTP REQUEST FOR EACH ORDER NUMBER my $url = "LINK/$ordernumber"; print "URL: $url\n"; my $req = HTTP::Request->new(GET=>$url); my $resp = $ua->request($req); my $response = JSON::XS->new->decode ($resp->content); my $status = $response->{status}; # WHILE WE GET ORDER NUMBER WITH MATCHING RESLUTS while ( $status eq 'PAID') { #// DO STAFFS HERE #// WHEN DONE THEN KEEP CHECKING OTHER ORDER NUMBER USING REDO } #no redo; # REDO FUNCATION (A) AFTER SUCCESS - ITS LIKE RESTART T +HE WHOLE FUNCATION AGAIN # BEACUSE AFTER SUCCESS, I HAVE TO KEEP ALSO CHECKING REAMI +NING ORDER NUMBER STATUES } $dbh->disconnect();

                    "Imaginary friends are a sign of a mental disorder if they cause distress, including antisocial behavior. Religion frequently meets that description"

      thank you

Re^3: continuously query
by Marshall (Canon) on Dec 21, 2020 at 23:55 UTC
    This looks like total bullshit.

    Your DB looks like:

    userid ordernumber status created 1 455678 PAID 2020-12-31 23:59:59 2 344666 NOTPAID 2020-12-08 23:59:59 3 788997 PAID 2020-12-01 23:59:59
    Show us the code that prints that SQL DB table.
    ADDED: Show how you get the status for the order number?

    You need to learn Perl, SQL and web page lingo and that combination is not working. Start one step at a time.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125586]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2024-04-25 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found