#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    2
    Rep Power
    0

    Declare cursor problem


    Hey,

    Recently Iím using Firebird, great database only little in documentation. At the moment Iím using the IB 6.0 documentation from the firebird site, only I think these are outdated? Some statements just donít seem to work in Firebird 1.5, like some of the stored procedures Iíve found in these books. For example: ďSet Term ^;Ē and more important I donít seem to get cursor statements working in Firebird (not even when using the same example)

    Could someone tell me what Iím doing wrong?

    Hesder


    For example a cursor statement Iíve tried to convert from oracle to Firebird 1.5 :

    CREATE PROCEDURE get_records_10monsteroverzicht(
    session_id VARCHAR(25),
    group_name VARCHAR(25),
    date_from VARCHAR(25)
    ) AS


    BEGIN

    declare c_template CURSOR for
    select tmplt_name
    from ip_smpl_grp_DETAIL
    where smpl_grp_name = group_name
    ORDER BY tmplt_name;

    ...how to use cursor in firebird?...

    END
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    250
    Rep Power
    14
    Originally Posted by Hesder
    Some statements just donít seem to work in Firebird 1.5, like some of the stored procedures Iíve found in these books. For example: ďSet Term ^;Ē and
    SET TERM is only used by client tools. What are you using to connect and run your scripts?
    Originally Posted by Hesder
    more important I donít seem to get cursor statements working in Firebird (not even when using the same example)

    Could someone tell me what Iím doing wrong?
    For example a cursor statement Iíve tried to convert from oracle to Firebird 1.5 :

    CREATE PROCEDURE get_records_10monsteroverzicht(
    session_id VARCHAR(25),
    group_name VARCHAR(25),
    date_from VARCHAR(25)
    ) AS


    BEGIN

    declare c_template CURSOR for
    select tmplt_name
    from ip_smpl_grp_DETAIL
    where smpl_grp_name = group_name
    ORDER BY tmplt_name;

    ...how to use cursor in firebird?...

    END
    Firebird doesn't support a CURSOR, it does support cycling through resultsets via a FOR SELECT construct:

    FOR SELECT tmplt_name
    from ip_smpl_grp_DETAIL
    where smpl_grp_name = group_name
    ORDER BY tmplt_name
    INTO :variable_name
    DO ... loop ...



    With regards,

    Martijn Tonies
    Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL Server.
    Upscene Productions
    http://www.upscene.com
    Martijn Tonies
    Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle
    Upscene Productions
    http://www.upscene.com

IMN logo majestic logo threadwatch logo seochat tools logo