stored-procedures

How to pass array and other type of variable to oracle stored procedure?

I want to pass one array and one integer variable to a oracle stored procedure from c#.net application. I can pass both parameter as array but can't pass two different type of variable. Is there any solution where I can pass array and any other type of variable together? ...

[SQL Server Procedure] Cannot user "Select TOP @Count ..."

I am creating a procedure something like below. it works fine when there is no "TOP @Count", or it works fine when i put a concrete vaule "TOP 100" . So why i cannot pass the value there??? how can i walk around it??? SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE MyProcedure @Count int = 100 AS BEGIN SELE...

Calling a stored proc that returns a recordset from within a stored proc

Working in SQL Server 2005, I have a stored procedure that inserts a record and returns the new ID via SELECT @@IDENTITY; as the last command. I then want to call this from another stored proc, and get the value of the new ID. But I can't work out how to get the value returned from the first procedure. Example: CREATE PROCEDURE spMyI...

How to create a complex type from a stored procedure that uses exec()?

Hi... I want to create a complex type to use within an entity manager from a query constructed dynamically and executed with exec(). Is it possible?; since I'm writing a filter, what would you do instead if it is not possible? Also, I'm evaluating using linq, but the filter needs many tables and their registers, therefore efficiency is...

Generating simple CRUD stored procs

I'm working on a project that is subject to certain corporate standards relating to SQL implementation. Specifically, that all SQL Server content be accessed only via stored proc. (No ORM or LINQ.) 80% or more of our needs can be handled through the basic CRUD (CREATE, READ, UPDATE, DELETE) type of procedure that should be fairly si...

Multiple WHERE clause inputs to T-SQL stored procedure

I have a multiple selection listbox on a web form which lists various internal activity codes, and users can filter the results of a query based on the codes selected. I can easily add a single code as a parameter to my stored procedure and filter the results with a WHERE clause like so: WHERE ActivityCode = @ActivityCode OR @ActivityC...

mysql count rows with a specific column

I have a table like this Sr Name 1       A 2       B 3       C 4       C 5       C 6       E 7       A 8       A 9       A 10       E 11       B 12       B I need output like this A = 4 Times B = 3 Times C = 3 Times E = 2 Times How can I achieve this? Thanks in advance ...

Execute MSSQL stored procedure via Zend Framework

Request: Please show me a working example of how to retrieve(in an array?) returned rows from a Stored Procedure on a MSSQL server using Zend Framework. Explanation: I can't find anything in the ZF docs about how to execute SP on MSSQL servers. I'm aware that it is possible via plain PHP. However, since my project uses ZF, I'd like not ...

Best Practice: One Stored Proc that always returns all fields or different stored procedure for each field set needed?

If I have a table with Field 1, Field 2, Field 3, Field 4 and for one instance need just Field 1 and Field 2, but another I need Field 3 and Field 4 and yet another need all of them... Is it better to have a SP for each combination I need or one SP that always returns them all? ...

How to get COUNT from stored procedure return?

I have a stored procedure in SQL which I can't change. It needs few input parameters and returns a table with 100+ rows and several columns. exec dbo.Select_Data 0, 0, 18, 50 I need something to get count of returned rows: select count(*) from (exec dbo.Select_Data 0, 0, 18, 50) and a way to get values from e.g. Name column:...

total number of rows for paging with subsonic

Hi, there! Im trying to do paging with subsonic that gets data from custom stored procedure. Im clear with everything, except how to get total number of rows, so that I could show user how many rows are there and how many pages he can go to? Im new to subsonic, maybe Im missing something. I know that it is possible to getpaged with su...

Stored Proc returning one row, recordset or output parameters?

Ignoring ORM / NHibernate, etc. Consider the common requirement to pass in a Unique ID and return data from a single row (if the ID is found). The two ways to do this would be to return a record set or to use output parameters. Stored proc would be called from .NET C# code - so from that point of view one requires the set up / reading ...

SQL Stored proc, select data from secondary tables

I am trying to modify a stored procedure I wrote to pull data from other tables and insert it to a table. Basically I have one table where we store mappings by ID. In that table I put together a field that should be storing the concatenation of that data, which works fine. The problem is it is storing the ID of the mapping, not the name...

How to read/write or copy/paste text file locally using Stored procedure?

Hi My Stored Procedure is using Bulk Insert Task. As per requirement of Bulk Insert, the text file should be on same server where database is. Now file is residing on another machine. But database server can access file using shared network drive. Now question is How my stored procedure can read or copy the file from network drive an...

call to stored procedure returns nothing

I am calling a stored procedure on sql server like this: SqlConnection conn = new SqlConnection(); SqlCommand cmd; XmlDocument xmlDocument; XmlReader xr; XmlNode node; SqlDataReader rdr = null; try { xmlDocument = new XmlDocument(); conn.ConnectionString = "Data Source=test;Initial Catalog=teste;Integrated Security=SSPI;"; ...

Can anyone help me with a MySQL stored procedure

I have never done one before and am trying to work through an online guide but I can't seem to find a good example of one with parameters. CREATE PROCEDURE `calcdistance` ( IN ulat varchar, IN ulon varchar, IN clat varchar, IN clon varchar) BEGIN Select DEGREES(ACOS(SIN(RADIANS(ulat)) * SIN(RADIANS(clat)) + CO...

Parse all stored procedures in a database

Does anyone know of a way to verify the correctness of the queries in all stored procedures in a database? I'm thinking of the scenario where if you modify something in a code file, simply doing a rebuild would show you compilation errors that point you to places where you need to fix things. In a database scenario, say if you modify a t...

Views and stored procedures - using both for DB security (Entity Framework 4)

I'm a bit new to database programming in general, and even newer to Entity Framework 4. I'm reading the O'Reilly Press book on the subject, and just want to be sure I understand what the author is saying about using views in conjunction with stored procedures for an added layer of security. She says: If you are reluctant to expose ...

Get column names/types returned from a stored procedure

Is there a way via metadata (Information_Schema, perhaps?) to get a list of the columns a sproc will return? I'm trying to automate some code generation and that would help tremendously... ...

Can you loop over a comma separated list of values in a mysql stored procedure

I need to loop over a comma separated list of IDS that were passed into a stored procedure. I have seen people use locate() and substring etc but I haven't seen anything that really makes sense. Thanks! ...