If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > ADO, MSSQL2000 and changes in view

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-02, 04:51
paan-cha paan-cha is offline
Registered User
 
Join Date: Aug 2002
Posts: 2
Question ADO, MSSQL2000 and changes in view

Hello all,

I work with MSSQL2000 and Delphi. I want to insert new values in the Master_Detail_VW (see script below) using the ADO components. I tried something like this:

var
ADOQuery1:TAdoQuery;
begin
.
.
.
ADOQuery1.SQL.Append('select * from Master_Detail_VW');
ADOQuery1.Insert;
ADOQuery1.FieldByName('Id').AsInteger = '3';
ADOQuery1.FieldByName('Master_Name').AsString = 'c';
ADOQuery1.FieldByName('Detail_Name').AsString = 'd';
ADOQuery1.Post;
.
.
.
end;

AdoQuery raised the EOleException 'Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available' on Post.
I tried the same with BDE and had no problems.

Can anybody HELP ME?
Thanks.
Paan-cha


/* My db */


create table Master (Id int, Name char(1))
go

insert into Master (Id, Name) values (1, 'A')
go

insert into MAster (Id, Name) values (2, 'B')
go

create table Detail (Master int, Name char(1))
go

insert into Detail (Master, Name) values (1, 'A')
go

create view Master_Detail_VW with schemabinding
as
select Master.Id, nullif(Master.Name, null) Master_Name, nullif(Detail.Name, null) Detail_Name
from dbo.Master Master
left outer join dbo.Detail Detail on Master.Id = Detail.Master
go

create trigger Master_Detail_VW_I on Master_Detail_VW
instead of insert
as
begin
if exists (select 1
from inserted)
begin
insert into Master
(Id, Name)
select Id, Master_Name
from Inserted

insert into Detail
(Master, Name)
select Id, Detail_Name
from Inserted
end
end
go


/*
insert into Master_Detail_VW
(Id, Master_Name, Detail_Name)
values
(3, 'c', 'd')
*/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On