DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Guillermo Guest

    problem with stored procedure


    I'm starting in sp programming, i've got an error when i tried to save this

    Create Procedure SP_BorradocCh
    @soc_codigo int
    As
    DECLARE nros_internos CURSOR FOR SELECT che_nroint,che_escliente FROM
    cheque WHERE che_codsoc = @soc_codigo
    OPEN nros_internos
    FETCH NEXT FROM nros_internos
    WHILE @@fetch_status = 0
    BEGIN
    IF nros_internos.che_escliente = 1
    DELETE FROM chequecliente WHERE chc_nroint =
    nros_internos.che_nroint
    ELSE
    DELETE FROM chequenocliente WHERE chn_nroint =
    nros_internos.che_nroint
    DELETE FROM cheque WHERE che_nroint =
    nros_internos.che_nroint
    FETCH NEXT FROM nros_internos
    END
    CLOSE nros_internos
    DEALLOCATE nros_internos

    is the code right written? it says that has a problem with nros_Internos.
    Thanks.

  2. #2
    DaveSatz Guest

    Re: problem with stored procedure

    For your purposes you need to fetch che_nroint,che_escliente into variables
    see- BOL under FETCH (T-SQL) and look at B. Use FETCH to store values in
    variables


    --
    HTH,
    David Satz
    Principal Software Engineer
    Hyperion Solutions
    ->Using SQL Server 7.0 SP3/6.5 SP5a/Cold Fusion 4.5.1 SP2/VSS
    (Please reply to group only - emails answered rarely)
    -----------------------------------------------------------------

    "Guillermo" <polonskyg@yahoo.com> wrote in message
    news:3b0d46e4$1@news.devx.com...
    >
    > I'm starting in sp programming, i've got an error when i tried to save

    this
    >
    > Create Procedure SP_BorradocCh
    > @soc_codigo int
    > As
    > DECLARE nros_internos CURSOR FOR SELECT che_nroint,che_escliente FROM
    > cheque WHERE che_codsoc = @soc_codigo
    > OPEN nros_internos
    > FETCH NEXT FROM nros_internos
    > WHILE @@fetch_status = 0
    > BEGIN
    > IF nros_internos.che_escliente = 1
    > DELETE FROM chequecliente WHERE chc_nroint =
    >

    nros_internos.che_nroint
    > ELSE
    > DELETE FROM chequenocliente WHERE chn_nroint =
    >

    nros_internos.che_nroint
    > DELETE FROM cheque WHERE che_nroint =
    >

    nros_internos.che_nroint
    > FETCH NEXT FROM nros_internos
    > END
    > CLOSE nros_internos
    > DEALLOCATE nros_internos
    >
    > is the code right written? it says that has a problem with nros_Internos.
    > Thanks.




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links