Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Stored procedure and USING
Thu, Aug 6 2009 6:57 AMPermanent Link

gienek majonez
Hi,
There is a small procedure like this:

CREATE PROCEDURE "REPAIR"(
)
BEGIN
   DECLARE DBCursor CURSOR FOR DBStmt;
   DECLARE TableCursor CURSOR FOR TableStmt;
   DECLARE DBName VARCHAR DEFAULT '';
   DECLARE TableName VARCHAR DEFAULT '';
                                    
   DECLARE stmt STATEMENT;

   PREPARE DBStmt FROM 'SELECT "Name" FROM Configuration.Databases';
   PREPARE TableStmt FROM 'SELECT "Name" FROM ?.Information.Tables';

   OPEN DBCursor;
   FETCH FIRST FROM DBCursor (Name) INTO DBName;

   WHILE NOT EOF(DBCursor) DO

       OPEN TableCursor USING DBName;
       FETCH FIRST FROM TableCursor (Name) INTO TableName;
       WHILE NOT EOF(TableCursor) DO
         SET LOG MESSAGE TO DBName + '.' + TableName + ': repairing...';
         PREPARE stmt FROM 'REPAIR TABLE "'+DBName+'.'+TableName+'"';
         EXECUTE stmt;/**/
         SET LOG MESSAGE TO 'Done.';
 
         FETCH NEXT FROM TableCursor (Name) INTO TableName;
       END WHILE;
 
       CLOSE TableCursor;
      
     FETCH NEXT FROM DBCursor (Name) INTO DBName;
   END WHILE;

   CLOSE DBCursor;
END
//-------------------

Question:
why USING in line
 OPEN TableCursor USING DBName;
don't replace ? in TableStmt with variable DBName? Bug or feature?
When I try to execute procedure in Manager i get error #700 with message
"Expected table name but instead found ?"

best regards,
g_m
Thu, Aug 6 2009 7:36 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

gienek


Neither bug or feature just how it is. It will probably change in the future but at present ElevateDB can only replace the comparison value.

Roy Lambert [Team Elevate]
Thu, Aug 6 2009 10:53 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Gienek,

<< why USING in line
 OPEN TableCursor USING DBName;
don't replace ? in TableStmt with variable DBName? Bug or feature? >>

It's normal.  Try to think of parameters as the same as a constant value,
not a general text replacement mechanism.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image