im using Sybase ASE database and i used the sql below to create a view in database:
create view dbo.vb_user_list (db_name, user_email, user_sex) as
select 'db01' ,
email,
sex
from db01.dbo.emp_hdr
where enable = 1
union
select 'db02' ,
email,
sex
from db02.dbo.emp_hdr
where enable = 1
this view show all user from db01 and db02, and it works.
but when i want to alter this view to show user from db03 also, i make a sql like below:
alter view dbo.vb_user_list (db_name, user_email, user_sex) as
select 'db01' ,
email,
sex
from db01.dbo.emp_hdr
where enable = 1
union
select 'db02' ,
email,
sex
from db02.dbo.emp_hdr
where enable = 1
union
select 'db03' ,
email,
sex
from db03.dbo.emp_hdr
where enable = 1
but its with below error message:
[ALTER - 0 rows, 0.002 secs] [Code: 102, SQL State: 37000] Incorrect syntax near '('.
i don't understand why, can anybody help?
You haven't stated your ASE version so there are a couple answers:
for ASE versions up to 15.7, you need to drop and then (re)create the proc; you'll need to make sure you grab a copy of your permissions and any auditing settings before you drop the view as these settings will also need to be recreated once the view has been recreated
for ASE 16.x, you can use the create or replace view
command; while this is basically the same as drop view
+ create view
, the one benefit is that any settings (eg, permissions, auditing settings) will remain in place