SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Binding Error
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

humanpuck
Yak Posting Veteran

94 Posts

Posted - 08/08/2006 :  10:32:51  Show Profile  Reply with Quote
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




Edited by - humanpuck on 08/08/2006 10:34:47

TG
Flowing Fount of Yak Knowledge

USA
6062 Posts

Posted - 08/08/2006 :  14:08:15  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
1222 Posts

Posted - 08/08/2006 :  22:08:32  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000