/*
<Params>
CompanyID=ftinteger
LeadType=ftinteger
Description=ftString
TargetDate=ftdatetime
Notes=ftString
</Params>
*/


INSERT INTO crmLeads
(
  xCompany,
  xLeadType,
  xLeadSource,
  Description,
  TargetDate,
  CreatedBy,
  Notes,
  ModifiedBy,
  xHandler,
  Site,
)
VALUES
(
 CAST(:CompanyID AS INTEGER),
 CAST(:LeadType AS INTEGER),
 1,
 :Description,
 CAST(:TargetDate AS DATE),
 1,
 :Notes,
 1,
 1,
);

DECLARE LeadID INTEGER;
SET LeadID = (SELECT LASTAUTOINC FROM #Dummy);

SELECT * FROM crmLeads WHERE Idx=LeadID;
