List:MySQL on Win32« Previous MessageNext Message »
From:rdo mail list address Date:July 31 2004 12:29pm
Subject:Re: [win32] USE statement in procedure
View as plain text  
Forgot to include the table definitions:

mysql> use cd2;
Database changed
mysql> show tables;
+---------------+
| Tables_in_cd2 |
+---------------+
| table1        |
+---------------+
1 row in set (0.00 sec)

mysql> desc table1;
+--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| pos    | int(11)     | YES  |     | NULL    |       |
| title  | varchar(60) | YES  |     | NULL    |       |
| artist | varchar(22) | YES  |     | NULL    |       |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)


At 07:17 AM 7/31/2004 -0500, you wrote:
>
>Running 5.0.0-alpha-nt on a windows 2000 box.  The server is mysqld-nt.
>
>If a "USE" database statement is inside a procedure, then upon
>execution, there is an error message that says that the table referenced in
>the cursor does not exist, and the table name is preceded with a period.
>Additionally, the connection to the server is lost.
>
>Without the "USE" statement this particular procedure runs okay.
>
>After noticing a problem in another procedure, I narrowed the procedure
>down to a simpler reproducible process.
>
>C:\>mysql -u rdo
>Welcome to the MySQL monitor.  Commands end with ; or \g.
>Your MySQL connection id is 2 to server version: 5.0.0-alpha-nt
>
>Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
>
>mysql> use cd2
>Database changed
>mysql> drop procedure populater;
>Query OK, 0 rows affected (0.00 sec)
>
>mysql>
>mysql> delimiter //
>mysql> create procedure populater()
>    ->
>    -> begin
>    -> declare done int default 0;
>    -> declare continue handler for NOT FOUND set done = 1;
>    -> declare c1 cursor for select pos,title,artist
>    ->   from table1
>    ->   where pos is not null;
>    ->
>    -> use cd2;
>    -> set @x = 0;
>    -> open c1;
>    ->
>    -> set @x = 1;
>    -> close c1;
>    -> end
>    -> //
>Query OK, 0 rows affected (0.00 sec)
>
>mysql>
>mysql> delimiter ;
>mysql> call populater();
>ERROR 1146 (42S02): Table '.table1' doesn't exist
>mysql> select @x;
>ERROR 2013 (HY000): Lost connection to MySQL server during query
>mysql>
>
>

Thread
[win32] USE statement in procedurerdo mail list address31 Jul
  • Re: [win32] USE statement in procedurerdo mail list address31 Jul
  • Re: [win32] USE statement in procedureSGreen2 Aug
  • Re: [win32] USE statement in procedurerdo mail list address2 Aug
    • Re: [win32] USE statement in procedureSGreen2 Aug
    • Re: [win32] USE statement in procedurerdo mail list address2 Aug
RE: [win32] USE statement in procedurePF: MySQL2 Aug
  • RE: [win32] USE statement in procedurerdo mail list address2 Aug