380960 (6) [Avatar] Offline
#1
I'm running PostgreSQL 9.5 on Windwos 10

This is the list 16.7


CREATE OR REPLACE FUNCTION ch16.write_bin_file(
param_bytes bytea,
param_filename text
)
RETURNS text AS
$$
f = open('C:/temp/' + param_filename, 'wb+') -- <co id="co_code_plpython_write_bin_file_1"/>
f.write(param_bytes) -- <co id="co_code_plpython_write_bin_file_2"/>
f.close()
return param_filename -- <co id="co_code_plpython_write_bin_file_3"/>
$$ LANGUAGE plpython3u IMMUTABLE;

I Get this error:

ERROR: could not compile PL/Python function "write_bin_file"
DETAIL: SyntaxError: invalid syntax (<string>, line 3)

********** Error **********

ERROR: could not compile PL/Python function "write_bin_file"
SQL state: 38000
Detail: SyntaxError: invalid syntax (<string>, line 3)
regina.leo (257) [Avatar] Offline
#2
I think the cue ball markup stuff got in the way.

Try changing the -- to # or just get rid of those -- <co things entirely

I'll update the source code to not have that get in the way.