stored-procedures

Mysql syntax help

I have problems writing a SP in MySQL. From what I can read on the net the following should work, but it does not. I use Mysql v. 5.1.35 CREATE DEFINER=`My_Username`@`%` PROCEDURE `ChangePassword`(IN SPusername VARCHAR(100), IN SPoldPassword VARCHAR(100), IN SPnewPassword VARCHAR(100)) BEGIN IF EXISTS(SELECT Password_Hash ...

Dynamic Datasource in SQL Server Stored Procudure

I have a SQL Server that houses Several Databases. I have a Main Database that holds several tables with entities and ID numbers. Then, each one of those entities has a correlating database (not a table, but database) with all of its information. For example, if the an entity in the MAIN database has an ID number of 1, there would be an ...

execution time of a stored procedure

What is the age old method of testing execution time of stored procedures on informix 11.5. I am thinking of doing something like this from a unix prompt: $ time (echo 'execute procedure foo(1)' | dbaccess ...) Any other ideas? ...

Best practice for a SQL Archiving Stored Procedure

I have a very large database (~100Gb) primarily consisting of two tables I want to reduce in size (both of which have approx. 50 million records). I have an archive DB set up on the same server with these two tables, using the same schema. I'm trying to determine the best conceptual way of going about removing the rows from the live db a...

A database question for storing and computing with historical data.

I have an application that polls different bins at different times and computes the number of widgets in each bin based on the weight. Polling is done every few minutes and the result is timestamped and added to a MySQL table. The table contains the 3 columns below. The example shows 3 bins (A,B and C) but there could be anywhere from 1 ...

Call a Stored Procedure from another Stored Procedure.

I want to call a SP from another SP. I know I can easily call it. But Problem is, if an error occurs in SP2 then I want to ROLLBACK SP1. SP1 BEGIN Tran [Some Code] Call to SP2 [Some Code] SP2 BEGIN TRAN [Some Code] [Error Comes] ROLLBACK TRAN This would rollback Tran in sp2 only. I...

Return value of stored procedure is correct but column values are all NULL

I'm working with the C# membership provider and transferring it to LINQ along the way. I'm having trouble pulling the results from a stored procedure in MS SQL. The procedure does some work to set variables and then selects the variables before setting the return value of 0. When I run this in MS SQL to test it works fine. When I run i...

Can I have index created on temp tables (#temp) which are created dynamically in a stored procedure?

I am creating temp tables (#temp_table) in my stored procedure. It is a huge table with large data. Then I am creating a index in the storeed procedure as it is required for faster query to the temp table. But when I execute the stored procedure, the index is not used. The index is not being created when the stored procedure is executed....

Mapping stored procedure property in ef

Hi I'm trying the entity framework and in my model i have a customer, customer_address and address tables. I've created stored procedures for crud operations for each table. Mapping the sprocs for customer and address went easy but mapping update sproc for customer_address gives me error. I'm confused how to implement this properly. Her...

Accessing RAISEERROR message from cfstoredproc

Hi there, I have a SQL stored procedure which under some situations will return a result of -1 if it fails, but also returns a message via the RAISERROR command e.g.: BEGIN RAISERROR ('Error %i has occurred', 11, 1, 0) RETURN -1 END I am accessing this via coldfusion using cfstoredproc e.g.: <cfstoredproc procedure="sp_ret...

writing a generic procedure in oracle

i want to write procedure which accents name of 2 tables as arguments and then compare the number or rows of the 2. Also i want to each field of the 2 columns.The row which has a missmatch shold be moved to another error table. Can anyone give a PL/SQL procedure for doing this. I want to achive this in oracle 9 ...

Capture Stored Procedure print output in .NET

Is it possible to capture print output from a TSQL stored procedure in .NET? I have a lot of legacy Procs that use the print as means of errorMessaging. An example, is it possible to access the outprint 'word' from following PROC? -- The PROC CREATE PROC usp_PrintWord AS PRINT 'word' // Some C# Code to would like to pull out 'wor...

Evaluate a string in a MySQL stored procedure

I have a stored procedure that I would like to pass a string to, to be evaluated in the query. I will be building a string in php, based on query parameters that exist. So, my string might be col1 = val1 or col1 = val1 AND col2 = val2 AND col3 = val3, ect. Then in my stored procedure, I would do something like this: SET @s = CONCAT('SELE...

Troubles pulling id from first insert done by stored procedure to do use on second stored procedure

I'm having troubles pulling the id from the first insert to use on the second insert. Here's my SQL (I'm using stored procedures): DECLARE @JoinDate date DECLARE @ID int SET @JoinDate = getdate() EXEC Members_Add $(UserID), '$(UserName)', @JoinDate, '$(firstname)', '$(lastname)', NULL, '$(Country)', NULL, '$(stateorprov...

SQL Server 2008: Creating dynamic Synonyms?

Hi folks, in my SQL Server 2008 database I have a number of different tables with the same structure. I query them in different stored procedures. My first try was to pass the table name to the stored procedure, like: CREATE PROCEDURE MyTest @tableName nvarchar(255) AS BEGIN SELECT * FROM @tableName END But we can't use parameter...

Classic ADO and Table-Valued Parameters in Stored Procedure

Is there some way to pass a table-valued parameter to a stored procedure in SQL Server via classic ADO? ...

MYSQL stored procedure accessing java object stored as a BLOB.

I am storing a Java object as an byte in a blob of a table. The java object is customized object. How can I construct the java object and use it in the stored procedure? ...

Retrieve fields schema in Visual Studio of stored procedure which uses temp tables

I have some complex stored procedures pulling data from other databases using linked servers. This data is put into temp tables which are joined in a select query for output. The procedures work fine but in visual studio if I try to add the stored procedure to a dataset using the designer I get the error invalid object name #tmp or whate...

SQL error: String or binary data would be truncated

I'm doing an integration on a community platform called Telligent. I'm using a 3rd-party add-on called BlogML to import blog posts from an XML file (in BlogML format) into my local Telligent site. The Telligent platform comes with many classes in their SDK so that I can programmatically add content, such as blog posts. E.g. myWeblogServ...

SQL Server 2005 proper index to filter 30,000,000 registers

Hello, I have a problem with a stored procedure of a transactional table, the user have a web form to find transactions by several values. The process is taking too long and I don't know how to set proper index. here is my stored procedure: CREATE PROCEDURE dbo.cg_searchTransactions ( @id_Ent tinyint, @transactionTypeID int = ...