Callable code installed on a database manager, exposing an API through which it can be invoked. Normally written in the native query language, some DBMS platforms support other languages as well.

learn more… | top users | synonyms

1
vote
1answer
27 views

Alter of stored procedure and execution performance

I would like to understand how an alter of a stored procedure without modifications can impact performance. I had a situation where a production environment had its database schema updated and a ...
0
votes
0answers
22 views

CALL Procedure(Function) = Trigger?

I have discovered some strange behavior in Oracle 11g, and I'm wondering if anyone has an explanation for it. The gist is that when I use a function that contains a commit/rollback/savepoint within a ...
3
votes
1answer
50 views

How can I get the last inserted id from an specific table from a given stored procedure?

I know about the existence of LAST_INSERT_ID() function... Though I am not quite sure about its behaviour... Does it take the last inserted id from the current user into account? Or uses all the ...
0
votes
1answer
33 views

Why is my PL/SQL procedure so slow?

I have this sub-procedure in a fairly large program, and it is taking hundreds of times longer than comparable sub-procedures. Is there any way I could improve efficiency here? None of this ...
-9
votes
1answer
48 views

Stored Procedure which INSERT, UPDATE, DELETE any table(for any table) where table name and its values are passed as parameter [on hold]

Stored procedure which performed operations like inserting data to table, updating data, and deleting data of table where table name is passed by parameter. Parameters of stored procedure: table name ...
3
votes
3answers
142 views

INSERT/UPDATE in same query from previous SELECT with some singularities

I'm trying to perform a INSERT|UPDATE by selecting data from another DB and this is what I have so far: INSERT INTO pdone.reps (veeva_rep_id,display_name,username,`first`,`last`,email) SELECT ...
1
vote
0answers
10 views

Adding new sproc to the exisiting database using connectors?

The project I'm currently working on is mostly pythonic, by this reason I'll likely use mysqldb python connector or sqlalchemy. The question arose when I've tried to find out the way of adding new ...
2
votes
1answer
31 views

How can I pass object to procedure from trigger? [on hold]

I am using mysql 5.6. After insert or update, inside the trigger I am calling procedure, So how can i pass NEW and OLD object from trigger to procedure ?
1
vote
2answers
58 views

Stored procedure using cursors

I am attempting to create a procedure using cursors to list the average salary of all employees on a per department basis. I am using three tables, defined as emp (eid, ename, age, salary) works ...
0
votes
0answers
24 views

msdb.dbo.sp_start_job got stuck in stored procedure

I have a stored procedure USP_A with logic like following: ...... BEGIN TRY exec dbo.usp_Log 'Start to run job job1' Exec @intErrorCode = msdb.dbo.sp_start_job 'job1' IF @intErrorCode <> 0 ...
0
votes
1answer
27 views

Use PL/pgSQL in PostgreSQL outside of a stored procedure or function?

I'd really like to use an IF, ELSE construct and execute multiple statements within the IF and ELSE blocks, but I don't wish to save my commands to the database as a stored procedure or function. Can ...
1
vote
1answer
26 views

Is there another/better way to create and maintain large amounts of procedures?

So I've decided to take a step back, and scrutinize the way I implement procedures on my databases. I'll list what I have done, give my reason for doing so and hopefully I will be told that I'm a ...
2
votes
1answer
24 views

MySQL stored procedure updates twice

I have this stored procedure: DELIMITER $$ CREATE PROCEDURE updateTrendContentStats(IN mongoid VARCHAR(255),IN numericid INT,IN points INT,IN ctype INT,IN activity INT,IN created INT) BEGIN DECLARE ...
0
votes
2answers
24 views

Retrieve data from SP inside of From

Goal: Retreive a list of data from a stored procedure that is acting as a database name. When you have retrieved the list from stored procedure, I want to make another new data manipulation. Problem: ...
1
vote
1answer
43 views

stored procedure vs. function in postgresql and which is better for executing dml statements

I'm using postgresql 9.3. If I want to add the following steps and call these steps as a routine, would it be better to use a function or stored procedure? My basic steps are: RENAME TABLE ...
0
votes
0answers
18 views

Statement ignored - PL/SQL Procedure

create or replace PROCEDURE UNIQUE_MATCH ( PHYSICIANID IN NUMBER , FNAME IN VARCHAR2 , LNAME IN VARCHAR2 , POSTALCODE IN VARCHAR2 , SOURCETABLE IN VARCHAR2 ) AS ALREADY_HAS NUMBER; BEGIN ...
3
votes
1answer
28 views

A Customized Table with Chronological order

Goal: My request is the retrieve the return result from sp_Test as 8, 2, 4, 1 ,3 (take a look at picture 1) based on the chronological list from User-Defined Table Type dbo.tvf_id. Problem: When I ...
3
votes
0answers
69 views

Why the stored procedure is much slower than a temporary table?

I want to do the updating of my database every day and I will like to use stored procedures but the time of execution of the temporary table is faster than the stored procedure. How can I optimize my ...
0
votes
0answers
18 views

MySql stored procedures are not atomic (JDBC)?

I have a stored procedure with one UPDATE and one INSERT in its body. I call the SP with a single executeQuery(...) wrapped within a try-with-resources. The DB connection is set (by default) to ...
1
vote
0answers
16 views

BLToolKit save null instead of 0 [migrated]

(Can't use it as tag, but we're Using BLToolkit as ORM) I have this weird problem where BLToolkit saves NULL instead of 0 in our database. If you look the image, this is my values that will be ...
0
votes
0answers
44 views

How can i add index in MYSQL stored procedure?

I can not use alter table () on my stored procedure i don't have a permission to do that in the big database data_pro. How can i use index in my stored procedure for my 2 fields in where condition? ...
1
vote
1answer
126 views

Why is my stored procedure very much slower than the same MYSQL query?

My stored procedure is very slow compared to a normal query or a temporary table. How can I optimize my stored procedure? CREATE DEFINER=`datasll`@`...` PROCEDURE `product`() BEGIN EXPLAIN ...
0
votes
0answers
25 views

How to Create a Recommended Test Planning in SQL Server

Goal: Make lots of different test for a specific stored procedure named 'sp_test' in order to review if you are retrieving the same data based on data input. Purpose: If you have made lots of ...
1
vote
0answers
59 views

Why my sql query run faster than my stored procedure?

I am trying to write a script in MYSQL Workbench to update my database every day using stored procedure but I find it too slow compared normal query or temporary tables. If i use temporary table the ...
1
vote
1answer
38 views

Setting query to run as a stored procedure and email the results [closed]

I have the following query: select COUNT(CASE WHEN New_accounttype = 1 THEN New_AccountType ELSE NULL END) as 'New Connections' , COUNT(CASE WHEN New_accounttype = 2 THEN New_AccountType ELSE NULL ...
0
votes
1answer
29 views

trouble creating a stored procedure to print out values for each day of week

I am having difficulty in understanding how to get this working correctly. I am trying to have create a stored procedure that is run automatically on a sunday and will get the data for the previous ...
4
votes
2answers
225 views

Tracking down a stored procedure's parameters after execution

I have been asked to identify a permissions issue with a stored procedure. This stored procedure behaves in two possible ways depending on what values are used for its parameters. exec ...
2
votes
1answer
15 views

Retreive a Customized List with input data

I have a database that has about 223 tables and I need to locate the name of the constraint. My request is to add a parameter that is the name of the constraint and you retrieve a list that shows the ...
1
vote
2answers
34 views

ALTER DATABASE script preventing restore of MySQL database in another server

While backing up the database with mysqldump --routines options, I see ALTER DATABASE in the middle of the output dump, near the routines. /*!50003 DROP FUNCTION IF EXISTS `f_my_function` */; ALTER ...
1
vote
1answer
32 views

Using NOCOUNT to Improve Procedure Performance

I am looking to improve the performance of a certain procedure and I wanted to begin with the insertion of the SET NOCOUNT ON. I've read a couple of articles on the subject: Aaron Bertrand SET ...
0
votes
1answer
70 views

Simultaneous READ COMMITTED transactions updates a select for update columns

I have a READ COMMITTED transaction in which I am trying to update a row and increment a column value till it reaches a bucket value contained in another column. Please see the code below CREATE ...
1
vote
0answers
60 views

Parameter Sniffing Question [closed]

My question is: If we employ a plan guide, why would we still experience the effects of parameter sniffing (ie: Where the query returns results at different speeds, 1s, 1s, 1s, 15m, 2s, 2s, etc..) ...
0
votes
3answers
54 views

Merge MySQL tables without data repetition

My situation is this: I have several DIFFERENT tables in my MySQL database with the same name columns. Such tables can contain (or not) the same data. What I need to do is a kind of "merge" between ...
1
vote
1answer
86 views

MySQL: Why is inserting data with transactions faster then without them

I am using stored procedure to generate sequence consisting of prefix and number in given range (etc sequence "AB100", "AB101", ..., "AB199", "AB200") The stored procedure includes REPEAT loop, in ...
0
votes
0answers
40 views

Data Mock up for my table

I want to mock up data for a table. So I need to generate a million sample records for the table? Table structure is like this: CREATE TABLE Employees( EmployeeID int NOT NULL, FirstName ...
2
votes
1answer
48 views

Periodically update a table with new records from another server

I have databases on two different servers. I need to regularly retrieve new records from a table on server A, and process them in order to use them to update a table on server B (with a different ...
1
vote
1answer
34 views

How can I setup a Login which can run an automated Database Refresh without giving away too much priv?

I would like to re-ask and extend the question posed in this thread if I may: SQL Server permissions to create, restore, delete only some databases I am also attempting to setup an 'isolated' ...
0
votes
1answer
25 views

Procedure doesn't have compatible arguments

Getting an error while invoking my procedure named LOG_MSG_TEST(). Procedure Schema name is ADMINIST. My procedure has one INTEGER input parameter and one VARCHAR output parameter. I am calling ...
0
votes
1answer
29 views

Executing a script via Powershell possibility

Let's say I don't happen to have the ability to create a Stored Procedure, but I have to run the same query on a regular basis. Would I be able to put my query in a .txt document and be able to run it ...
0
votes
1answer
66 views

How to create a dummy Linked Server in SQL Server 2012

I have a database in two different production servers. I want to keep the schemas consistent between the two. One has jobs that call stored procedures that reference a Linked Server. The other does ...
0
votes
0answers
14 views

Read show create table in mysql stored procedure

How can I read the output of following query and assign to a stored procedure's variable? SHOW CREATE TABLE users; Or, is there is an information schema from where I can draw the full table ...
0
votes
2answers
85 views

Use event schedule and stored procedure to automatically average every hour MySQL

I have a database in Mysql Workbench about weather that updates every second. It contains temperature and wind speed. This is my database: CREATE TABLE `test`.`new_table` ( `id` INT(10) NOT NULL, ...
0
votes
0answers
27 views

How to reset @@IDENTITY value inside a Sybase SP

Is there any way to reset the @@IDENTITY value inside a Sybase SP? I'm writing a SP which involves a transaction, so everytime I do an insert, to check data was correctly inserted, I assign ...
0
votes
1answer
16 views

Help with stored procedure and update table

I am trying to write a stored procedure that has parameters and updates a table with the supplied title and middleName for the person having the businessEnityID. Create Procedure sp_PersonEditor ...
0
votes
1answer
21 views

Working with variables in stored proc

I want to create a meta table on the fly using a stored pdocedure and passing a table prefix as "in" parameter and then build the final table name somehow. My code looks like this: SET @table_ = ...
0
votes
1answer
35 views

Getting error while installing log4db2 utility

DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0601N The name of the object to be ...
0
votes
0answers
32 views

Which technologies should I consider using for creating a calculated view?

I use SQLServer, but I suppose this question is general enough for any type of database. Suppose I wish to build an application that allows people to rate geographic regions on where they would like ...
1
vote
1answer
33 views

Unable to update table after creating an After update trigger

I have a table like this /*Table: pageprivilege*/ ------------------------ /*Column Information*/ ---------------------- FIELD TYPE COLLATION NULL KEY DEFAULT Extra ...
1
vote
0answers
77 views

Return both Result set AND a warning from a stored procedure

In Data Studio when you call SYSPROC.ADMIN_CMD() directly and it returns a warning, the results panel shows both the warning and the result set: CALL SYSPROC.ADMIN_CMD('EXPORT TO ...
2
votes
2answers
132 views

sp_send_dbmail stored procedure send with attachment

I've been tasked with sending a small monthly report to for one of my customers. The report has previously been run manually on the instance, the output copied to a spreadsheet and send to the ...