Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Binding Error

Author  Topic 

humanpuck
Yak Posting Veteran

94 Posts

Posted - 2006-08-08 : 10:32:51
I get the following error when I try to select against a particular view.

Server: Msg 4413, Level 16, State 1, Line 1
Could not use view or function 'rptCallSummarySub' because of binding errors.

Is this because the view is using too many tables or something else? Any help would be appreciated. Here's the view.


create view dbo.rptCallSummarySub as
--drop view dbo.rptCallSummarySub
select origin_user_id,origin_org_id,
'#CC' = (case when (case when destination_user_id is not null
then Count(origin_user_id)
end) is null then 0
else (case when destination_user_id is not null
then Count(origin_user_id)end)
end),
'TT' = (case when (case when destination_user_id is not null
then Sum(call_length) end) is null then 0
else (case when destination_user_id is not null
then Sum(call_length) end)end),
'AT' = (case when (case when destination_user_id is not null
then sum(call_length)/count(origin_user_id) end) is null then 0
else (case when destination_user_id is not null
then sum(call_length)/count(origin_user_id) end) end),
'OC' = (case when Count(origin_user_id) is null then 0
else Count(origin_user_id) end),
'IC' = case when(case when exists(select user_id
from internal_profile
where internal_profile.user_id =
rpt_Wincall_Phone_TieTogether.destination_user_id)
then count(origin_user_id)end) is null then 0
else (case when exists(select user_id
from internal_profile
where internal_profile.user_id =
rpt_Wincall_Phone_TieTogether.destination_user_id)
then count(origin_user_id)end)end,'#ICC' = 0,
call_Date
from rpt_Wincall_Phone_TieTogether
group by origin_user_id,origin_org_id,destination_user_id,call_date

union all

select destination_user_id,destination_org_id,0,0,0,0,0,
'#ICC' = case when Count(destination_user_id)
is null then 0
else Count(destination_user_id)
end,call_date
from rpt_Wincall_Phone_TieTogetherIncoming
where origin_user_id is not null
group by destination_user_id,destination_org_id,call_date



TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-08-08 : 14:08:15
One cause for "binding errors" is after a view is created, one of the underlying tables/views/functions is renamed or dropped.

Be One with the Optimizer
TG
Go to Top of Page

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2006-08-08 : 22:08:32
I would test by using just the query itself and not the view. The binding error will be easier to pinpoint this way.


select origin_user_id,origin_org_id,
'#CC' = (case when (case when destination_user_id is not null
then Count(origin_user_id)
end) is null then 0
else (case when destination_user_id is not null
then Count(origin_user_id)end)
end),
'TT' = (case when (case when destination_user_id is not null
then Sum(call_length) end) is null then 0
else (case when destination_user_id is not null
then Sum(call_length) end)end),
'AT' = (case when (case when destination_user_id is not null
then sum(call_length)/count(origin_user_id) end) is null then 0
else (case when destination_user_id is not null
then sum(call_length)/count(origin_user_id) end) end),
'OC' = (case when Count(origin_user_id) is null then 0
else Count(origin_user_id) end),
'IC' = case when(case when exists(select user_id
from internal_profile
where internal_profile.user_id =
rpt_Wincall_Phone_TieTogether.destination_user_id)
then count(origin_user_id)end) is null then 0
else (case when exists(select user_id
from internal_profile
where internal_profile.user_id =
rpt_Wincall_Phone_TieTogether.destination_user_id)
then count(origin_user_id)end)end,'#ICC' = 0,
call_Date
from rpt_Wincall_Phone_TieTogether
group by origin_user_id,origin_org_id,destination_user_id,call_date

union all

select destination_user_id,destination_org_id,0,0,0,0,0,
'#ICC' = case when Count(destination_user_id)
is null then 0
else Count(destination_user_id)
end,call_date
from rpt_Wincall_Phone_TieTogetherIncoming
where origin_user_id is not null
group by destination_user_id,destination_org_id,call_date

--

Run this query against the db. If there is a binding error, the error message should specify the item and line num of it's orgin. From that point it'll be easy to fix.
Go to Top of Page
   

- Advertisement -