Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Perl: разработка для Web > Что за ошибка такая???


Автор: forumuser 15.5.2003, 11:04
Есть скрипт работающи й с базой данных. После завершения и вывода результата ниже пишется следующее:
DBI:biggrin.gifb=HASH(0x197bd94)->disconnect invalidates 2 active statement handles (either destroy statement handles or call finish on them before disconnecting) at C:\Program Files\sambar51\cgi-bin\traffic.pl line 31.

Строка конекта такая:
my $dbh = DBI->connect("DBI:mysql:database=traffic;host=xxx.xxx.xxx.xxx","tynnfgtn", "fgynjfyfgn") || die $DBI::errstr;

Дисконект: $dbh -> disconnect();

В чем проблема? Что неправильноconfused.gif


Автор: acp 15.5.2003, 11:26
Проблема, по моему, в незнании английского языка.

Автор: forumuser 15.5.2003, 11:30
Умничайте в другом месте, товарищ acp.
Всем остальным: в интернете вычитал кое что. Оказывается для дескриптора выражения нужно выполнять функцию finish. Например $ID-> finish(); а уже потом disconnect.

Автор: HalkaR 15.5.2003, 12:42
Попробуй.
Код
$dbh = DBI->connect("DBI:mysql:mysql:localhost:3306", 'root', '', {RaiseError => 1}) or die "$DBI::errstr\n";
$dbh->disconnect or die "$DBI::errstr\n";

Автор: acp 15.5.2003, 13:57
Извини, forumuser, но я не умничаю. Я так сказал потому, что причина ошибки и её решение написаны у тебя, вот
Цитата

disconnect invalidates 2 active statement handles (either destroy statement handles or call finish on them before disconnecting)


Цитата
в интернете вычитал кое что. Оказывается для дескриптора выражения нужно выполнять функцию finish. Например $ID-> finish(); а уже потом disconnect.

Собственно, это можно было вычитать, выполнив perldoc для модуля DBI.

Цитирую для тебя
Цитата

finish

  $rc  = $sth->finish;
Indicates that no more data will be fetched from this statement handle before it is either executed again or destroyed. The finish method is rarely needed, but can sometimes be helpful in very specific situations to allow the server to free up resources (such as sort buffers).

When all the data has been fetched from a SELECT statement, the driver should automatically call finish for you. So you should not normally need to call it explicitly except when you know that you've not fetched all the data from a statement handle. The most common example is when you only want to fetch one row, but in that case the selectrow_* methods may be better anyway. Adding calls to finish after each fetch loop is a common mistake, don't do it, it can mask genuine problems like uncaught fetch errors.

Consider a query like:

  SELECT foo FROM table WHERE bar=? ORDER BY foo
where you want to select just the first (smallest) ``foo'' value from a very large table. When executed, the database server will have to use temporary buffer space to store the sorted rows. If, after executing the handle and selecting one row, the handle won't be re-executed for some time and won't be destroyed, the finish method can be used to tell the server that the buffer space can be freed.

Calling finish resets the Active attribute for the statement. It may also make some statement handle attributes (such as NAME and TYPE) unavailable if they have not already been accessed (and thus cached).

The finish method does not affect the transaction status of the database connection. It has nothing to do with transactions. It's mostly an internal ``housekeeping'' method that is rarely needed. See also disconnect and the Active attribute.

The finish method should have been called cancel_select.


PS: я мог бы написать "RTFM", и был бы полностью прав...

Автор: forumuser 15.5.2003, 16:42
Дык, и я согласен, что не владею английским в полной мере. Так потому и задавал вопрос в форуме! То что есть подробное описание в RTFM, это и так понятно, но сидеть со словарем времени нет, а перевод в translate.ru нисколько не прояснил ситуацию.

Автор: acp 15.5.2003, 17:59
Понятно...

Вообщем, для твоего случая, ты правильно нашёл в интернете, вызывай для всех своих "statement handles" функцию finish перед дисконнектом. В результате эта ошибка должна прекратиться...

PS: переведу твоё сообщение об ошибке
Цитата

Вызов функции disconnect уничтожает 2 активных "statement hadles" (для устранения этой проблемы или уничтожайте эти "statement handles" или вызывайте для них метод finish)


PPS: зашёл на translate.ru и перевёл вышеуказанную цитату (ту что из DBI), действительно забавно smile.gif Если уж и переводить подобное, то не на translate.ru (где направление перевода только общее), а домашним Промтом (где можно выставить направление перевода "Информатика"). Явно будет лучше...

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)