Don't say it, first on the code.
Pg:
--Establishment of T1 tableCREATE TABLE Public. T1 (F1INTEGER not NULL, F2VARCHAR( -), F3VARCHAR( -)[][] [], CONSTRAINTT1_pkeyPRIMARY KEY(F1)) with(OIDs=false);--Create an array of T1 table behavior elements to replace RefcursorCREATE OR REPLACE FUNCTION Public. FUN1 (P1 Public. t1[])RETURNS varchar [] [] as$body $DECLARERow1 Public. t1%RowType; ARR1VARCHAR [ ];BEGINFOREACH Row1incharray P1 loop arr1:=array_append (ARR1,ROW1.F2); EndLOOP; RETURNarr1;END; $body $language'Plpgsql'
Delphi:
//The table field is passed to the string in the array structure of the PG, of course, you can select the field to pass, not the fields, directly add a "," on the line.functionDataserecordtoarraystring (Acds:tdataset):string;varI:integer; Srecord:string;begin forI: =0 toAcds.fieldcount-1 Do begin ifAcds.fields[i]. IsNull ThenResult:= Result +',' Else beginSrecord:=Acds.fields[i]. asstring; ifAcds.fields[i]. DataTypeinch[Ftblob, Ftobject, Ftdataset, Ftgraphic] ThenResult:= Result +','+SrecordElse begin
Handles escape characters If normal text can be commented out to speed up
ifSrecord.contains('"') ThenSrecord:= Srecord.replace ('"','\"\"', [Rfreplaceall]); ifSrecord.indexofany ([',',' ','{','"']) >=0 ThenSrecord:='\"'+ Srecord +'\"'; Result:= Result +','+Srecord; End; End; End; Result:='{"('+ result.substring (1) +')"}';End;//TestprocedureTform1.button1click (sender:tobject);vars, s1, S2:string;beginUniQuery1.SQL.Text:='SELECT * from T1'; Uniquery1.open; Uniquery1.first; S:=dataserecordtoarraystring (UniQuery1); Uniquery1.next; S1:=dataserecordtoarraystring (UniQuery1); Uniquery1.next; S2:=dataserecordtoarraystring (UniQuery1); withUniStoredProc1 Do beginClose; Parambyname ('P1'). Asstring: = Format ('{%s,%s,%s}', [S, S1, S2]); TryExecproc; exceptOn e:exception Do beginShowMessage (e.message); Exit; End; End; ShowMessage (fields[0]. asstring); End;End;
Solve the problem that UNIDAC cannot pass cursor refcursor to PostgreSQL in disguise