1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- $PBExportHeader$f_getfromtable.srf
- $PBExportComments$从后台表中取数函数--自定义函数
- global type f_getfromtable from function_object
- end type
- forward prototypes
- global function string f_getfromtable (string table_get, string column_get, string cond_get, integer record_get)
- end prototypes
- global function string f_getfromtable (string table_get, string column_get, string cond_get, integer record_get);//column_get=字段英文名,cond_get=取数定位条件
- transaction t_report
- int li
- string ls_sql,ls_return
- if isvalid(w_rpt_edit) then
- t_report=w_rpt_edit.it_report
- elseif isvalid(w_rpt_preview) then//为了加快速度
- //t_report=w_rpt_preview.it_report
- else
- t_report=sqlca
- end if
- ls_sql="select "+column_get+" from "+table_get
- if trim(cond_get)>'' then ls_sql=ls_sql+" where "+cond_get
- prepare sqlsa from :ls_sql using t_report;
- describe sqlsa into sqlda;
- declare my_cursor dynamic cursor for sqlsa;
- open dynamic my_cursor using descriptor sqlda;
- for li=1 to record_get
- fetch my_cursor using descriptor sqlda;
- next
- if sqlda.numoutputs>0 then
- choose case sqlda.outparmtype[1]
- case TypeString!
- if t_report.sqlcode=0 then ls_return=GetDynamicString(sqlda,1)
- case TypeDate!
- if t_report.sqlcode=0 then ls_return=string(GetDynamicDate(sqlda,1),'yyyy/mm/dd')
- case TypeDateTime!
- if t_report.sqlcode=0 then ls_return=string(GetDynamicDatetime(sqlda,1))
- case TypeDecimal!,TypeDouble!,TypeInteger!,TypeLong!,TypeReal!
- if t_report.sqlcode=0 then ls_return=string(GetDynamicNumber(sqlda,1))
- case TypeTime!
- if t_report.sqlcode=0 then ls_return=string(GetDynamicTime(sqlda,1))
- end choose
- else
- ls_return='后台取数出错'
- end if
- close my_cursor;
- return ls_return
- end function
|