|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, February 13, 2013 11:01 AM
Points: 4,
Visits: 57
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, March 09, 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
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, February 13, 2013 11:01 AM
Points: 4,
Visits: 57
|
|
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
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, January 16, 2013 7:40 AM
Points: 136,
Visits: 259
|
|
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.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Friday, March 22, 2013 11:49 AM
Points: 945,
Visits: 998
|
|
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.
|
|
|
|