FETCH
        [ [ NEXT | PRIOR | FIRST | LAST
                | ABSOLUTE { n | @nvar }
                | RELATIVE { n | @nvar }
            ] 
            FROM
        ] 
{ { [ GLOBAL ] cursor_name } | @cursor_variable_name } 
[ INTO @variable_name [ ,...n ] ]

解决方案 »

  1.   

    FETCH [ [ NEXT | PRIOR | FIRST | LAST ] FROM ] cursor_name [USING DESCRIPTOR :sqlda_struct | INTO :hvar [,...]]cursor_nameIs a previously declared and opened cursor. sqlda_structIs an output SQLDA data structure that was previously populated by the DESCRIBE statement and that contains output value addresses. This option is used only with a cursor declared by prepared SELECT statements. (SELECT statements are prepared by using the PREPARE statement.)hvarIs one or more host variables to receive the data.
    The USING DESCRIPTOR :sqlda_struct option can be used only with a dynamically defined cursor. The INTO :hvar option can be used with either a dynamic or static cursor.Examples
    EXEC SQL DECLARE C1 CURSOR FOR
       SELECT au_fname, au_lname FROM authors FOR BROWSE;
    EXEC SQL OPEN C1;
    while (SQLCODE == 0)
    {
       EXEC SQL FETCH C1 INTO :fname, :lname;
    }
      

  2.   

    FETCH [ [ NEXT | PRIOR | FIRST | LAST ] FROM ] cursor_name [USING DESCRIPTOR :sqlda_struct | INTO :hvar [,...]]cursor_nameIs a previously declared and opened cursor. sqlda_structIs an output SQLDA data structure that was previously populated by the DESCRIBE statement and that contains output value addresses. This option is used only with a cursor declared by prepared SELECT statements. (SELECT statements are prepared by using the PREPARE statement.)hvarIs one or more host variables to receive the data.
    The USING DESCRIPTOR :sqlda_struct option can be used only with a dynamically defined cursor. The INTO :hvar option can be used with either a dynamic or static cursor.Examples
    EXEC SQL DECLARE C1 CURSOR FOR
       SELECT au_fname, au_lname FROM authors FOR BROWSE;
    EXEC SQL OPEN C1;
    while (SQLCODE == 0)
    {
       EXEC SQL FETCH C1 INTO :fname, :lname;
    }