We investigate the presence of complex organic molecules ( COMs ) in strongly UV-irradiated interstellar molecular gas . We have carried out a complete millimetre ( mm ) line survey using the IRAM 30 m telescope towards the edge of the Orion Bar photodissociation region ( PDR ) , close to the H _ { 2 } dissociation front , a position irradiated by a very intense far-UV ( FUV ) radiation field . These observations have been complemented with 8.5 ^ { \prime \prime } resolution maps of the H _ { 2 } CO J _ { K _ { a } ,K _ { c } } = 5 _ { 1 , 5 } \rightarrow 4 _ { 1 , 4 } and C ^ { 18 } O J = 3 \rightarrow 2 emission at 0.9 mm . Despite being a harsh environment , we detect more than 250 lines from COMs and related precursors : H _ { 2 } CO , CH _ { 3 } OH , HCO , H _ { 2 } CCO , CH _ { 3 } CHO , H _ { 2 } CS , HCOOH , CH _ { 3 } CN , CH _ { 2 } NH , HNCO , H _ { 2 } ^ { 13 } CO , and HC _ { 3 } N ( in decreasing order of abundance ) . For each species , the large number of detected lines allowed us to accurately constrain their rotational temperatures ( T _ { rot } ) and column densities ( N ) . Owing to subthermal excitation and intricate spectroscopy of some COMs ( symmetric- and asymmetric-top molecules such as CH _ { 3 } CN and H _ { 2 } CO , respectively ) , a correct determination of N and T _ { rot } requires building rotational population diagrams of their rotational ladders separately . The inferred column densities are in the 10 ^ { 11 } - 10 ^ { 13 } cm ^ { -2 } range . We also provide accurate upper limit abundances for chemically related molecules that might have been expected , but are not conclusively detected at the edge of the PDR ( HDCO , CH _ { 3 } O , CH _ { 3 } NC , CH _ { 3 } CCH , CH _ { 3 } OCH _ { 3 } , HCOOCH _ { 3 } , CH _ { 3 } CH _ { 2 } OH , CH _ { 3 } CH _ { 2 } CN , and CH _ { 2 } CHCN ) . A non-thermodynamic equilibrium excitation analysis for molecules with known collisional rate coefficients suggests that some COMs arise from different PDR layers but we can not resolve them spatially . In particular , H _ { 2 } CO and CH _ { 3 } CN survive in the extended gas directly exposed to the strong FUV flux ( T _ { k } = 150 - 250 K and T _ { d } \gtrsim 60 K ) , whereas CH _ { 3 } OH only arises from denser and cooler gas clumps in the more shielded PDR interior ( T _ { k } = 40 - 50 K ) . The non-detection of HDCO towards the PDR edge is consistent with the minor role of pure gas-phase deuteration at very high temperatures . We find a HCO/H _ { 2 } CO/CH _ { 3 } OH \simeq 1/5/3 abundance ratio . These ratios are different from those inferred in hot cores and shocks . Taking into account the elevated gas and dust temperatures at the edge of the Bar ( mostly mantle-free grains ) , we suggest the following scenarios for the formation of COMs : ( i ) hot gas-phase reactions not included in current models ; ( ii ) warm grain-surface chemistry ; or ( iii ) the PDR dynamics is such that COMs or precursors formed in cold icy grains deeper inside the molecular cloud desorb and advect into the PDR .