Page 1 of 1
Uniconnection Result
Posted: Fri 14 Mar 2014 10:31
by murkay
Is there a way to get results from Uniconnection without creating Uniquery ?
I mean uniconnection.execsql( select afield from mytable where bfield = 22)
I want to get value of afield.
Re: Uniconnection Result
Posted: Fri 14 Mar 2014 10:55
by AlexP
Hello,
No, you can't get ResultSet when using the uniconnection.execsql method
Re: Uniconnection Result
Posted: Fri 14 Mar 2014 11:30
by murkay
I made a function for this which gives first result and sql.text must have a result field
It is not perfect.
Maybe people may need this or you may add such a thing to your product.
Function ConnecExec(conn: TUniConnection; Sqltext: String): Variant;
Var
Query: TUniQuery;
Begin
Result := null;
If Not AnsiContainsText(Sqltext, 'result') Then
Exit;
Query := TUniQuery.Create(Nil);
Try
With Query Do
Begin
Connection := conn;
ReadOnly := true;
SQL.text := Sqltext;
Execute;
Result := FieldByName('result').Value;
End;
Finally
Query.Free;
End;
End;
Re: Uniconnection Result
Posted: Fri 14 Mar 2014 13:26
by AlexP
Please specify the database you are working with, as to retrieve the only value from the table (not the whole RecordSet), some databases have more simple ways
Re: Uniconnection Result
Posted: Fri 14 Mar 2014 13:40
by murkay
MSSQL Server and MS Access
Re: Uniconnection Result
Posted: Wed 19 Mar 2014 10:06
by AlexP
You can use stored procedures/functions for implementation of this functionality in MS SQL Server.