In be.as script SQL script can now be executed directly. The SQL area starts with #sql and ends with #end. If a return value is expected, it starts with #sqlscript and ends with #end. The variable <sqlresults> contains the number of returned values and <sqlresult:X> contains the results.
setvar=a=5.000000
setvar=b=6.000000
[sqlscript]
declare @m decimal(19,6);
declare @d decimal(19,6);
select @d = <a> / <b>;
select @m = <a> * <b>;
select @d,@m;
[/sqlscript]
setvar=ls_result=
for ll_loop=1 to <sqlresults>
ls_result=<ls_result> (<sqlresult:[ll_loop],#0.00>)
next
meldung=beasmeldung$$<ls_result>
or you can define the Area with #sqlscript ...#end
be.as variables are exchanged in the SQL-area too. This exchange happens “before”the SQL-Script is executed. Important: The SQL-Script is executed directly on the SQL-Server. Numbers which are transferred with placeholders, need to be formatted with num(x) and dbdate.
Example:
setvar=ld_today=<today>
setvar=lc_sum=
input=Please insert sum:=lc_sum=cancel
#sqlscript
select <ld_date,dbdate>,<lc_sum,num(6)> from "BEAS_DUMMY"
#end
Example: Update-Event in item-window
windowevent update
#sqlscript
if <item.39.value> = 100 and <item.39.value> <> '<ls_itemgroup>' begin
update "OITM" set u_dimension1 = u_dimension2 / u_dimension3 + 2.5 where "ItemCode" = <item.5.value,dbstring>;
end;
#end
end event
attention:
Format Numbers with num(x) and dates with dbdate and close strings with N'<string>'
Example
select <ld_date,dbdate>,<lc_sum,num(6)> from "BEAS_DUMMMY"
To execute one SQL-Statement, works with SQL
sql=select "ItemName" into ls_itemname from "OITM" where "ItemCode"=<ls_itemcode,dbstring>
messagebox=<ls_itemname>
See sql
If you've more then one result-line,then work with datastorevalues