Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

CRUD generator Expand / Collapse
Author
Message
Posted Saturday, June 27, 2009 3:23 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, September 5, 2014 5:24 PM
Points: 4, Visits: 58
Comments posted to this topic are about the item CRUD generator
Post #743178
Posted Monday, July 6, 2009 12:22 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, March 9, 2011 8:21 AM
Points: 1, Visits: 20
Getting an error:

declare @TableName varchar(100)
,@SQL1 varchar(2000)
,@SQL2 varchar(2000)
,@SQL3 varchar(2000)
,@SQL4 varchar(2000)
,@SQL5 varchar(2000)
,@SQL6 varchar(2000)
,@Parameters int
,@TypeOfCrud int--1 = Insert, 2 = Update, 3 = Read, 4 = Delete, 5 = All

select @TableName = 'CUSTOMER_ORDER' --<,@Parameters = 0 --<< If using parameters for the insert statement then use 1 if not then use 0
,@TypeOfCrud = 3

As you can see, I chose a table from my database, "read" type, and get I get this error at the exec(@SQL1) statement and exec(@SQL@) statements:

Msg 197, Level 15, State 1, Line 235
EXECUTE cannot be used as a source when inserting into a table variable.
Msg 197, Level 15, State 1, Line 241
EXECUTE cannot be used as a source when inserting into a table variable.


if isnull(@SQL1, '') <> ''
begin
insert into @FinalSelect([--SelectText])
exec (@SQL1)

if isnull(@SQL2, '') <> ''
begin
insert into @FinalSelect([--SelectText])
exec(@SQL2)
end
Post #747946
Posted Monday, July 6, 2009 2:59 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, September 5, 2014 5:24 PM
Points: 4, Visits: 58
What version of SQL Server are you using?

This was coded on SQL Server 2005.

I never encountered this error; however, I would simply change the @FinalSelect table variable to a temp table #FinalSelect and try that.

Thanks,
Ryan Foote
Post #748076
Posted Monday, July 6, 2009 5:01 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, December 12, 2014 9:23 AM
Points: 206, Visits: 402
Thanks for the contribution. Most of the time I encourage the use of object abstraction tools like mygeneration, entity space, etc., but its always nice to have some tools available.

The more you are prepared, the less you need it.
Post #748182
Posted Monday, July 6, 2009 5:32 PM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 4:12 PM
Points: 758, Visits: 1,031
While I like the idea of using code generators for tasks like this, I do have an issue with the approach of recommending a row-by-row interface.

Also, the typical CRUD interface is at a table level, rather than at an "object" level. For example, you will have one part of the interface for the invoice_header, and another for the invoice_line. To me a better approach is to create an interface that takes many invoices, and have the database code written at that level. It can then use set-based logic.

I don't believe that database interfaces require a row-by-row approach, or that they have to be formed around the physical tables. So use with caution.
Post #748192
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse