No announcement yet.

Button Run - INSERT TO double...

  • Filter
  • Time
  • Show
Clear All
new posts

  • Button Run - INSERT TO double...

    Good morning,
    I think it is my first post ...
    My name is Michele from the low Friuli Venezia Giulia - Italy. Passionate about PHP programming and SQL as an alternative hobby ..

    I hope I have looked for good, in the forum, before posting this request, but I had not found anything in my case, otherwise I apologize right now.

    I'm posting this request because I can not understand, and to find a solution about this problem:

    in a grid which extracts the data in a MySQL table "table2" I added a run button as indicated here.

    to copy the records selected through the relevant checkbox, in another table: "table1".

    The configurations in the "table2" are as follows:


    [I] = 0;
    [total_chked] = array();

    On button:



    As Indicate here.

    if(count([total_chked]) > 0)
    $to_copy = "(".implode(',',[total_chked]).")";
    sc_exec_sql("INSERT INTO table1 (idtable1, field1, field3, field4) SELECT Null, field6, field8, field10 FROM table2 WHERE idtable2 IN ".$to_copy);

    Premises to the problem:
    It states that the application runs after a user login and then through the security module created from the "Forms"> "Security" as Type: Application.

    The problem:
    Step 1:
    I run the application, and I select the records you want to copy in "table1" through its checkbox, then I click on the "Run" button and successfully copies the record ...
    Step 2:
    Now, the application remains open and copy other records (for the second time), of course, different from those copied in Step 1.
    The system copies the selected ones selected records and copied in Step 1.

    Ambiguous solutions:

    I have to log out or a macro to redirect (sc_redir) in another application.

    Sincerely "ambiguous" solutions would be a bit annoying and time-consuming for the user, because it just so happens that a user might have forgotten to "copy" other records and insert them immediately after the copy of the background, without leaving by app.

    Some kindly help?

    Thanks in advance!

  • #2
    I would try this,

    this is what i did to selected records in one of my applications then divert to pdf report placed in the on finish. by the sounds of it you just need to redir with parameters.

    $redir_app = 'pdfreport_oem_owner_sales';
    $redir_target = '_blank';
    $redir_param = array('var_id_sale' => join(',',$sale_values));
    sc_redir($redir_app, $redir_param);


    • #3
      Hello scottypaul,
      Thank you for your reply...
      Right now I am preparing lunch ... In the afternoon I try then I answer.
      Thank you!


      • #4
        Ok No problem, let me know how you get on.


        • #5


          • #6
            Today, in the afternoon, where I live, there was a bad storm that took away electricity while turned on the PC. When I restarted, they had disappeared the tables in the MySQL database. I could not believe my eyes! I'm restoring everything and proof of your, scottypaul, possible solution I have to postpone. As soon as I did I write here.
            See you soon. Thanks!


            • #7
              I solved the problem by resetting the array with the following string at the end of PHP code OnFinish on the button:

              [total_chked] = array();

              Thanks so much!


              • #8
                A similar issue:

                I have a header table with detail records. I have a run button of a grid for the header records.
                For the records I select, I want to find all the detail records and insert new records in another detail table.
                Right now it only processes the forst detail record it finds
                EX: HEader record 123 is checked. It has 7 detail records, but only the first is processed, then it goes on to the next checked header record.
                I am new so code will be basic

                {zero} = 0;
                echo {zero};

                $check_sql = "SELECT poid, styleid, colorid, dimid FROM tblPODetail WHERE poid = '{PONumber}' AND type = '{zero}'";
                sc_lookup(rs, $check_sql);
                if (isset({rs[0][0]}))


                {poid} = {rs[0][0]};
                {styleid} = {rs[0][1]};
                {colorid} = {rs[0][2]};
                {dimid} = {rs[0][3]};

                $insert_table = 'rmDetails';
                $insert_fields = array (

                'rmid' => "'105'",
                'poid' => "'{poid}'",
                'styleid' => "'{styleid}'",
                'colorid' => "'{colorid}'", );

                $insert_sql = 'INSERT INTO ' . $insert_table
                . ' (' . implode(', ', array_keys($insert_fields)) . ')'
                . ' VALUES (' . implode(', ', array_values($insert_fields)) . ')';




                {other_field} = '' ;
                {other_region} = '';