zxs1225
2nd November 2012, 09:01
I want to get data using OLE function. currently I can get data withing table name and field name. But I want to get some summarized data from sql, I do not know how to get the return value using OLE, my program code like following, please help to check what should I do :(
Query = "select sum(tfacr200.amnt) as smant from tfacr200 where tfacr200.itbp ='C14000001'"
B_function = "olesql_parse(" & Chr(34) & Query & Chr(34) & ")"
BaanObj.ParseExecFunction "ottdllsql_query", B_function
query_id = Val(BaanObj.returnvalue)
If query_id <> 0 Then

B_function = "olesql_fetch(" & query_id & ")"
BaanObj.ParseExecFunction "ottdllsql_query", B_function
temp_string = "smant" 'I do not know the variable name should be used
SAMNT = String(80, " ")
B_function1 = "olesql_getstring(" & Chr(34) & temp_string & Chr(34) & "," & Chr(34) & SAMNT & Chr(34) & ")"
BaanObj.ParseExecFunction "ottdllsql_query", B_function1
temp_string = BaanObj.ReturnCall
SAMNT = Mid(temp_string, 27, InStrRev(temp_string, """") - 27)
SAMNT = Trim(SAMNT)

End If

mark_h
2nd November 2012, 18:49
Moved to the correct forum. Do some searching on this forum and you should find some examples to help you. One thread (http://www.baanboard.com/baanboard/showthread.php?t=14762&highlight=Return+variables+OLE) and here is another (http://www.baanboard.com/baanboard/showthread.php?t=14778&highlight=parse) as an example. There are others if you search for OLE or Excel automation.

zxs1225
4th November 2012, 04:10
Dear mark_h, thank you very much. I'm sure I can use ole function, if I using qery directly with table and field name I can got result corrently, for excample: Query = "select tfacr200.amnt from tfacr200 where tfacr200.itbp ='C14000001'". But if I using alias name of fields I do not know how to get back the query result.

mark_h
4th November 2012, 13:58
Sorry - missed that. I have never done it myself, but the first thing I think was changing the query. Have you tried
Query = "select sum(tfacr200.amnt):smant from tfacr200 where tfacr200.itbp ='C14000001'" using : instead of as?

zxs1225
5th November 2012, 03:15
Dear mark_h, Thank you very much. I got the query result now. In Infor LN must using query as Query = "select sum(tfacr200.amnt):tfacr200.amnt from tfacr200 where tfacr200.itbp ='C14000001'", in Baan IV need not use alias name, can do like Query = "select sum(tfacr200.amnt) from tfacr200 where tfacr200.itbp ='C14000001'"