redo Posted October 3, 2007 Share Posted October 3, 2007 hi...i need help...iam not used to store procedure...but my superviser want to used it...and now...i cant delete row this is my command...i used switch where when i press padam button,they will run this coding.. case 'Padam': $year = date('Y'); $month = '0'; for($i=0;$i<count($_POST['DelRow']);$i++) { $sql = "delete from call sp_del_basicdata_pembuatan(".$_POST['DelRow'][$i].")"; mysql_query($sql); } $exData = $myData->checkDataMgr($tahun);//this command used to check whether the data exist or not break; can someone help me???? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 3, 2007 Share Posted October 3, 2007 What is $_POST['DelRow']? Link to comment Share on other sites More sharing options...
redo Posted October 4, 2007 Author Share Posted October 4, 2007 What is $_POST['DelRow']?input type="checkbox" name="DelRow[]" id="DelRow[]" value="<?php echo $rekod[$i]['pb_id']?>">DelRow name of the checkbox...can u help me...i really dont understand bout store procedure... Link to comment Share on other sites More sharing options...
redo Posted October 4, 2007 Author Share Posted October 4, 2007 What is $_POST['DelRow']?input type="checkbox" name="DelRow[]" id="DelRow[]" value="<?php echo $rekod[$i]['pb_id']?>"DelRow name of the checkbox...can u help me...i really dont understand bout store procedure... Link to comment Share on other sites More sharing options...
justsomeguy Posted October 4, 2007 Share Posted October 4, 2007 Oh. You have "delete from" and then you call the sp. Just call the sp, remove the delete statement. It doesn't make sense to delete something form a stored procedure. Since "del" is in the name of the sp I assume that it will do the delete, so all you need to do is call it and pass it whatever information you need to. Link to comment Share on other sites More sharing options...
redo Posted October 5, 2007 Author Share Posted October 5, 2007 thank you...i've done what u suggest...but it seem nothing change..the data is still therei really dont know wat else to do...ive tried call the sp first then delete comand..it doesnt work .. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2007 Share Posted October 5, 2007 What is the code for the sp? Link to comment Share on other sites More sharing options...
redo Posted October 8, 2007 Author Share Posted October 8, 2007 What is the code for the sp?code?sp_del_basicdata_pembuatan(name of my store procedure)<--is this wat u want? Link to comment Share on other sites More sharing options...
Synook Posted October 8, 2007 Share Posted October 8, 2007 but what is the actual stored procedure (SP)? Think of an SP like a function, so when you write call sp_del_basicdata_pembuatan({$_POST['DelRow'][$i]}) you are telling it to execute (call) a function called sp_del_basicdata_pembuatan with the first parameter having the value of $_POST['DelRow'][$i]. So, what does the SP's code look like? Link to comment Share on other sites More sharing options...
redo Posted October 9, 2007 Author Share Posted October 9, 2007 here's the codeCREATE DEFINER=`root`@`%` PROCEDURE `sp_del_basicdata_pembuatan`(id integer)BEGINdelete from basicdata_pembuatan where pb_id=id;ENDi cant change the store procedure code coz my supervisor dont let me...so i assume his code was rite... Link to comment Share on other sites More sharing options...
Synook Posted October 9, 2007 Share Posted October 9, 2007 So, basically all this sp is doing is executing this query: delete from basicdata_pembuatan where pb_id=id So, when you type call sp_del_basicdata_pembuatan(".$_POST['DelRow'][$i].")"; You are really just executing delete from basicdata_pembuatan where pb_id={$_POST['DelRow'][$i]} Try running that query outside the sp and see whether it causes an error. Link to comment Share on other sites More sharing options...
redo Posted October 10, 2007 Author Share Posted October 10, 2007 i already try it..and it work when i execute delete from basicdata_pembuatan where pb_id={$_POST['DelRow'][$i]} so what is the problem??huhumaybe my call function wrong??? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 10, 2007 Share Posted October 10, 2007 If your supervisor is requiring that you use the stored procedures that he writes, then he should be telling you what you need to do to use them. According to my experience with stored procedures, this is correct:call sp_del_basicdata_pembuatan({$_POST['DelRow'][$i]})If that's not working, you should ask your supervisor why. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.