CRUD generator

  • foote.ryan

    SSC Enthusiast

    Points: 120

    Comments posted to this topic are about the item CRUD generator

  • rlarsen

    SSC Journeyman

    Points: 79

    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' --<<Enter the name of the table

    ,@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

  • foote.ryan

    SSC Enthusiast

    Points: 120

    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

  • Andrew..Peterson

    SSCertifiable

    Points: 6719

    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.

  • Bruce W Cassidy

    SSChampion

    Points: 12607

    [font="Verdana"]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.

    [/font]

  • akljfhnlaflkj

    SSC Guru

    Points: 76202

    Thanks for the script.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply