stored-procedures

Return DataTable based on boolean param

Hi All, I have a table that has a field, "IsActive," that indicates whether a record has been "deleted" or not. Currently, I retrieve this info like so: public DataTable GetContractors(bool IsActive) { SqlParameter paramIsActive = new SqlParameter("@IsActive", SqlDbType.Bit); paramIsActive.Value = IsActive; ...

Testing Stored Procedures with MySQL

What is the best way to test MySQL stored procedures? How do you test stored procedures with output parameters in the MySql GUI? ...

Stored procedure search using entity framework

Hi everyone. I want to implement a search logic that I have seen and use. It works like this: There is stored procedure that is loaded in entity framework and it is used as a method in C#, it takes parameters in order to perform search. That method is returning list of views (DB View). The views in list have just some of the properti...

Is nHibernate intended to replace database objects?

I've not yet found a clear answer to this and to clarify: With nHibernate and SQL server are you expected to disregard or migrate your business logic stored in your stored procedures, views and triggers into HQL or application code? ...

Issue calling a MySQL stored procedure (with params) via a linked server (SQL Server 2005) using OPENQUERY syntax

Hello, I'm having issues when trying to call a MySQL (5.0.77) stored procedure with parameters, via a linked server (SQL Server 2005) using the OPENQUERY syntax. The MySQL stored procedure returns a result set, and when I use the 'EXEC ... AT ...' syntax the call works fine, e.g... EXEC('CALL my_stored_proc(''2009-10-07'',''2009-10-07...

Limit data manipulation from user only through application layer for multi-database solution

Hello, I'm starting the development of a new software that must be compliant to SQL Server (2005 and above), Oracle (10r2 and above) and Sybase (12.5 and above). I'm planning on implementing the database abstraction using stored procedures, so I can use more performatic code implementing database specific approaches for each case. I pla...

MySQL call a stored procedure every x minutes

Is there a way in MySQL to call a stored procedure from within SQL every x minutes? I want to use this in a session-environment, where the database keeps track of all the sessions and automatically deletes sessions older than x minutes. ...

mssql_bind empty string converting to NULL

I am currently using SQL Server 2000 Stored Procedures with PHP. Following the PHP doc, I use mssql_bind to assign value of parameters and then execute the Stored Procedure. The problem is that I got this bug which prevents me to bind empty strings to parameters (they are converted to NULL when the Stored Proc gets called) I dont't wan...

SQL select groups of distinct items in prepared statement?

I have a batch job that I run on a table which I'm sure I could write as a prepared statement. Currently it's all in Java and no doubt less efficient than it could be. For a table like so: CREATE TABLE thing ( `tag` varchar, `document` varchar, `weight` float, ) I want to create a new table that contains the top N entries for ev...

Stored Procedure Usage in Adobe LiveCycle ES

We have a number of stored procedures in production that we would like to use with LC. I reviewed the JDBC types and I don't see any way to get LC to accept the results of a call to a stored procedure, the stored procedure service only has an output for the number of rows affected. In fact the only JDBC service I see that even handles ...

SQL Server: Concatenating WHERE Clauses. Seeking Appropriate Pattern

I want to take a poorly designed SQL statement that's embedded in C# code and rewrite it as a stored procedure (presumably), and am looking for an appropriate means to address the following pattern: sql = "SELECT <whatever> FROM <table> WHERE 1=1"; if ( someCodition.HasValue ) { sql += " AND <some-field> = " + someCondition.Value; ...

Throwing specific error messages in PLSQL Oracle...catching in hibernate?

Is it possible to throw a specific error message in a PL/SQL oracle stored procedure and catch it in Hibernate when it gets invoked? ...

C#/SQL Get all Stored Procedures and their Code

How can I obtain all stored procedures and their code from SQL Server? I need to show data that is similar to what SQL Server Management Studio shows, incl. allowing to browse through SP's with code, tables and indexes. Any hints on how to get this information out of SQL Server? P.S., I'm using C#. ...

Calling a store procedure with nHibernate

How do you call a stored procedure with nHibernate? Specifically there are two cases where I am using store procedures: to return a scalar value and to return a set of results mapped to entities. ...

Why does stored procedure invalidate SQL Cache Dependency?

After many hours, I finally realize that I am working correctly with the Cache object in my ASP.NET application but my stored procedures stops it from working correctly. This stored procedure works correctly: CREATE PROCEDURE [dbo].[ListLanguages] @Page INT = 1, @ItemsPerPage INT = 10, @OrderBy NVARCHAR (100) = 'ID', @OrderDirection NV...

Using Same Stored Procedure for Both Insert and Update in Entity Framework

I have a stored procedure that does both the insert and the update in one fell swoop (if the id == 0 then it's an insert, otherwise, update). I'd love to use this for both the insert and the update methods in Entity Framework, but this isn't looking feasible. Am I correct that I'll have to split the methods into two different stored proc...

How do I determine if I have execute permissions on a DB programatically?

I have a Windows Service that requires execute permissions on a DB. On start up I check to see if I can connect to the DB and stop the service if I can't. I also want to do a check to see if I can execute a stored procedure using that connection. Is there a way to do that without actually attempting to execute a sproc and looking at the ...

External stored procedure on IBM i

I am trying to create an external stored procedure on an IBM i (V5R4), but I'm getting an error when I try to run it. All I want to do is call an RPG program, without passing any parameters or worrying about returning any data. Sorry, I'm not an RPG programmer or an expert on IBM i, so I could be missing something very simple. The SQL ...

Updating a Field based on Values in Two Other Fields

I have a database table containing fields RACE, ETHNICITY and ETH. I need to evaluate RACE and ETHNICITY fields and populate ETH using a series of cases: if Race = W and Ethncity = 1 then ETH = Caucasian etc. Can someone advise me on the best way to structure a stored procedure to accomplish this? ...

Log error messages in Oracle stored procedure

Hi, We plan to configure a stored procedure to run as a batch job daily using Oracle DBMS scheduler package. We would like to know what would be the best way to log an error message when there is an error occured. Is logging to a temporary table an option? or is there a better option. Thanks in advance. ...