Hi Evgeny,
You don't need to use || to join each line. whatever is there in ' ' single quotes are considered as a single string, even if your query is in multiple lines.
use '' (2 single quotes) around constant to escape single quote or you can also define scalar variable for these constants.
execute immediate
'SELECT
"DocEntry",
"DocNum",
''N'' AS "Canceled",
''O'' AS "DataSource",
"CreateDate",
"CreateTS",
''N'' AS "Handwrtten",
''0'' As "Instance",
NULL AS "LogInst",
' || :ObjectType || ' AS "Object",
"FinncPriod" AS "Period",
''0'' AS "Series",
''O'' AS "Status",
''1'' AS "UserSign",
''N'' AS "Transfered",
"CardCode",
"CardName",
"Comments",
"DocDate",
"DocDueDate",
"TaxDate",
"GroupNum",
"NumAtCard",
"U_DispatchDate",
"U_RusDeliveryDate",
"U_UrgencyOfPO",
"DocCur",
"DocRate",
"DocTotal",
"DocTotalFC",
(SELECT "SlpName" FROM ' || :DB1 || '.OSLP AS OSLP Where OSLP."SlpCode" = OPOR."SlpCode"),
"AtcEntry"
FROM ' || :DB2 || '.OPOR AS OPOR
WHERE OPOR."CardCode" = ' || :CardCode || '
AND "DocEntry" NOT IN (SELECT "DocEntry" FROM ' || :DB1 || '.OPOR) ' ;