Delphi XE2 (WIDEMEMO)
Posted: 23.12.2013, 16:00
Hello.
I have this SQL function in postgresql-9.3.2-1-windows-x64:
When I run from pgAdmin Query window, I get:
Now, open Delphi XE2, create new VLC Forms Application. Place ZConnection1, ZQuery1, DataSource1 and DBEdit1 components on Form1.
Add this code in OnFormCreate event:
When application runs, you will see (WIDEMEMO) in DBEdit1. You can try adding
And yet result will be the same. What am I missing?
Windows 7 x64, ZEOSDBO-7.1.2-stable, Delphi XE2.
I have this SQL function in postgresql-9.3.2-1-windows-x64:
Code: Select all
CREATE OR REPLACE FUNCTION fnk_create_table(prm_name varchar, prm_surname varchar)
RETURNS TABLE(clm_name varchar(3), clm_surname varchar(6)) AS
$BODY$
BEGIN
RETURN QUERY select CAST(prm_name AS varchar(3)) as clm_name, CAST(prm_surname as varchar(6)) as clm_surname;
END;$BODY$
LANGUAGE plpgsql VOLATILE
COST 1 SECURITY DEFINER ROWS 1;
ALTER FUNCTION fnk_create_table(varchar, varchar) OWNER TO postgres;
GRANT EXECUTE ON FUNCTION fnk_create_table(varchar, varchar) TO postgres;
Code: Select all
select * from fnk_create_table('Albert', 'Einstein ');
Code: Select all
clm_name clm_surname
Alb Einste
Add this code in OnFormCreate event:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
ZConnection1.HostName := 'localhost';
ZConnection1.User := 'postgres';
ZConnection1.Password := 'your_password_here';
ZConnection1.Database := 'postgres';
ZConnection1.Protocol := 'postgresql-9';
ZConnection1.Connected := True;
ZQuery1.Connection := ZConnection1;
ZQuery1.SQL.Add('select * from fnk_create_table(''Albert'', ''Einstein'');');
ZQuery1.Open;
DataSource1.DataSet := ZQuery1;
DBEdit1.DataSource := DataSource1;
DBEdit1.DataField := 'clm_name';
end;
Code: Select all
ZQuery1.FieldByName('clm_name').SetFieldType(TFieldType.ftString);
DBEdit1.Field.SetFieldType(TFieldType.ftString);
Windows 7 x64, ZEOSDBO-7.1.2-stable, Delphi XE2.