Bender
2nd January 2007, 18:21
Baan: Baan IVc4
DB: SQL Server 2000
OS: Windows 2003
C/S: Both

Hi there,

can anyone solve this Problem? ForumSearch did not help yet.
I am quite new to baan but have experience in DynamicSQL for Oracle.

Here my Problem:
I want to transfer tabledata from one company to another.
After i checked and compared all RDI-Infos an possible references,
i want to get a count of the data i want to transfer.

So i'm building a SQL with a "count(*):1" and a "not exists" clause.
Everything passes until the fetch is reached. Then i get this Errormessage in the Event-Viewer only: "bdberrno 509 (Bad memory cursor; bad table pointer specified)"
The Session itself crashes away to Nirvana.

This is the part of the code, that matters.

If anybody has a clue, please tell me :)
Thanks in advance guys

****************
sql.source.cnt.select=sprintf$("select count(%s):1 "& "from %s where %s._compnr = %d "
& "and not exists (select * from %s where %s._compnr = %d) " ,str.cnt.column
,tmp.source.table, tmp.source.table, tmp.sourcecompnr
,tmp.target.table, tmp.target.table, tmp.targetcompnr)
sql_id.source.cnt.tbl = sql.parse(sql.source.cnt.select)
if sql_id.source.cnt.tbl<>0 then if(sql.select.bind(sql_id.source.cnt.tbl, 1, src.cnt)=0)then if(sql.exec(sql_id.source.cnt.tbl)=0)then while true on case sql.fetch(sql_id.source.cnt.tbl) case eendfile:
break
case 0:
break
default:
endcase
break
endwhile
sql.break(sql_id.source.cnt.tbl)
sql.close(sql_id.source.cnt.tbl)
endif
endif
endif
****************

solepeder
2nd January 2007, 19:05
Hi,

I didn't work a lot with this, but you can try this: (modifications in blue)

sql.source.cnt.select=sprintf$("select count(*):1 "
& "from %s where %s._compnr = :2 "
& "and not exists (select %s.* from %s where %s._compnr = :3) "
,tmp.source.table, tmp.source.table, tmp.target.table,
,tmp.target.table, tmp.target.table)

sql_id.source.cnt.tbl = sql.parse(sql.source.cnt.select)

if sql_id.source.cnt.tbl<>0 then
if(sql.select.bind(sql_id.source.cnt.tbl, 1, src.cnt)=0)then
sql.where.bind(sql_id.source.cnt.tbl, 2, tmp.sourcecompnr)
sql.where.bind(sql_id.source.cnt.tbl, 3, tmp.targetcompnr)
if(sql.exec(sql_id.source.cnt.tbl)=0)then
while true
on case sql.fetch(sql_id.source.cnt.tbl)
case eendfile:
break

case 0:
break

default:

endcase
break

endwhile

sql.break(sql_id.source.cnt.tbl)
sql.close(sql_id.source.cnt.tbl)
endif

endif

endif

In the other hand...
Table source and target exist in the company source and target, don't they?

I hope this work...

Soledad

Bender
2nd January 2007, 19:20
thanks for helping ;)
but your suggestions do not change the gruesome result :(

i'll keep trying though...

By the Way, do you know how to determine wich column is a index column in a table?

greetz,
Bender

solepeder
3rd January 2007, 22:14
thanks for helping ;)
but your suggestions do not change the gruesome result :(

i'll keep trying though...

By the Way, do you know how to determine wich column is a index column in a table?

greetz,
Bender

The table that contains table index is ttadv421. You should use field ttadv421.part.

I hope this help you.

Soledad

Bender
4th January 2007, 10:28
Thanks Soledad, this would make it easier, i did it myself now using every info from rdi :) But Thanks again man ;)