SP w/ Dynamic SQL Works, Sometimes

  • homebrew01 (7/22/2016)


    Thanks for the replies. I know the SP is hitting the correct database, because it completes 1 of the inserts correctly, but just "stops" at the next one.

    All I can think is there's some condition, like a timeout setting or something in PHP causing it to fail. But when I run it from SQL Mgt studio, it only takes 30 seconds, nothing extreme. (I am a PHP dummy)

    I don't think there are any problems with data or parameters. I trap the SQL syntax for the step that it should run, and if I run it manually it works.

    Also, I have a trace set up to capture the call of the stored procedure from PHP. If I copy-paste the trace data that calls the SP into a QRY window and run it, with the same login as PHP is using, it works perfectly. Here's the command found in the trace file, and it works perfectly.

    -- From SQL Trace. Works perfectly in a QRY window

    EXEC usp_JobMatch_ListTransfer

    @Job_ID=454185,@Recruiter_MemID=2829026,

    @List_Name_New='GD 721 454',

    @CheckFUNC='Y',@CheckIND='N',@CheckLOC='N',

    @SearchString=' (JOB_Title_posDesc_Comb like %regional%) ',

    @State='CA,FL,IL,IN'

    I don't know anything about PHP specifically, but connection strings from applications usually specify a timeout period or if it is not specified have a default timeout period. SSMS however will run a query for as long as it takes to complete. Check the connection string to see if that could be the cause if it not completing from the web but working in SSMS.

  • Ahem...

    Luis Cazares (7/22/2016)


    Have you tried printing the statements before executing them? Maybe a null is giving you problems.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares (7/22/2016)


    Ahem...

    Luis Cazares (7/22/2016)


    Have you tried printing the statements before executing them? Maybe a null is giving you problems.

    Yes, I mentioned that running the exact code in a SQL window, or the entire stored procedure with the same parameters works fine. Only "stops" when called through PHP.

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply