stored-procedures

How to determine if a parameter value was passed to a stored procedure

别说谁变了你拦得住时间么 提交于 2021-01-27 05:24:35
问题 I want to create a stored procedure (in SQL Server 2008 R2) that will update a record in a table based on the table's PK. The stored proc will have, for example, four parameters: @ID int, @Name nvarchar(50), @Email nvarchar(80), @Phone nvarchar(20) How can I determine if the caller of the stored proc passes a NULL value for one (or more) of the parameters vs. if the caller didn't pass anything for one (or more) of the parameters? C# caller example: Caller specifies NULL for @Phone : using

How to determine if a parameter value was passed to a stored procedure

二次信任 提交于 2021-01-27 05:24:29
问题 I want to create a stored procedure (in SQL Server 2008 R2) that will update a record in a table based on the table's PK. The stored proc will have, for example, four parameters: @ID int, @Name nvarchar(50), @Email nvarchar(80), @Phone nvarchar(20) How can I determine if the caller of the stored proc passes a NULL value for one (or more) of the parameters vs. if the caller didn't pass anything for one (or more) of the parameters? C# caller example: Caller specifies NULL for @Phone : using

How to get multi table results of an stored procedure using SimpleJDBCCall in spring?

安稳与你 提交于 2021-01-24 13:22:14
问题 I'm implementing a Spring + MSSQL Server 2008 application. I use SimpleJDBCCall API to execute stored procedures and retrieve results. For stored procedures with mono table results, it works fine, but I don't know how to use it for procedures with multi table results. Sample procedure body: multi table results SELECT * FROM TABLE1 SELECT * FROM TABLE2 回答1: I was most ignorant, it does in fact work! You can specify both resultsets, with each its own mapper. In code it looks like this:

How to get multi table results of an stored procedure using SimpleJDBCCall in spring?

≡放荡痞女 提交于 2021-01-24 13:20:53
问题 I'm implementing a Spring + MSSQL Server 2008 application. I use SimpleJDBCCall API to execute stored procedures and retrieve results. For stored procedures with mono table results, it works fine, but I don't know how to use it for procedures with multi table results. Sample procedure body: multi table results SELECT * FROM TABLE1 SELECT * FROM TABLE2 回答1: I was most ignorant, it does in fact work! You can specify both resultsets, with each its own mapper. In code it looks like this:

How to get multi table results of an stored procedure using SimpleJDBCCall in spring?

戏子无情 提交于 2021-01-24 13:19:09
问题 I'm implementing a Spring + MSSQL Server 2008 application. I use SimpleJDBCCall API to execute stored procedures and retrieve results. For stored procedures with mono table results, it works fine, but I don't know how to use it for procedures with multi table results. Sample procedure body: multi table results SELECT * FROM TABLE1 SELECT * FROM TABLE2 回答1: I was most ignorant, it does in fact work! You can specify both resultsets, with each its own mapper. In code it looks like this:

MySQL stored procedure cursor for prepared statements

这一生的挚爱 提交于 2021-01-20 18:15:35
问题 I have a two tables: people_en: id, name people_es: id, name (please, dont bother about normalization. the design is normalized. the tables are much more complex than this but this is just a way to simplify my problem). I then have a stored procedure: CREATE PROCEDURE myproc(lang char(2)) BEGIN set @select = concat('SELECT * FROM ', lang, ' limit 3'); PREPARE stm FROM @select; EXECUTE stm; DEALLOCATE PREPARE stm; SET @cnt = FOUND_ROWS(); SELECT @cnt; IF @cnt = 3 THEN //Here I need to loop

How to MAP select stored procedure in Entity Framework 6 code-first approach?

懵懂的女人 提交于 2021-01-18 04:47:08
问题 For example when we write protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<tblError>().MapToStoredProcedures(); } Then it will create 3 stored procedures in the database with the names of tblError_Delete , tblError_Insert , tblError_Update My question is about tblError_Select : how to map a stored procedure that is used to execute select queries? I want EF to be generate tblError_Select along with preceding 3 stored procedures. I want to do CRUD

Update hierarchy after deletion of row

≡放荡痞女 提交于 2021-01-07 06:21:38
问题 I have a table that contains tree-like data (hierarchic design). Here is a small sample: +----+----------+-----------+-------+----------+---------+ | ID | ParentID | Hierarchy | Order | FullPath | Project | +----+----------+-----------+-------+----------+---------+ | 1 | null | 1 | 1 | 1 | 1 | | 2 | null | 2 | 2 | 2 | 1 | | 3 | 1 | 1.1 | 1 | 1-3 | 1 | | 4 | 1 | 1.2 | 2 | 1-4 | 1 | | 5 | 4 | 1.2.1 | 1 | 1-4-5 | 1 | | 6 | 2 | 2.1 | 1 | 2-6 | 1 | | 7 | null | 3 | 1 | 1 | 2 | +----+----------+---

Update hierarchy after deletion of row

隐身守侯 提交于 2021-01-07 06:21:17
问题 I have a table that contains tree-like data (hierarchic design). Here is a small sample: +----+----------+-----------+-------+----------+---------+ | ID | ParentID | Hierarchy | Order | FullPath | Project | +----+----------+-----------+-------+----------+---------+ | 1 | null | 1 | 1 | 1 | 1 | | 2 | null | 2 | 2 | 2 | 1 | | 3 | 1 | 1.1 | 1 | 1-3 | 1 | | 4 | 1 | 1.2 | 2 | 1-4 | 1 | | 5 | 4 | 1.2.1 | 1 | 1-4-5 | 1 | | 6 | 2 | 2.1 | 1 | 2-6 | 1 | | 7 | null | 3 | 1 | 1 | 2 | +----+----------+---

How to pass NULL to a optional parameter and it not be interpreted as a missing parameter

岁酱吖の 提交于 2021-01-07 02:47:04
问题 I have a SQL Server stored procedure that updates a large table. Because of its size, most parameters are optional. Most recommendations for setting the default of my optional parameters is to set them to NULL. However, my problem is that NULL is a legitimate update parameter value so I'm trying to figure out how to handle detect the difference between a NULL that is passed vs. a NULL that exists due to a missing optional parameter. One solution I've seen is to set the optional parameter's