title: Application Engine Peoplecode bind variables
body: <p>I have the below PeopleCode step in an Application Engine program that reads a CSV file using a File Layout and then inserts the data into a table, and I am just trying to get a better understanding of how the the line of code (<code>&amp;SQL1 = CreateSQL("%Insert(:1)");</code>) in the below script gets generated. It looks like the CreateSQL is using a bind variable (:1) inside the Insert statement, but I am struggling as where to find where this variable is defined in the program. </p>
  
  <pre><code>Function EditRecord(&amp;REC As Record) Returns boolean;
     Local integer &amp;E;
  
     &amp;REC.ExecuteEdits(%Edit_Required + %Edit_DateRange + %Edit_YesNo + %Edit_OneZero);
     If &amp;REC.IsEditError Then
        For &amp;E = 1 To &amp;REC.FieldCount
           &amp;MYFIELD = &amp;REC.GetField(&amp;E);
           If &amp;MYFIELD.EditError Then
              &amp;MSGNUM = &amp;MYFIELD.MessageNumber;
              &amp;MSGSET = &amp;MYFIELD.MessageSetNumber;
              &amp;LOGFILE.WriteLine("****Record:" | &amp;REC.Name | ", Field:" | &amp;MYFIELD.Name);
              &amp;LOGFILE.WriteLine("****" | MsgGet(&amp;MSGSET, &amp;MSGNUM, ""));
           End-If;
        End-For;
        Return False;
     Else
        Return True;
     End-If;
  End-Function;
  
  Function ImportSegment(&amp;RS2 As Rowset, &amp;RSParent As Rowset)
     Local Rowset &amp;RS1, &amp;RSP;
     Local string &amp;RecordName;
     Local Record &amp;REC2, &amp;RECP;
     Local SQL &amp;SQL1;
     Local integer &amp;I, &amp;L;
     &amp;SQL1 = CreateSQL("%Insert(:1)");
     rem &amp;SQL1 = CreateSQL("%Insert(:1) Order by COUNT_ORDER");
     &amp;RecordName = "RECORD." | &amp;RS2.DBRecordName;
     &amp;REC2 = CreateRecord(@(&amp;RecordName));
     &amp;RECP = &amp;RSParent(1).GetRecord(@(&amp;RecordName));
     For &amp;I = 1 To &amp;RS2.ActiveRowCount
        &amp;RS2(&amp;I).GetRecord(1).CopyFieldsTo(&amp;REC2);
        If (EditRecord(&amp;REC2)) Then
           &amp;SQL1.Execute(&amp;REC2);
           &amp;RS2(&amp;I).GetRecord(1).CopyFieldsTo(&amp;RECP);
           For &amp;L = 1 To &amp;RS2.GetRow(&amp;I).ChildCount
              &amp;RS1 = &amp;RS2.GetRow(&amp;I).GetRowset(&amp;L);
              If (&amp;RS1 &lt;&gt; Null) Then
                 &amp;RSP = &amp;RSParent.GetRow(1).GetRowset(&amp;L);
                 ImportSegment(&amp;RS1, &amp;RSP);
              End-If;
           End-For;
           If &amp;RSParent.ActiveRowCount &gt; 0 Then
              &amp;RSParent.DeleteRow(1);
           End-If;
        Else
           &amp;LOGFILE.WriteRowset(&amp;RS);
           &amp;LOGFILE.WriteLine("****Correct error in this record and delete all error messages");
           &amp;LOGFILE.WriteRecord(&amp;REC2);
           For &amp;L = 1 To &amp;RS2.GetRow(&amp;I).ChildCount
              &amp;RS1 = &amp;RS2.GetRow(&amp;I).GetRowset(&amp;L);
              If (&amp;RS1 &lt;&gt; Null) Then
                 &amp;LOGFILE.WriteRowset(&amp;RS1);
              End-If;
           End-For;
        End-If;
     End-For;
  End-Function;
  
  rem *****************************************************************;
  rem * PeopleCode to Import Data                                     *;
  rem *****************************************************************;
  Local File &amp;FILE1, &amp;FILE3;
  Local Record &amp;REC1;
  Local SQL &amp;SQL1;
  Local Rowset &amp;RS1, &amp;RS2;
  Local integer &amp;M;
  
  &amp;FILE1 = GetFile("\\nt115\apps\interface_prod\interface_in\Item_Loader\ItemPriceFile.csv", "r", "a", %FilePath_Absolute);
  &amp;LOGFILE = GetFile("\\nt115\apps\interface_prod\interface_in\Item_Loader\ItemPriceFile.txt", "r", "a", %FilePath_Absolute);
  
  &amp;FILE1.SetFileLayout(FileLayout.GH_ITM_PR_UPDT);
  &amp;LOGFILE.SetFileLayout(FileLayout.GH_ITM_PR_UPDT); 
  &amp;RS1 = &amp;FILE1.CreateRowset();
  &amp;RS = CreateRowset(Record.GH_ITM_PR_UPDT);
  REM &amp;SQL1 = CreateSQL("%Insert(:1)");
  &amp;SQL1 = CreateSQL("%Insert(:1)");
  /*Skip Header Row:  The following line of code reads the first line in the file layout (the header) 
  and does nothing.  Then the pointer goes to the next line in the file and starts using the 
  file.readrowset*/
  &amp;some_boolean = &amp;FILE1.ReadLine(&amp;string);
  &amp;RS1 = &amp;FILE1.ReadRowset();
  
  While &amp;RS1 &lt;&gt; Null
     ImportSegment(&amp;RS1, &amp;RS);
     &amp;RS1 = &amp;FILE1.ReadRowset();
  End-While;
  
  &amp;FILE1.Close();
  &amp;LOGFILE.Close();
  </code></pre>