5 Replies Latest reply on Jul 20, 2007 3:04 PM by Dan Bracuk

    Query after report Print

    rjproc
      I have set up a .cfr report, that open in a blank pdf window. It is possible to set it so that once it is printed an insert query would run??
        • 1. Re: Query after report Print
          Dan Bracuk Level 5
          It would be very difficult considering that printing usually happens on the client and <cfquery> happens on the server.
          • 2. Re: Query after report Print
            rjproc Level 1
            I wasn't sure if it was at all possible knowing that the print is a client activity, so where would I put the <cfquery> to have it run after the report is viewed.

            Thanks
            • 3. Re: Query after report Print
              Level 7
              rjproc wrote:
              > I wasn't sure if it was at all possible knowing that the print is a client activity, so where would I put the <cfquery> to have it run after the report is viewed.
              >
              > Thanks

              I see you have two choices. If user approval is irrelevant, run the
              update after the report is generated, viewed or not. If user approval
              is required, have a form control they activate to send a request to the
              server to do the update.

              • 4. Re: Query after report Print
                rjproc Level 1
                I have tried to run the query like this.
                <cfquery name="QUnprintedPIs" datasource="FleetmaxTitles">
                SELECT
                FROM
                WHERE
                </cfquery>

                <cfloop query="">
                <cfquery name="UpdateInfo" datasource="">
                INSERT INTO
                VALUES(,,)
                </cfquery>
                </cfloop>

                <cfreport format="PDF" template=".cfr"></cfreport>

                This is how it is set up now, the insert is working fine, but since the report is running after the query, it outputs null.

                If I put the report before the query, it runs the reportbut wont run the query.

                Thanks
                • 5. Re: Query after report Print
                  Dan Bracuk Level 5
                  this does not answer your question but it makes your insert more efficient.

                  instead having your query inside a loop, it is usually more efficient to put your loop inside your query. Something like this

                  insert into SomeTable
                  (field1, field2, etc)
                  <cfloop query = "something">
                  select distinct #value1#, #value2#, etc
                  from SomeSmallTable
                  <cfif currentrow lt recordcount>
                  union
                  </cfif>
                  </cfloop>