power builder中解决float,long等类型demo - Tuxedo (Chinese)

int iRet=0 ;
string str;
iRet = TuxInit(2);
MessageBox ("tuxinit ret val" ,string(iRet) )
str = '101011.98'
iRet = TuxSetFld32(100665536,str,2,0,0)
MessageBox ("RECNUM float ret val" ,string(iRet)+"|"+str )
str = '8981'
iRet = TuxSetFld32(33556580,str,1,0,0)
MessageBox ("BILLCOUNT long ret val" ,string(iRet)+"|"+str )
if (iRet < 0) then
     MessageBox ("BILLOUT long ret val" ,string(iRet)+"|"+str )
end if
messagebox("begin tpcall","begin tpcall");
str = "FMLTMP"
iRet = TuxTpCall(str,0)
MessageBox ("TuxTpCall ret val" ,string(iRet))
if ( iRet < 0) then
     MessageBox ("TuxTpCall ret val" ,string(iRet) )
end if
str=space(10)
iRet = TuxGetFld32(100665536,str,2,0)
messagebox("str--->aaaaaa",str)
MessageBox ("TuxGetFld32 RecNum float ret val" ,string(iRet)+"|"+str )
str=space(10)
iRet = TuxGetFld32(33556580,str,1,0)
MessageBox ("TuxGetFld32 BILLCOUNT long ret val" ,string(iRet)+"|"+str )
str=space(10)
iRet = TuxGetFld32(100665348,str,2,0)
MessageBox ("TuxGetFld32 DEPOSIT float ret val" ,string(iRet)+"|"+str )
str=space(10)
iRet = TuxGetFld32(33556847,str,1,0)
MessageBox ("TuxGetFld32 NUMLONG long ret val" ,string(iRet)+"|"+str )
iRet = TuxTpFree();
MessageBox ("TuxFree ret val" ,string(iRet) )
iRet = TuxTpTerm();
MessageBox ("TuxTpTerm ret val" ,string(iRet) ) 

好象您中间用的函数都有个什么tux开头,是不是用c写了客户端的动态库了。 

对。这些函数是自己使用vc++封装的动态连接库内的函数。 

其实bea提供了几个long、float等类型函数,但是我们在使用pb中,发现long类型的可以解决,但是float类型传输后,总是按着什么科学计数法(???E????)表示小数,我们就自己封装了几个函数解决的。 

如果你封装了它们,那么您以后就可以整理一下这些DLL,加一些必要的说明,然后放到网上去让大家来down。从此也就不要花太多的精力来研究tuxedo中api函数的细节了。 

没有问题的。 

用pb注意string必须提钱分配,否则调用动态库时候常出内存错误。

Related

Found errors in apex. How to contact APEX developers?

Using APEX more than year. During this time found some problems, such as lost quotes in errors in querry builder in some places. This porblem's may be invisible when working with english tables/columns names, but are significant, when they are in unicode and casesensitive.
How can i contact apex developers to improve APEX quality? 
Vadim,
Feel free to provide this information in the forum. Developers review reports about product defects here. And thanks for taking the time to report problems.
Scott 
How can i post some code or attach file here, on forum?
arrys idexes becomes links, summs becoms italics.
is there any tags for inserting code?
First error is with query builder. It misses some quotes when using sorting or groupings, making queries with unicode and low-case table/columns names unworkable.
I've solved the problem, but i don't know how to post patched code here.
Second problem that there are some validations in apex code, marked with comment "When we allow multibyte item names, this validation can be removed."
This validations makes problems with some items, generated by wizards. Items with Unicode names are corrctly generated by wizards, works correctly, until you wish to update them. At that moment you cannot save item with it's old name.
I've solved the problem by removing this validations from f4000.sql before installing. I think, that this should be removed in apex 4.
The third error is describdeb APEX generates incorrect POST-request when printing pdf. It is most significant problem, that does not allow some correct pdf reports to be generated. 
Hi,
You can paste code at [www.pastebin.ca] - just make sure you specify never expire or something longer than the default 1 month
You can paste images on [www.tinypic.com]
You can upload files to [www.sendspace.com]
Or for pasting code here directly you can use [code][/code] tags.
Mike 
corrected images/qb/qb_gensql.js follows
pathed gen_Columns, gen_Group and gen_Sort
var qb_checkCols=0;
var qb_suspendGen=false;
function qb_linkDblClick(){
    // put some code here
    var x=this;
}
function qb_tableDblClick(){
    // put some code here
     var x=this;
}
function qb_columnDblClick(){
    // put some code here
     var x=this;
}
function qb_getAlias(obj) {
      var tname = obj.getAttribute("htmldb:name")
      var tcnt = obj.getAttribute("htmldb:cnt")
      var cId = '';
      if (tcnt > 0) {
        cId = tname+'_'+tcnt;
      } else {
        cId = tname;
      }
      return cId;
}   
function qb_rmTableConditions(id) {
//  var t = html_GetElement(id);
  var t = html_GetElement(id+"_thold");
//  var zx = id;
  if (t) {
//      var tname = t.innerHTML;
//      var tname = t.getAttribute("htmldb:name")
//      var tcnt = t.getAttribute("htmldb:cnt")
//      var cId = '';
//      if (tcnt > 0) {
//        cId = tname+'_'+tcnt;
//      } else {
//        cId = tname;
//      }
      var x=html_GetElement('conditions').getElementsByTagName('TR');
      for(var i=0;i<x.length;i++){
       // var foo = x.id;
if(x[i].table && x[i].table == qb_getAlias(t)) {
qb_checkCols--;
var zz = x[i].table;
x[i].parentNode.removeChild(x[i]);
i--;
}
}
}else{
return false;
}
qb_genSql();
}
function qb_rmCondition(x) {
x = html_GetElement(x);
x.parentNode.removeChild(x);
qb_checkCols--;
qb_genSql();
}
function qb_rmConditionImg(x) {
var chkBox = html_GetElement('selectColumns_'+x);
chkBox.checked = false;
x = html_GetElement(x+'_condition');
x.parentNode.removeChild(x);
qb_checkCols--;
qb_genSql();
}
function qb_toggleOut(id){
var x = html_GetElement(id);
var y = html_GetElement(x.col+"_grp");
if (x.checked) {
x.checked=true;
x.defaultChecked=true;
} else {
x.checked=false;
y.checked=false;
x.defaultChecked=false;
y.defaultChecked=false;
}
qb_genSql();
}
function qb_toggleGrp(id){
var x = html_GetElement(id);
cDebug(x)
var y = html_GetElement(x.col+"_out");
cDebug(y +':'+x.col+"_out")
if (x.checked) {
x.checked=true;
y.checked=true;
x.defaultChecked=true;
y.defaultChecked=true;
} else {
x.defaultChecked=false;
x.checked=false;
}
qb_genSql();
}
function qb_setFun(obj) {
var s = obj.value;
var count = 0;
if (s!="") {
var matches = s.match(/\(/g);
if (matches)
count = matches.length;
}
obj.paren = count;
qb_genSql();
}
function qb_rendCharSelect(obj){
obj.options.length = 0;
obj.options[obj.options.length]=new Option('','');
obj.options[obj.options.length]=new Option('COUNT','count(');
obj.options[obj.options.length]=new Option('COUNT DISTINCT ','count( distinct ');
obj.options[obj.options.length]=new Option('INITCAP','initcap(');
obj.options[obj.options.length]=new Option('LENGTH','length(');
obj.options[obj.options.length]=new Option('LOWER','lower(');
obj.options[obj.options.length]=new Option('LTRIM','ltrim(');
obj.options[obj.options.length]=new Option('RTRIM','rtrim(');
obj.options[obj.options.length]=new Option('TRIM','rtrim(ltrim(');
obj.options[obj.options.length]=new Option('UPPER','upper(');
obj = null;
return;
}
function qb_rendNumberSelect(obj){
obj.options.length = 0;
obj.options[obj.options.length]=new Option('','');
obj.options[obj.options.length]=new Option('COUNT','count(');
obj.options[obj.options.length]=new Option('COUNT DISTINCT ','count( distinct ');
obj.options[obj.options.length]=new Option('AVG','avg(');
obj.options[obj.options.length]=new Option('MAX','max(');
obj.options[obj.options.length]=new Option('MIN','min(');
obj.options[obj.options.length]=new Option('SUM','sum(');
obj = null;
return;
}
function qb_rendDateSelect(obj){
obj.options.length = 0;
obj.options[obj.options.length]=new Option('','');
obj.options[obj.options.length]=new Option('COUNT','count(');
obj.options[obj.options.length]=new Option('COUNT DISTINCT ','count( distinct ');
// obj.options[obj.options.length]=new Option('YEAR','year');
// obj.options[obj.options.length]=new Option('QUARTER','quarter');
// obj.options[obj.options.length]=new Option('MONTH','month');
// obj.options[obj.options.length]=new Option('DAY','weekday');
// obj.options[obj.options.length]=new Option('DAY OF YEAR','doy');
// obj.options[obj.options.length]=new Option('WEEK','week');
obj = null;
return;
}
// add a condition row
function qb_addCondition(box){
qb_checkCols++;
// get table and create new row
var x = box;
var table = html_GetElement("conditions");
cTestClone(box.value.substring(0,box.value.indexOf('.')),box.value.substring(box.value.indexOf('.')+1),box)
if ( ! qb_suspendGen )
qb_genSql();
}
function cTestClone(p_Obj,p_Col,p_Box){
var startTime = new Date();
var l_Obj_Col = p_Obj + '.' + p_Col;
var table = html_GetElement("conditions");
var l_cRow = html_GetElement('clone');
var newTR = l_cRow.cloneNode(true);
var x = p_Box.value.substring(0,p_Box.value.indexOf('.'));
newTR.table = x;
/*
if(document.all){
table.firstChild.appendChild(newTR);
}else{
table.appendChild(newTR);
}
*/
newTR.table = p_Obj;
var l_Tds = newTR.getElementsByTagName('TD');
newTR.id = p_Box.value+"_condition";
//cDebug(newTR.id)
l_Tds[8].getElementsByTagName('SELECT')[0].id = l_Obj_Col + '_fun'; // Function
var l_ColIn = l_Tds[1];
l_ColIn.id = l_Obj_Col + '_Column'; // Column
l_ColIn.innerHTML = p_Col; // Column
var l_ObjIn = l_Tds[3];
l_Tds[3].id = l_Obj_Col + '_Object'; // Object
l_ObjIn.innerHTML = p_Obj; // Object
l_Tds[2].getElementsByTagName('INPUT')[0].id = l_Obj_Col + '_alias'; // Alias id
var l_Inp = table.getElementsByTagName('INPUT');
var c = 0;
var r = 0;
for (j=0;j<l_Inp.length;j++) {
var aid = l_Inp[j].id.substring(l_Inp[j].id.indexOf('.')+1);
var aid2 = l_Inp[j].value.substring(l_Inp[j].value.indexOf('_')+1);
if (aid == p_Col+'_alias') {
c = c+1;
if ( aid2 > r)
r = aid2;
}
}
var l_Alias = '';
if ( c == 1 )
l_Alias = '';
if ( c == 2 )
l_Alias = '_1';
r = parseInt(r)+1;
if ( c > 2 )
l_Alias = '_'+r;
l_Tds[2].getElementsByTagName('INPUT')[0].value = p_Col+l_Alias; // alias value
var l_outIN = l_Tds[7].getElementsByTagName('INPUT')[0];
l_outIN.id = l_Obj_Col + '_out'; // Output?
l_outIN.out = "1";
l_outIN.col = p_Box.value;
l_Tds[5].getElementsByTagName('SELECT')[0].id = l_Obj_Col + '_st'; // Sort Type
var l_soIN = l_Tds[6].getElementsByTagName('INPUT')[0];
l_soIN.id = l_Obj_Col + '_so'; // Sort Order
l_soIN.sort = "1";
l_soIN.st = p_Box.value+"_st";
l_soIN.col = p_Box.value;
var l_grpIN = l_Tds[9].getElementsByTagName('INPUT')[0]
l_grpIN.id = l_Obj_Col + '_grp'; // Group By
l_grpIN.grp = "1";
l_grpIN.col = p_Box.value;
var l_Del = l_Tds[10].getElementsByTagName('IMG')[0];
l_Del.id = l_Obj_Col + '_del'; // Output?
l_Del.value = l_Obj_Col;
var l_conIN = l_Tds[4].getElementsByTagName('INPUT')[0];
l_conIN.id = l_Obj_Col + '_con'; // Condition
l_conIN.where = "1";
l_conIN.col = p_Box.value;
if(document.all){
table.firstChild.appendChild(newTR);
}else{
table.appendChild(newTR);
}
if (p_Box.alt=='DATE')qb_rendDateSelect(html_GetElement(l_Obj_Col + '_fun'));
if (p_Box.alt=='VARCHAR2')qb_rendCharSelect(html_GetElement(l_Obj_Col + '_fun'));
if (p_Box.alt=='NUMBER')qb_rendNumberSelect(html_GetElement(l_Obj_Col + '_fun'));
newTR = null;
l_Tds = null;
cDebug("Elap:"+(new Date() - startTime));
return;
}
function qb_RowUp(pThis){
oElement = html_RowUp(pThis);
qb_genSql();
return oElement;
}
function qb_RowDown(pThis){
oElement = html_RowDown(pThis);
qb_genSql();
return oElement;
}
function qb_checkColumn(box){
var x = html_GetElement(box.value+"_condition");
if (box.checked == true && x ) {
return;
} else if (box.checked == true && !x ) {
if ( qb_checkCols + 1 > 60 ) {
box.checked=false;
alert(l_maxCols);
return;
} else {
qb_addCondition(box);
}
} else if (box.checked == false && x ) {
qb_rmCondition(x);
} else if (box.checked == false && !x ) {
return;
}
}
function qb_genSql(){
//if(g_SkipWriteSQL){return true;}
var cols = qb_getColumns();
var tabs = qb_getTables();
var l = qb_getLinks();
var w = qb_getWhere();
var g = qb_getGroup();
var s = qb_getSort();
var ret;
if ( cols != "" && tabs != "" ) {
ret = "select\t" + cols + " \n from\t" + tabs;
if ( l!="" ) {
if (w!="") {
ret = ret + " \n where " + l +"\n and "+ w;
} else {
ret = ret + " \n where " + l;
}
} else {
if (w!="")
ret = ret + " \n where " + w;
}
ret = ret + g + s;
} else {
ret = "";
}
//cDebug(ret)
var d = html_GetElement("QUERYTEXT");
if (d){d.value = ret};
//set the value on the page
var q = html_GetElement("P1002_QUERY");
if (q){q.value = ret};
// set the value in session
//qb_postQUERY(ret);
qb_resultsOnClick=true;
}
function qb_getLinks(){
var ret="";
var tab = "";
for(var i=0;i<qb_links.length;i++){
ret = ret == "" ? " ": ret + "\n and\t "
tab = qb_links[i].field1.id.split('.');
ret = ret + '"'+tab[0]+'"."'+tab[1]+'"';
if ( qb_links[i].condition == 'L')
ret = ret + '(+) =';
else
ret = ret + '=';
tab = qb_links[i].field2.id.split('.');
ret = ret + '"'+tab[0]+'"."'+tab[1]+'"';
if ( qb_links[i].condition == 'R')
ret = ret + '(+)';
}
return ret;
}
function qb_getTables(){
var d=html_GetElement('qbTableHolder').getElementsByTagName('DIV');
var ret="";
for(var i=0;i<d.length;i++){
if ( d[i].id && d[i].id.substring(d[i].id.length-5) == "thold" ) {
var tname = d[i].getAttribute("htmldb:name");
ret = ret == "" ? " ": ret + ",\n\t ";
ret = ret +'"'+ tname+'"' + ' "' + qb_getAlias(d[i])+'"';
}
}
return ret;
}
function qb_getColumns(){
var d=html_GetElement('conditions').getElementsByTagName('INPUT');
var ret="";
for(var i=0;i<d.length;i++){
//cDebug('qb_getColumns :' + d[i].checked +':'+d[i].out)
if ( d[i].checked && d[i].out) {
var a = html_GetElement(d[i].col+"_alias");
var f = html_GetElement(d[i].col+"_fun");
// is a function assigned
if (f && f.value != "") {
if (f.paren>0) {
var par = "";
for (var zz=0;zz<f.paren;zz++) { par = par + ")"; }
ret = ret == "" ? " ": ret + ",\n\t " ;
var tab = d[i].col.split('.');
ret = ret + f.value + '"'+tab[0]+'"."'+tab[1] + '"' + par + ' as "' + a.value +'"';
} else {
// do my to_char stuff here
ret = ret == "" ? " ": ret + ",\n\t " ;
var l_col = " ";
switch (f.value) {
case "year":
l_col = "to_char("+d[i].col+",'YYYY')";
break;
case "quarter":
l_col = "to_char("+d[i].col+",'Q')";
break;
case "month":
l_col = "to_char("+d[i].col+",'MONTH')";
break;
case "doy":
l_col = "to_char("+d[i].col+",'DDD')";
break;
case "week":
l_col = "to_char("+d[i].col+",'WW')";
break;
case "weekday":
l_col = "to_char("+d[i].col+",'DAY')";
break;
}
ret = ret + l_col + ' as "' + a.value +'"';
}
} else {
ret = ret == "" ? " ": ret + ",\n\t " ;
var tab = d[i].col.split('.');
ret = ret + '"'+tab[0]+'"."'+tab[1] + '" as "' + a.value +'"';
}
}
}
return ret;
}
function qb_getWhere(){
var d=html_GetElement('conditions').getElementsByTagName('INPUT');
var ret="";
for(var i=0;i<d.length;i++){
var foo = d[i].value;
if ( d[i].where && d[i].value != "" ) {
ret = ret == "" ? "\t ": ret + " \n and\t " ;
var tab = d[i].col.split('.');
ret = ret + '"'+tab[0]+'"."'+tab[1] + '" ' + d[i].value ;
//ret = ret + d[i].col + ' ' + d[i].value ;
}
}
return ret;
}
function qb_getSort(){
var d=html_GetElement('conditions').getElementsByTagName('INPUT');
var m = new Array;
var zz = 0;
var pos=1;
var maxpos=1;
var ret="";
// make a smaller array from the input arrays that are sort value
// and get the maximum value
for(var i=0;i<d.length;i++){
if (d[i].sort && d[i].value != "" ) {
m[zz] = d[i];
if(m[zz].value > maxpos){maxpos = m[zz].value};
zz++
}
}
while (pos<=maxpos) {
for(var i=0;i<m.length;i++){
if ( m[i].sort && m[i].value != "" ) {
if (m[i].value == pos) {
var x = html_GetElement(m[i].st);
if (x.value == "None") {
ret = ret == "" ? "\norder by ": ret + ", " ;
var tab = m[i].col.split('.');
ret = ret + '"' + tab[0] + '"."' + tab[1] + '" Asc';
} else {
ret = ret == "" ? "\norder by ": ret + ", " ;
var tab = m[i].col.split('.');
ret = ret + '"' + tab[0] + '"."' + tab[1] + '" ' + x.value ;
}
}
}
}
pos++;
}
return ret;
}
function qb_getGroup(){
var d=html_GetElement('conditions').getElementsByTagName('INPUT');
var ret="";
for(var i=0;i<d.length;i++){
if ( d[i].grp && d[i].checked ) {
ret = ret == "" ? " \ngroup by ": ret + ", " ;
var tab = d[i].col.split('.');
ret = ret + '"' + tab[0] + '"."' + tab[1] + '"';
}
}
return ret;
}
/* sets up and executes savetab*/
function qb_SaveTab(pThis){
html_ShowElement(html_MakeParent('R7170925778234838','Save_table'));
html_ShowElement(html_MakeParent('R7099926313598093','Save_table'));
html_TabClick(pThis,'Save_table');
return;
}
function qb_newCondition(col,alias,func_value,func_paren,out,sort_type,sort_order,group_by,condition) {
var c=html_GetElement("selectColumns_"+col);
c.checked="true";
qb_checkColumn(c);
var f = html_GetElement(col+"_fun");
f.value = func_value;
f.paren = func_paren;
var a = html_GetElement(col+"_alias");
a.value = alias;
var o = html_GetElement(col+"_out");
o.checked = out == "false" ? "": "true";
var st = html_GetElement(col+"_st");
st.value = sort_type;
var so = html_GetElement(col+"_so");
so.value = sort_order;
var g = html_GetElement(col+"_grp");
g.checked = group_by == "false" ? "": "true";
var con = html_GetElement(col+"_con");
con.value = condition;
}
This is why I like using pastebin for large code segments :)
Mike

请看代码,为什么会花了12秒钟返回270条记录!客户端用VB

/*取操作日志表*/
LogInfo(TPSVCINFO *rqst)
{
int i=0;
FBFR32* obuf;
obuf = (FBFR32*)tpalloc("FML32",NULL,102400);
exec sql declare c3 cursor for select JLBH,CZYID,MKBH,GNBH,CZIP,to_char(CZSJ,'YYYY/MM/DD HH24:MI:SS'),CZZT From CZRZ ;
exec sql open c3;
while (1){
     exec sql whenever not found do break;
     exec sql fetch c3 into :ac_RecordID,:ac_OperatorID,:ac_OperatorModule,:ac_OperatorFunction,:ac_IpAddr,:ac_OperatorTime,:ac_Flag;     
(void)Fchg32((FBFR32*)obuf,RecordID,(FLDOCC32)i,(char*)ac_RecordID,(FLDLEN32)0);
     (void)Fchg32((FBFR32*)obuf,OperatorID,(FLDOCC32)i,(char*)ac_OperatorID,(FLDLEN32)0);     
     (void)Fchg32((FBFR32*)obuf,OperatorModule,(FLDOCC32)i,(char*)ac_OperatorModule,(FLDLEN32)0);
     (void)Fchg32((FBFR32*)obuf,OperatorFunction,(FLDOCC32)i,(char*)ac_OperatorFunction,(FLDLEN32)0);
     (void)Fchg32((FBFR32*)obuf,OperatorTime,(FLDOCC32)i,(char*)ac_OperatorTime,(FLDLEN32)0);
     (void)Fchg32((FBFR32*)obuf,IpAddr,(FLDOCC32)i,(char*)ac_IpAddr,(FLDLEN32)0);
     (void)Fchg32((FBFR32*)obuf,Flag,(FLDOCC32)i,(char*)ac_Flag,(FLDLEN32)0);
     //userlog("select out RecordID:%s",ac_RecordID);
i++;
}
exec sql close c3;
/*把取出的结果返回给客户端*/
// userlog("select resoult is complete");     
tpreturn( TPSUCCESS,0, obuf, 0, 0 );
}
客户端用VB:
Dim reqstr As Long
Dim sendstr As Long
Dim RecvBuf As TuxBuf
Dim mylen As Long
Dim logID As String
Dim myResultString As String
myResultString = String(65535, vbNullChar)
RecvBuf.Bufptr = tpalloc("FML", "", ByVal 0&)
If RecvBuf.Bufptr = TP_ALLOC_ERROR Then
Msg$ = "tpalloc Failed - tperrno = " + str$(gettperrno())
MsgBox Msg$
Exit Sub
End If
logID = txtBranch_ID.Text
sendstr = tpalloc("STRING", vbNullString, 65535)
If sendstr = -1 Then
wstatus = tpterm()
MsgBox "ERROR:: Unable to Allocate STRING Buffer!"
Exit Sub
Else
wstatuslong = lstrcpyPtr(sendstr, logID)
mylen = Len(logID) + 1
If tpcall("LogSearch", sendstr, mylen, RecvBuf.Bufptr, iRcvLen, 0&) = -1 Then
MsgBox "ERROR:: Failed to Request the Service!"
Else
wstatuslong = lstrcpyStr(myResultString, RecvBuf.Bufptr)
End If
i = 0
Do While True
FrmLog.Flex.Rows = i + 2
FrmLog.Flex.Row = i + 1
iRet = Fget32(RecvBuf.Bufptr, RecordID, i, ByVal myResultString, 0&)
If iRet = -1 Then
Exit Do
End If
FrmLog.Flex.Col = 0
FrmLog.Flex.Text = myResultString
iRet = Fget32(RecvBuf.Bufptr, OperatorID, i, ByVal myResultString, 0&)
If iRet = -1 Then
Exit Do
End If
FrmLog.Flex.Col = 1
FrmLog.Flex.Text = myResultString
iRet = Fget32(RecvBuf.Bufptr, OperatorModule, i, ByVal myResultString, 0&)
If iRet = -1 Then
Exit Do
End If
FrmLog.Flex.Col = 2
FrmLog.Flex.Text = myResultString
iRet = Fget32(RecvBuf.Bufptr, OperatorFunction, i, ByVal myResultString, 0&)
If iRet = -1 Then
Exit Do
End If
FrmLog.Flex.Col = 3
FrmLog.Flex.Text = myResultString
iRet = Fget32(RecvBuf.Bufptr, OperatorTime, i, ByVal myResultString, 0&)
If iRet = -1 Then
Exit Do
End If
FrmLog.Flex.Col = 4
FrmLog.Flex.Text = 
建议你首先在service的数据库读取前后加上打印时间语句,看看用了多少时间。数据库很可能是一个瓶颈。 
同意楼上的建议。
建议在读取数据库记录的时候加入前后的时间。看是否数据库性能配置是否存在问题。 
看了一下你的代码,是把那个表的数据都取出来,没有查询条件,而且记录这么少(270多),我想数据库应该不会慢吧。还有就是,你为什么用Fchg32而不用Fadd32。我觉得Fchg32是修改,要根据occ在buffer中定位,然后修改,而Fadd32是往buffer中放,occ自动增长,应该效率会高些。实际证明,FML有时会成为瓶颈。这两个函数性能我没有比较过,纯属猜测,你自己可以试一下吧,把结果贴上来吧。还有就是client会不会慢,你可以把开始接收第一个数据和收完后的时间打出来看看。 
感觉你可以这样分步做:先将SQL语句分析一下,是否是数据库影响了速度。如果不是,在后台服务程序里加上时间信息,看看慢在什么地方。最后肯定可以找到瓶颈的。 
不过BEA的工程师说这是由于FML的问题,我觉得不然,BUFFER处理没有理由这么慢.
加上了时间戮之后,原来是这样的:
Server早已执行完毕,瓶颈是在客户端,应该可能是FML的问题.
各位高手有没有更好的解决办法?用VIEW会不会快一些?
我测试过,用的不好的话FML的buffer是会成为瓶颈的,不要猜测觉得内存操作就几乎不花时间。现在知道是client的问题了,你看一下你在客户端开buffer有没有问题,还有就是客户端这边的机器性能如何,多试一下。 
客户端的机器是P4的SONY最新笔记本,内存512M,我想应该没有任何问题在机器性能上来说.
但是我做测试的客户端是HP 9000超级小型机,和被测主机之间的网络就不说了,照样会出那个问题。 
要注意啦,FML本来就是一个比较慢的东西,它的特点在于灵活!
如果怀疑是FML的处理过慢,其实你可以专门就这个部分在你自己的机器上面做实验在确认,比如看看把一千条记录加入FML中需要多少时间。
性能问题就是比较麻烦,大家都知道要把瓶颈找出来,可是怎么找呢?也只能把整个过程分段,对怀疑的部分加以分析、确认了。呵呵,慢工出细活。 
这个问题flyisland 很有经验,上次还是他帮忙了,确实是要动手试验,不能凭感觉,上次就把oracle很冤枉了一把,呵呵。 
可以将你的例子发给我看看,好吗?
mrvb#sina.com 
是不是客户端解析时间问题啊。看看服务器日志,后台所用时间和前台所用时间对比一下。

how to using OCICollGetElemArray?

how to using OCICollGetElemArray?
example
CStatement Statement;//sql statement
     if(!Statement.Attach(theApp.m_pDB))
          return;
     OCINumber* Numbers[10];
     double Buf[10];
     uword nStep = 10;
     sb4 nIndex = 0;
     boolean bExist = 0;
     memset(Numbers, 0, sizeof(Numbers));
     memset(Buf, 0, sizeof(Buf));
     sdo_geometry* pGeometry = NULL;
     sdo_geometry_ind* pGeometry_ind = NULL;
     OCIType* sdo_type = NULL;
     theApp.m_pDB->GetTDO(SDO_GEOMETRY, &sdo_type);
     if(NULL == sdo_type)
          return;
     CLoadGeom geom;
     string sql = "SELECT geometry FROM aaa where oid = 10495";
     Statement.Prepare(sql.c_str());
     Statement.DefineObjectByPos(1, sdo_type, (void**)&pGeometry, sizeof(sdo_geometry*), (void**)&pGeometry_ind, sizeof(sdo_geometry_ind*));
     if(0 >= Statement.Execute(1))
          return;
     int nCount = 0;
     OCIEnv* hOCIEnv = theApp.m_pDB->m_hOCIEnv;
     OCIError* hOCIError = theApp.m_pDB->m_hOCIError;
     const OCIArray* pArray = pGeometry->sdo_ordinates;
     OCICollSize(hOCIEnv, hOCIError, pArray, (sb4*)&nCount);//nCount = 10
     OCICollGetElemArray(hOCIEnv, hOCIError, pArray, nIndex, &bExist, (void**)Numbers, NULL, &nStep);//nStep=9 and nIndex=1 and Buf[0]~Buf[3] not zero
     OCINumberToRealArray(hOCIError, (const OCINumber**)Numbers, nStep, sizeof(double), Buf);
why?

Pass a PL/SQL local variable to the Javascript

I need to know how to pass a PL/SQL local variable to the Javascript.
The following code is in Addtional PL/SQL Code, AFTER PROCESS THE FORM.
I don't know how to pass the CNT into the javascript. Anyone knows?
Thanks,
Patty
==================================================================================
declare
cnt number;
begin
select count(*) into CNT
from time_reporting_week
WHERE WEEK_ENDING='09-MAR-02'
AND USER_ID = 'PPL';
if cnt > 0 then
htp.p('<script language="Javascript1.3">
//***** Days Total *****//
var itemname = new Array();
itemname = name.split(".");
//Form name
var fname = itemname[0];
//Field name
var fldname = itemname[2];
//
var row_num := 0;
var index;
//
var daytot_sun = new String(fname + ".DETAIL_BLOCK.TOTAL_SUN.01");
var daytot_mon = new String(fname + ".DETAIL_BLOCK.TOTAL_MON.01");
var daytot_tue = new String(fname + ".DETAIL_BLOCK.TOTAL_TUE.01");
var daytot_wed = new String(fname + ".DETAIL_BLOCK.TOTAL_WED.01");
var daytot_thu = new String(fname + ".DETAIL_BLOCK.TOTAL_THU.01");
var daytot_fri = new String(fname + ".DETAIL_BLOCK.TOTAL_FRI.01");
var daytot_sat = new String(fname + ".DETAIL_BLOCK.TOTAL_SAT.01");
//
//Initialize the day's total for each day
document.forms[0].elements[eval(daytot_sun)].value = 0;
document.forms[0].elements[eval(daytot_mon)].value = 0;
document.forms[0].elements[eval(daytot_tue)].value = 0;
document.forms[0].elements[eval(daytot_wed)].value = 0;
document.forms[0].elements[eval(daytot_thu)].value = 0;
document.forms[0].elements[eval(daytot_fri)].value = 0;
document.forms[0].elements[eval(daytot_sat)].value = 0;
//
for (i = 0; i < cnt; i++)
{
row_num = row_num + 1;
char_row = row_num;
if (row_num == 1) | (row_num == 2) | (row_num == 3) | (row_num == 4) |
(row_num == 5) | (row_num == 6) | (row_num == 7) | (row_num == 8) |
(row_num == 9)
{
index = "0" + char_row;
}
else
{
index = char_row;
}
//
var record_sun = new String(fname + ".DETAIL_BLOCK.HOURS_SUN." + index);
var record_mon = new String(fname + ".DETAIL_BLOCK.HOURS_MON." + index);
var record_tue = new String(fname + ".DETAIL_BLOCK.HOURS_TUE." + index);
var record_wed = new String(fname + ".DETAIL_BLOCK.HOURS_WED." + index);
var record_thu = new String(fname + ".DETAIL_BLOCK.HOURS_THU." + index);
var record_fri = new String(fname + ".DETAIL_BLOCK.HOURS_FRI." + index);
var record_sat = new String(fname + ".DETAIL_BLOCK.HOURS_SAT." + index);
document.forms[0].elements[eval(daytot_sun)].value =
parseFloat(document.forms[0].elements[eval(daytot_sun)].value) +
parseFloat(document.forms[0].elements[eval(record_sun)].value);
document.forms[0].elements[eval(daytot_mon)].value =
parseFloat(document.forms[0].elements[eval(daytot_mon)].value) +
parseFloat(document.forms[0].elements[eval(record_mon)].value);
document.forms[0].elements[eval(daytot_tue)].value =
parseFloat(document.forms[0].elements[eval(daytot_tue)].value) +
parseFloat(document.forms[0].elements[eval(record_tue)].value);
document.forms[0].elements[eval(daytot_wed)].value =
parseFloat(document.forms[0].elements[eval(daytot_wed)].value) +
parseFloat(document.forms[0].elements[eval(record_wed)].value);
document.forms[0].elements[eval(daytot_thu)].value =
parseFloat(document.forms[0].elements[eval(daytot_thu)].value) +
parseFloat(document.forms[0].elements[eval(record_thu)].value);
document.forms[0].elements[eval(daytot_fri)].value =
parseFloat(document.forms[0].elements[eval(daytot_fri)].value) +
parseFloat(document.forms[0].elements[eval(record_fri)].value);
document.forms[0].elements[eval(daytot_sat)].value =
parseFloat(document.forms[0].elements[eval(daytot_sat)].value) +
parseFloat(document.forms[0].elements[eval(record_sat)].value);
}
</script>');
end if;
Passing the value of PL/SQL variables to HTML or Javascript is the same. Once you've opened a htp.print('...'); you must escape the PL/SQL variable within the htp.print() block to have its value printed to the output of that htp.print method. Use the following:
htp.print('<script> .... ' || cnt || ' ... </script>');

Oracle results paging

I would like to page the results from an oracle query
I am using the code below and it print the links to the pages but do not display the column values . What can it be?
Thank´s in advance
<?php
$db_conn = ocilogon("xx", "xx", "xx");
if (!$pagina) {
$maior = 10;
$menor = 1;
$pagina = 1;
} else {
$maior = $maior + 10;
$menor = $maior - 9;
}
$conexao = $db_conn;
$sql = "SELECT * FROM TABLE";
$sql = "SELECT * FROM (SELECT rownum AS numero, COLUMN FROM ($sql) ".
"WHERE numero <= $maior ) where rownum >= $menor";
$sql = OCIParse($conexao, $sql);
OCIExecute($sql, OCI_DEFAULT);
$sql2 = "SELECT COUNT(*) as CONTADOR FROM TABLE";
$sql2 = OCIParse($conexao, $sql2);
OCIExecute($sql2, OCI_DEFAULT);
while (OCIFetch($sql2)) {
$conta = OCIResult($sql2, 'CONTADOR');
}
while (OCIFetch($sql)) {
$variavel = OCIResult($sql, 'COLUMN');
echo $variavel;
}
for ($i = 0; $i < $conta; $i++) {
$vai = $pagina +1;
$vaimaior = $vai * 10;
if ($pagina == $i) {
echo $vai;
} else {
echo "<a href='?pagina=$i&maior=$vaimaior'>$vai</a>";
}
}
?> 
This is some sample code to test. There are still some weaknesses
such as when a user passes a page number that is totally out of range.
I tried to be faithful to what I thought you intended.
I found it helpful to use distinct variable names.
I found it helpful to print our the variables to check they were correct.
I found it useful to identify the page by just the page number, and
then calculate the start and end rows using the constant ROWSPERPAGE.
I used the $_GET syntax to make the script portable: globals are now
switched off in PHP releases for security reasons.
You might find using bind variables advantageous.
<?php
define('ROWSPERPAGE', 5);
if (!isset($_GET['pagina'])) {
   $pagina = 1;
} else {
   $pagina = $_GET['pagina'] < 1 ? 1 : $_GET['pagina'];
}
$menor = ($pagina - 1) * ROWSPERPAGE + 1;
$maior = $menor + ROWSPERPAGE - 1;
//echo "pagina is $pagina, menor is $menor,  maior is $maior<br>\n";
$conexao = ociplogon("cjones", "cjones", "//tide.au.oracle.com:1535/t920.au.oracle.com");
$mysql = "select mycolumn from mytable order by mycolumn";
// Standard paging query from http://asktom.oracle.com:
//
//  select *
//    from ( select a.*, rownum rnum
//           from ( YOUR_QUERY_GOES_HERE -- including the order by ) a
//           where rownum <= MAX_ROWS )
//   where rnum >= MIN_ROWS
$pagesql = "select *
          from ( select a.*, rownum rnum
              from ( $mysql ) a
              where rownum <= $maior )
          where rnum >= $menor";
$stid = OCIParse($conexao, $pagesql);
OCIExecute($stid, OCI_DEFAULT);
echo "<table>";
while (OCIFetchInto($stid, $row, OCI_ASSOC+OCI_RETURN_NULLS)) {
   $variavel = $row['MYCOLUMN'];
   echo "<tr><td>".htmlentities($variavel)."</td></tr>";
}
echo "<table>";
$sql2 = "SELECT COUNT(*) as CONTADOR FROM MYTABLE";
$stid2 = OCIParse($conexao, $sql2);
OCIExecute($stid2, OCI_DEFAULT);
while (OCIFetch($stid2)) {
   $conta = OCIResult($stid2, 'CONTADOR');
}
//echo "Conta is ". $conta."<br>\n";;
for ($i = 1; $i < $conta/ROWSPERPAGE+1; $i++) {
   if ($pagina == $i) {
     echo $i." \n";
   } else {
     echo "<a href='?pagina=$i'>$i</a> \n";
   }
}
?>A web search will bring up many pre-written (and tested) solutions
such as ADOdb and PEAR's HTML_Page.
-- CJ 
BTW, I used ociplogon() just for testing. I'd be careful with it in production.
-- CJ

Categories

Resources