dynamic soql escape the single quote code example
Example: dynamic soql escape the single quote
'SELECT payout__Account_Desc__c FROM payout__ImportStaging__c where payout__BD_Id__c = \'' + String.escapeSingleQuotes(bdId) + '\' AND payout__Processed_Flag__c <> \'' + String.escapeSingleQuotes('Y') + '\'');