manusatsangi
10th October 2002, 19:13
Hi NPRao,
Sorry my question is not very much related to main point of discussion of this thread.
I have been wondering why people use SELECTBIND and WHEREBIND when they can just do with ":".
If
SELECT ppmod123.field1:5, ppmod123.field2:6
SELECTBIND(5, my_val1)
SELECTBIND(6, my_val2)
SELECTDO
....

ENDSELECT

same as

SELECT ppmod123.field1:my_val1, ppmod123.field2:my_val2
SELECTDO
....

ENDSELECT

then why would someone write extra piece of code using SELECTBIND.
maybe there is something in SELECTBIND which the latter code does'nt have? Is it so? If it is, could you please share it?

Warm Regards
Manu

mark_h
10th October 2002, 19:28
Manu - here is a sample that may help you understand why you want to use selectbind


function reset.file.pointer.production.bom()
{
select tibom010.*
from tibom010
where tibom010._index1 >= {:1, :2, :3}
order by tibom010._index1
as set with 1 rows
wherebind (1, mitm.stack(1, level))
wherebind (2, pono.stack(level))
wherebind (3, seqn.stack(level))
selectdo
endselect
}


As the level variable decreases you get the previous level of the BOM. This is just one way of doing this.

And since this off the main topic of the other thread, I will split this off to a new thread.

Mark

NPRao
10th October 2002, 20:05
Hi Manu,

The selectbind and wherebind are used to extract partial strings or particular array values.

Its explained in the help manual -


In order to bind pseudo variables, the functions SELECTBIND and WHEREBIND have been added. Pseudo variables have the form ':<number>'. A special bind function is then used to link a program variable to the pseudo variable.
It is also possible to use a pseudo variable in the WHERE clause. The WHEREBIND function is then used to link a value to the pseudo variable.
Used BAAN 4GL variables (with ':') are 'bound' automatically.

manusatsangi
11th October 2002, 08:18
Hi Mark,
Thanks for replying, but I'm sorry I still could'nt get your point.
Do you mean that I can't rewrite your code as below:

function reset.file.pointer.production.bom()
{
select tibom010.*
from tibom010
where tibom010._index1 >= {:mitm.stack(1, level), :pono.stack(level), :seqn.stack(level)}
order by tibom010._index1
as set with 1 rows
selectdo
endselect
}

Moreover, just to understand this sample code better how is mitm.stack declared?
Is it something like

extern domain tcitem mitm.stack(1, 5)


Warm Regards
Manu

manusatsangi
11th October 2002, 08:23
I meant..

where tibom010._index1 >= {:mitm.stack(1, level), :pono.stack(level), :seqn.stack(level)}


in my last post..

mark_h
11th October 2002, 15:56
Sometimes you need to turn smiles off in your posts or you get smiley faces in your code.

mitm.stack is declared like this:


extern domain tcitem mitm.stack(99)


And yes what you suggested is another way of doing the code. The way you suggested is probably how I would write the code.

Also you can't do this:


select tisfc010.*
from tisfc010
where tisfc010.pdno=313386
and tisfc010.opno>sqrt(100)
selectdo
endselect


But you can do this:

select tisfc010.*
from tisfc010
where tisfc010.pdno=313386
and tisfc010.opno>:1
wherebind(1,sqrt(100))
selectdo
endselect


According to the performance guide when doing dynamic sql you would want to use these options. I typically do not use them, but they are used in all of our BOM scripts.

Mark