stored-procedures

MySQL - definer in stored procedure

Hello. I've written all of MySQL procedures as root@localhost. Code looks like : CREATE DEFINER=`root`@`localhost` PROCEDURE `p_add_user`(...) Trouble is, when deploying on online server. When I replace root with current user and replace localhost with current IP, it works just fine. But that is quite annoyance .... Is there any way...

SQL Server 2005: Subquery in EXEC ?

EXEC [dbo].[pr_cfgAddFact] @SettingName = 'TransferBatch', @RoleFK = SELECT TOP 1 rolepk FROM cfgRole WHERE cfgRole.Name = 'SuperAdmin' Why would SQL complain about the SELECT clause here? I am trying to run the proc with the sub query getting the data. ...

Permissions for Large Variables to Be Sent Via Stored Procedures (SQL Server)

I can't figure out a way to allow more than 4000 bytes to be received at once via a call to a stored procedure. I am storing images in the table that are around 15 - 20 kilobytes each, but upon getting them and displaying them to the page, they are always exactly 3.91 KB in size (or 4000 bytes). Do stored procedures have a limit on how ...

My Oracle 9i package won't compile, says that a user-defined function is out of scope... but it isn't...

I have an Oracle package which contains user-defined functions and procedures, including two user-defined functions which are called from SELECT and UPDATE statements. The functions in question are defined before the procedures that call them. This piece of code compiles and works fine on Oracle 10g but won't compile on 9i. The code s...

Unknown Column 'template' in where clause, while using a stored procedure.

Hello, I have a stored procedure, which has got executed without any errors, but gives me an error "#1054: Unknown column 'templateName' in where clause" when I run it. The stored procedure is: delimiter // DROP PROCEDURE `getData`// CREATE DEFINER=`root`@`localhost` PROCEDURE `getData`(IN templateName VARCHAR(45),IN templateVersion VA...

How to get the answers version and use it in IF loop

delimiter // DROP PROCEDURE `getData`// CREATE DEFINER=`root`@`localhost` PROCEDURE `getData`(IN templateName VARCHAR(45),IN templateVersion VARCHAR(45),IN userId VARCHAR(45)) BEGIN set @version = CONCAT("SELECT `saveOEMsData_answersVersion` FROM `saveOEMsData` WHERE `saveOEMsData_templateName` = '",templateName,"' AND `saveOEMsData_...

Retrieve a value inside a stored procedure and use it inside that stored procedure

delimiter // CREATE DEFINER=root@localhost PROCEDUREgetData(IN templateName VARCHAR(45),IN templateVersion VARCHAR(45),IN userId VARCHAR(45)) BEGIN set @version = CONCAT("SELECT saveOEMsData_answersVersion FROMsaveOEMsData WHERE saveOEMsData_templateName = '",templateName,"' ANDsaveOEMsData_templateVersion = ",templateVersion," AND saveO...

mysql stored procedures using php

I have a stored procedure: delimiter // create procedure userlogin(in eml varchar(50)) begin select * from users where email = eml; end// delimiter ; And the php: $db = new mysqli("localhost","root","","houseDB"); $eml = "[email protected]"; $sql = $db->query("CALL userlogin('$eml')"); $result = $sql->fetch_array(); The error...

Is it possible to create a global stored procedure at Sql server level

I created a query that takes a database backup at certain specified location. I want to use it as a stored procedure but this should act as a global stored procedure so that whenever this SP is called. Then database backup is taken. It uses DB_Name() to take database backup of owner database. Is it possible to create any such SP or Fun...

Stored Procedure - forcing execution order

I have a stored procedure that itself calls a list of other stored procedures in order: CREATE PROCEDURE [dbo].[prSuperProc] AS BEGIN EXEC [dbo].[prProc1] EXEC [dbo].[prProc2] EXEC [dbo].[prProc3] --etc END However, I sometimes have some strange results in my tables, generated by prProc2, which is dependent on the r...

Calling Stored procedure using Nhibernate -- Getting exception No persister for:

here is code, how I am calling Stored procedure ISession session = NHibernateHelper.GetCurrentSession(); IQuery q = session.GetNamedQuery("ps_getProgressBarData1"); var t = q.List(); XML mapping <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="ReleaseDAL" assembly="ReleaseDAL"> <sql-query name="ps...

Get Stored Proc Schema name in mysql

I would like to get the schema name string of a stored proc inside the stored proc itself. I don't know if it's possible because I didn't find any information about it. Exemple : DELIMITER $$ DROP PROCEDURE IF EXISTS `exemple` $$ CREATE DEFINER=`root`@`%` PROCEDURE `exemple`() BEGIN DECLARE schema_name VARCHAR(100) DEFAULT NULL; S...

I have a asmx webservice , I want to return the xml from a stored proc.

Im using Linq to SQL I have a stored procedure that is returning xml . ie im using for xml outo ,elements that works fine. what I want to do is expose the result of the stored procedure via a webservice. Here is some pseudo code: if some could help me replace the ?'s [WebMethod] public ? myMethod( int custID) { var myCust = d...

Debugging a local SQL Server 2008 stored proceedure from Visual studio 2008

Hi all, There are a few posts about this question around but most concern remote debugging - here everything is on same machine. Visual studio 2008. I have a data connection to localhost SQL Server 2008 using Windows authentication with an admin account - this account is a member of sysadmin in SQL server. I double click stored proc an...

What is the proper odbc command for calling Oracle stored procedure with parameters from .Net?

In the case of MSFT SQL Server 08, it is: odbcCommand = new OdbcCommand("{call " + SP_NAME + " (?,?,?,?,?,?,?) }", odbcConn); When I try to do the same thing for Oracle, I get: OdbcException: ERROR [HYC00] [Oracle][ODBC]Optional feature not implemented. Feel free to ask for clarification, and please help. I am using .Net 3.5, SQL S...

Oracle: Use of notational parameters which calling functions in insert statements not allowed ?

Why does Oracle 10 R2 not allow use of notational parameters while calling functions in insert statements ? In my app, I'm calling a function in an insert statement. If use notational method of parameter passing, I get an ORA-00907: Missing right parenthesis error message INSERT INTO foo (a, b, c)...

How to use variables in Teradata SQL Macros

Hello I'm wanting to use variables inside my macro SQL on Teradata. I thought I could do something like the following: REPLACE MACRO DbName.MyMacro ( MacroNm VARCHAR(50) ) AS ( /* Variable to store last time the macro was run */ DECLARE V_LAST_RUN_DATE TIMESTAMP; /* Get last run date and store in V_LA...

Call Stored Procedure in Nhibernate - exception - No persister for

I am getting exception when calling Stored Procedure using Nhibernate and here is the exception No persister for: ReleaseDAL.ProgressBars, ReleaseDAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null here is class file public class ProgressBars { public ProgressBars() { } private Int32 _Tot; private Int32 _subto...

does mysql stored procedures support data types like array, hash,etc?

i am creating a mysql function which takes in a varchar and change it to a int based on a mapping table. select name, convert_to_code(country) from users where sex = 'male' here, the convert_to_code() function takes in a country name (e.g. Japan, Finland..) and change it to country code which is an integer (e.g. 1001, 2310..) based on...

How to track changes in many SQL Server databases from .NET application?

Problem: There are a lot of different databases, which is populated by many different applications directly (without any common application layer). Data can be accessed only through SP (by policy) Task: Application needs to track changes in these databases and react in minimal time. Possible solutions: 1) Create trigger for each ta...