heidihunter
14th August 2003, 13:41
Hi,

I'm writing a function to return a value for use in a report that looks basically like this:

function long func()
{
long returnval
returnval= 0

select table1.fld1
where (table1.fld2=val AND table1.fld3= table2.fld)
selectdo
... do something with returnval ...
endselect

...
}

On compiling I get the error "Unknown column table2.fld". All the fields mentioned are declared as input fields for the report, and table2.fld is used in other parts with no problem. Do I need another kind of declaration here?

Thanks,
Heidi

sanjaykathuria
14th August 2003, 13:54
select table1.fld1
where (table1.fld2=val AND table1.fld3=:table2.fld)
selectdo
... do something with returnval ...
endselect

Use code rather than

select table1.fld1
where (table1.fld2=val AND table1.fld3=table2.fld)
selectdo
... do something with returnval ...
endselect

Minor mistake (Bound veriable)

rupertb
14th August 2003, 14:32
Hi Heidi,

Please fill out your profile information, baan version, db type and os type - this will help us help you.

In the past I've noticed that it's easier to help with queries when the exact code is posted i.e. rather than re-type where you think the problem lies, attach a copy of the source or cut and paste the source into your posting.

Did you include a FROM in your select statement?

Sanjay:
both methods are acceptable however the results will vary

"where tccom010.cuno=:tccom010.cuno" means where tccom010.cuno is equal to the current value of tccom010.cuno. One result will be returned.
"where tccom010.cuno=tccom010.cuno" will return all rows as by definition tccom010.cuno = tccom010.cuno


Regards,
Rupert

lli-baan
14th August 2003, 15:04
is the table2 only declared in the other part of your script (maybe an other function)?
Try to declare the table at the top if the script (than it's global)!