Jump to content

store procedure


redo
 Share

Recommended Posts

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

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

:) 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

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...