Windos Azure Mobile Service: Executing a Insert Stored Procedure in the data trigger -


i need call stored procedure when insert script trigger called. idea use stored procedure insert rows in 3 tables, including original table.

i have following tables - cars - makers - models

the stored procedure receives car's data, maker's name , model's name. sp looks in makers , models table , insert new record if not found.

this script trigger code:

function insert(item, user, request) {      var params = [item.name, item.year, item.maker_name, item.model]; var sql = "exec mycars.sp_insert_car ?, ?, ?, ?"; mssql.query(sql, params, {     success: function(results) {         request.respond(statuscodes.ok,{              results: results,             count: 1         });            }         }); } 

because sp_insert_car inserts row in cars table, trigger called again. weird thing is called when new maker or model inserted.

is there way disable second time trigger called?

also, sp has output parameter returns new car id. there way output parameter?

i appreciate can provide

i think want run request.execute first data original table. in success function run stored procedure add data, if missing, other tables. along lines of...

function insert(item, user, request) {     request.execute({         success: function() {             var params = [item.name, item.year, item.maker_name, item.model];             var sql = "mycars.sp_insert_car ?, ?, ?, ?";             mssql.query(sql, params, {                 success: function(results) {                     request.respond(statuscodes.ok,{                          results: results,                         count: 1                     });                 }             });         }     }); } 

this lets grab id of newly inserted row in original table, item.id, use passed-in parameter stored procedure if need it.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -