execute ms-sql stored proc

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
nait
User
Posts: 47

execute ms-sql stored proc

Post by nait »

is it possible to execute an ms sql stored procedured from a button click?

if this is not possible is it possible to execute a ms-sql stored procedure after a row is updated.

the procedure will perform an insert into a table using parameters from the row, but this should run on sql server i guess

for example i created a view that does a sort of dummy update but executes the stored procedure.

any help would be appreciated

nait


nait
User
Posts: 47

Post by nait »

i have put the following code in

function Row_Updated($rsold, &$rsnew) {

//execute my stored proc
ew_Execute("usp_TAMADMIN");

}

after pressing save i get server error 500


mobhar
User
Posts: 11721

Post by mobhar »

Is your Stored Procedure contains parameter?


nait
User
Posts: 47

Post by nait »

hi thanks for you reply

its has two parameters, but i have also tried to execute a stored proc with no parameters but it does not run


mobhar
User
Posts: 11721

Post by mobhar »

Make sure you have already added () characters after the SP's name.


nait
User
Posts: 47

Post by nait »

HI adding () has made no difference when i update the row after update i get the server 500 error


mobhar
User
Posts: 11721

Post by mobhar »

Assume you are using v2017, and your SP name is "MySP" and it has no parameter, then try this:

global $UserTableConn;
$rs = $UserTableConn->Execute("MySP()");
if ($rs->RecordCount()==0) {
$this->setSuccessMessage("SP is OK");
} else {
$this->setFailureMessage("SP not OK");
}


nait
User
Posts: 47

Post by nait »

hi apologies im using v12


mobhar
User
Posts: 11721

Post by mobhar »

Then try this:

global $conn;
$rs = $conn->Execute("MySP()");
if ($rs->RecordCount()==0) {
$this->setSuccessMessage("SP is OK");
} else {
$this->setFailureMessage("SP not OK");
}


Post Reply