I have move from anydac to pgdac, and I have one issue with byteA field.
I request directly from SQL queries, I don't use tfields.
the following code doesn't work, is it exists a similar function like "pg_escape_bytea" ?:
Code: Select all
function EncodeBYTEA(Value: ansistring): ansistring;
var encoded:pansichar;
len:integer;
leng:cardinal;
begin
leng:=Length(Value);
encoded:=PQEscapeByteaConn(TNativeConnect(dbcnx.Handle).Handle,pansichar(value),leng,len);
setlength(result,len-1);
StrCopy(pansichar(result),encoded);
PQFreemem(encoded);
result:=''''+result+'''';
end;
function DecodeBYTEA(value: ansistring): ansistring;
var decoded:pansichar;
len:integer;
begin
decoded:=PQUnescapeBytea(pansichar(value),len);
SetLength(result,len);
if (len > 0) then Move(decoded^,result[1],len);
PQFreemem(decoded);
end;
I just want escape/unescape byteA field in string.
If somebody have an idea?
Cheers
Dams