안녕하세요.
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 해서 출력하는 로직이 들어 있습니다.
고수 분들의 답변 부탁드려 봅니다. |