database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Q&A 29715 게시물 읽기
No. 29715
프로시져 실행후, 다시 쿼리 실행하는 경우 에러 발생 (Commands out of sync; you can't run this command now)
작성자
지종현(whdgus15)
작성일
2010-07-01 19:51
조회수
7,365

안녕하세요.

PHP작업중 에러가 생겨 문의 드립니다.

우선 아래와 같은 코드는 정상적으로 작동을 합니다.
---------------------------------------------------------------------------------------------------------
$sql = 'select 111';
$result = mysql_query($sql);
$numRows = mysql_num_rows($result);
if ($numRows>0) {
    echo mysql_result($result, 0, 0);

    $sql2 = 'select 222';
    $result2 = mysql_query($sql2);

    if (!$result2) {
        $message  = '* Err : ' . mysql_error() . "\n";
        die($message);
    }
    $numRows2 = mysql_num_rows($result2);
    if ($numRows2>0) {
        echo mysql_result($result2, 0, 0);
    }
}
---------------------------------------------------------------------------------------------------------
(결과 : 111222)

제가 원하는건.. 처음 프로시져를 실행후, 받아온 값을 가지고 다시 2차 쿼리를 실행하는 로직 입니다.. 아래와 같은 코드가 에러가 납니다.
---------------------------------------------------------------------------------------------------------
$sql = 'call sp_stat_day_new(\'' . $st_sdate_re . '\',\'' . $st_edate_re . '\');';
$result = mysql_query($sql);
$numRows = mysql_num_rows($result);
if ($numRows>0) {
    echo mysql_result($result, 0, 0);

    $sql2 = 'select 222';
    $result2 = mysql_query($sql2);

    if (!$result2) {
        $message  = '* Err : ' . mysql_error() . "\n";
        die($message);
    }
    $numRows2 = mysql_num_rows($result2);
    if ($numRows2>0) {
        echo mysql_result($result2, 0, 0);
    }
}
---------------------------------------------------------------------------------------------------------
실행하면...
Commands out of sync; you can't run this command now
위와 같은 에러 메시지가 보여집니다.

프로시져 안에서 특별한 내용은 없으며, 임시테이블 생성을 통하여..
결국에는 임시테이블의 값을 select 해서 출력하는 로직이 들어 있습니다.

고수 분들의 답변 부탁드려 봅니다.

[Top]
No.
제목
작성자
작성일
조회
29718php 에서 ip주소로 접속하게 하면 오류발생..
이기석
2010-07-05
7220
29717mysql bin로그 삭제 [1]
김하림
2010-07-05
7064
29716mysql 에러 질문 [1]
돌머리
2010-07-02
8374
29715프로시져 실행후, 다시 쿼리 실행하는 경우 에러 발생 (Commands out of sync; you can't run this command now)
지종현
2010-07-01
7365
29714MySQL Lock 발생시 해결 방법 [1]
이철수
2010-06-30
7154
29713order by 시 속도 단축 방법 질문 드립니다. [1]
권기혁
2010-06-29
6926
29712오라클의 user_source 함수와 같은것 찾아주세요..
다크라이온
2010-06-29
6901
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.023초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다