Questions tagged [stored-procedures]

A subroutine available to applications accessing a relational database system.

Filter by
Sorted by
Tagged with
0 votes
0 answers
25 views

Can't use User-Defined Table Type as a parameter in procedure

I am working on a database in SQL Server and want to create a procedure similar to this: create procedure db.insert_data @variable db.user_defined_type readonly as begin -- code end; This ...
DimPap's user avatar
  • 11
1 vote
0 answers
82 views

Is there a way to better way I can speed up this stored procedure

I would like to know if there is a way I can better write or filter this stored procedure CREATE DEFINER=`root`@`localhost` PROCEDURE `update_blank_holiday_record`() BEGIN DECLARE finished INT ...
tuneup90's user avatar
1 vote
1 answer
41 views

How to prevent error with counter in procedure

I have a procedure which I use for a while now. I works fine but it shows me also an error after completion. Here's the procedure: CREATE PROCEDURE `import_U_P`() BEGIN DECLARE anzahl INT DEFAULT 0; ...
doc_rolfo's user avatar
0 votes
1 answer
37 views

Unable to update the column value MySQL

I have a stored procedure in MySQL like below CREATE DEFINER=`root`@`localhost` PROCEDURE `UpdateJoin`( IN inputSeriesFacilitationId CHAR(36)) BEGIN DECLARE v_oldCount INT; START TRANSACTION; -- ...
SharmaPattar's user avatar
  • 2,504
1 vote
1 answer
38 views

Running stored procedure without waiting for it to finish

So I have this stored procedure that I run from my Spring boot application. It works and life is good. Now I want to run it asynchronously. Just launch the process and not leave the consumer waiting ...
Lucas Andrade's user avatar
-2 votes
1 answer
47 views

Inserting latest data into table coming from another table which is updated by SQL view [closed]

I have columns like ID, FirstName, LastName, DOB, Status coming from a SQL view called insert view. Now I have a stored procedure which inserts only latest data into table1 from that view as it ...
dixit gandhi's user avatar
0 votes
0 answers
17 views

syntax error : 1064 , when creating a stored procedure on XAMPP

platform: MySQL on XAMPP CREATE PROCEDURE percent(erp varchar(20)) BEGIN DECLARE percent DECIMAL(10,2); SELECT AVG(sub1 + sub2 + sub3) INTO percent FROM marksheet WHERE erp = erp; END; here i get the ...
Abhinav Gupta's user avatar
0 votes
0 answers
26 views

Airflow SQL Server stored procedure does not complete

We are moving some stored procedure from being executed in SQL Server jobs to Airflow. I use the following template to execute them: usp = MsSqlOperator( mssql_conn_id='mysqlconnection', ...
Thibaud's user avatar
-1 votes
0 answers
25 views

Which logic belongs to SQL stored procedures? [closed]

Usually databases are accessed through repositories, typically for pure CRUD operations. Which parts of the code belong to SQL stored procedures?
acmoune's user avatar
  • 3,103
1 vote
2 answers
29 views

How to use stored procedure parameters in the execute statement?

I have a simple stored procedure: DELIMITER $$ CREATE PROCEDURE `findUserByName`(IN `name` VARCHAR(36)) BEGIN set @name = name; PREPARE findStmt FROM 'SELECT * FROM user WHERE name=?'; EXECUTE ...
shingo's user avatar
  • 20.2k
0 votes
0 answers
15 views

Oracle Redaction and Definer's Rights Stored Procedures

I create a data Redaction policy for a field EMAIL and in the expression statment is the exception for the Data base owner user. It works perfectly :) This field is in a insert-select statmement in a ...
Ana Esquivel's user avatar
0 votes
1 answer
47 views

Mysql Query / Stored procedure to fetch data column wise based on range of month selected

I select month and year with range Jan-23 to March 23. The output expected should be as shown below using mysql query or stored procedure. Jan-23 Present Jan-23Absent Feb-23Present Feb-23Absent ...
chetana's user avatar
1 vote
1 answer
46 views

SQL Agent Job executes delete statement instead of Delete-Insert

I have written a stored procedure, code shown below. I have scheduled a job to execute this stored procedure. The job executes the procedure in 10 seconds and deletes the table but DOESN'T insert any ...
xorpower's user avatar
  • 18.2k
-1 votes
0 answers
27 views

PostgreSQL: cannot ALTER TABLE because it has pending trigger events

I'm getting 'cannot ALTER TABLE because it has pending trigger events' before executing Inner Procedure 3 (alter add constraint) and then fails. Please help me to fix this issue. Inner Procedure 1: ...
Vamsi Krishna's user avatar
0 votes
1 answer
30 views

Update column in table using snowflake scripting SQL

I am trying to update price column in table "sweatsuits". Goal is to add up 100 to price column values, when color is 'red' or 'pink' . I have written below code and it throws me error ...
user8545255's user avatar
0 votes
0 answers
42 views

No complex type created after updating the stored procedure

I have 1 stored procedure returning a complex type that was showing earlier with a suffix _Result. Then I updated the procedure and went to my .edmx file and deleted that procedure from these 3 places:...
Obraine's user avatar
  • 285
0 votes
0 answers
42 views

MySQL Dealing with Nested Transactional Stored Procedures [8.0.34]

UPDATE 11.22.2023 Helpful documentation confirming a deadlock always nullifies the entire transaction. https://dev.mysql.com/doc/refman/8.0/en/innodb-error-handling.html Still haven't found a rock-...
Floobinator's user avatar
1 vote
1 answer
96 views

"select * into" is too slow

i have a stored procedure in sql server: CREATE OR ALTER PROCEDURE dbo.basic_json_normalization_full @tableNamep sysname, @tableName sysname, @columns_list NVARCHAR(MAX), @json_query ...
maryem neyli's user avatar
0 votes
0 answers
101 views

Execution Timeout expired , In ms sql server, running a store procedure results in Microsoft.Data.SqlClient.SqlException, backend in ASP.NET core 6

A store procedure in MS SQL server results in "Microsoft.Data.SqlClient.SqlException". The store procedure is called from a backed asp.net core 6 web api. Details of the exception : ...
Walid's user avatar
  • 1
0 votes
1 answer
67 views

Data retrieved from T-SQL stored procedure into C# DataTable are skewed

I do have a strange problem I really do not understand when I retrieve data from a T-SQL stored procedure into a C# DataTable. The result I get in T-SQL is different from the result the DataTable ...
Chris's user avatar
  • 1
0 votes
2 answers
79 views

SQL Injection in Stored Procedures via MySQL Connector

I use the mysql-connector-python driver for executing database operations. Recently, I came across stored procedures in MySQL and decided to migrate some of my APIs from utilizing cursor.execute() to ...
BooRuleDie's user avatar
-1 votes
0 answers
27 views

Snowflake query to unpivot tables

enter image description here I had a question about unpivoting columns into rows in order to funnel into a STG_RESPONSES for multiple choices and into STG_COMMENTS for comments, here are the two table ...
Andy's user avatar
  • 1
2 votes
1 answer
94 views

Execution timeout expired issue in a stored procedure on Azure SQL

I got a problem with execution of a stored procedure on Azure SQL. By the way, the procedure is huge and average execution time is about 30–40 seconds. There is a main database and a replica. My API ...
Spring Elk's user avatar
0 votes
0 answers
35 views

Is there a way to show all warehouses in a Streamlit application running on Snowflake?

I have a Streamlit native app running on Snowflake and I would like to show a dropdown menu of all warehouses in the user's account. In my setup.sql script, I created a stored procedure ...
Sam W's user avatar
  • 1
-1 votes
2 answers
78 views

Combine multiple calcs using union

I have multiple calculations that use union and i am trying to combine them so i can load them into a new table on the same row. Below is an example of the calculations, i will have 8 in total. I want ...
Blowers's user avatar
  • 75
0 votes
1 answer
48 views

MySQL8 json payload does not accept json string as value for element

I have a stored procedure (see stored_procedure_1 code below) that expects json passed as an argument and inserts that data into a table. -- stored_procedure_1: DELIMITER \\ DROP PROCEDURE IF EXISTS ...
eetaSanglo's user avatar
0 votes
0 answers
31 views

Why is the SQL Agent job not failing when there's an error in a step?

There're several scheduled SQL Agent jobs in my 2019 Server. Each job-One Stored Procedure which I usually call a container consists of several Stored Procedures similar to below. SQL_Agent_Job_1 ...
Thilini's user avatar
0 votes
1 answer
25 views

What does the pale / light icon of the procedure mean?

I compiled a package in Oracle SQL Developer and some of my procedures have a rather pale / light colored icon (I am not allowed to add a picture). I am not really familiar with Oracle SQL Developer ...
Bollinez's user avatar
-1 votes
0 answers
38 views

Dapper QueryMultipleAsync is not returning any result(output parameters) in ASP.NET Core Web API

I am trying to execute an Oracle stored procedure which returns 2 output parameters: PROCEDURE SP1 ( inputParamOne IN VARCHAR2, inputParamSecond IN ...
Shivdutt's user avatar
0 votes
0 answers
20 views

Is there a way to check incorrect table names (or aliases) in MySQL Stored Procedures without executing/calling them?

Background: I'm having to move from MySQL 5.7 to MySQL 8. I do not have access to lower_case_table_names (which is set to 0). I have ~200 stored procedures, in which the table names (e.g. my_table_1) ...
VRA's user avatar
  • 91
0 votes
2 answers
48 views

How to create an external table using variables in Synapse without specifying columns

I have a stored procedure in Synapse Dedicated pool which takes a parquet file from adls and creates a staging table in dedicated pool: ALTER PROCEDURE dbo.Staging_Tables_sp ( @TableName VARCHAR(...
Rchee's user avatar
  • 89
0 votes
1 answer
18 views

Is there a way how to pass array of entities into stored procedure?

I have a project, which uses hibernate and do need to pass array of entities into stored procedure. There are tutorials/documentation about stored procedures, procedures using arrays, simple/custom ...
Martin Mucha's user avatar
  • 2,585
0 votes
1 answer
58 views

I can't use my declare @AverageValue in SQL Server

I have a variable in SQL Server. It's name is @AverageValue. EXEC sp_executesql @DynamicSQL, N'@AverageValue FLOAT OUTPUT', @AverageValue OUTPUT In this line I can see the result and @AverageValue ...
M.Eren's user avatar
  • 3
0 votes
1 answer
69 views

Create FOR loop inside Snowflake store procedure to execute SLQ query list from table

I am trying to create a loop inside store procedure in snowflake. I have a table created which has 3 columns(groupqueryids, query, orderid). One groupqueryids can have multiples queries and shorted by ...
Big_Data_engineer's user avatar
-1 votes
1 answer
51 views

How to call Microsoft SQL Server Stored Procedure from within Python using SQL Alchemy

I would like to execute a Stored Procedure residing on Microsoft SQL Server using Python and SQL Alchemy. So far I am able to connect to Microsoft SQL Server, run simple select query, assign it to a ...
Shaye's user avatar
  • 353
1 vote
0 answers
38 views

Error while trying to execute an Oracle Stored Procedure from CodeIgniter PHP

I'm working with CodeIgniter and have to modify a SP call This is working $this->DBTEST = $this->load->database("oracletest", TRUE); try { $params = array( array('...
Enrique's user avatar
  • 1,035
0 votes
1 answer
30 views

How to generalize a "WHERE" clause in a SQL trigger

I'm very new to SQL and practicing creating trigger functions right now. Currently I'm trying to create a stored procedure to update product records when a sale or stock update occurs. Right now, it ...
Finn Kimbrel's user avatar
0 votes
1 answer
60 views

Spring batch call stored procedure multiple time until get 0 rows

How can I use spring batch for calling on ItemReader a stored procedure multiple times until get 0 rows. For each time delegate the results of the stored procedure to ItemProcessor and ItemWriter? The ...
rubico's user avatar
  • 43
0 votes
2 answers
60 views

Scheduled Event not Executing Properly

I have a mysql event that is scheduled to run nightly defined as follows: create definer = myuser@`%` event nightly on schedule every '1' DAY starts '2023-10-21 00:00:00' enable do ...
Code Magician's user avatar
-1 votes
1 answer
24 views

Writing stored procedure in snowflake for converting table columns from one type to another type

I have a raw layer where snowpipe is being used to load the data from stage to table. All columns in that table are of type varchar. Now I want to move this data from raw layer to transformed layer ...
Ravindra's user avatar
-1 votes
1 answer
81 views

Oracle Create Stored Procedure to return list

I have a task table in which there are 3 columns(id,TimeStamp,Is_procssed).And i have created a stored procedure in oracle as given below. CREATE OR REPLACE PROCEDURE AUDITING....
prateek jangid's user avatar
1 vote
1 answer
113 views

Insufficient number of arguments for sp_rename in synapse stored procedure

I have this stored procedure in Synapse dedicated sql pool that is renaming a staging table to a main table. ALTER PROCEDURE [dbo].[RenameStagingTableToDedicatedTable] ( @DedicatedTableName ...
Rchee's user avatar
  • 89
-1 votes
0 answers
46 views

Mule 4 DataWeave Pass table array to Db::createStruct user defined Types

This is my payload: <TBL> <ITEM> <ID>123</ID> <LOT>2662475</LOT> <REC>04391623<REC> <SD> <SD_ITEM>6986306</SD_ITEM> <...
Vigneshwaran D's user avatar
-2 votes
1 answer
34 views

Print TABLE TYPE parameter in Stored Procedure

I need to pass a JSON response from an API to a Stored Procedure. So, I created a TABLE TYPE and tried using it in the procedure. But I get an error Must declare the scalar variable "@mydata&...
Bala's user avatar
  • 11.1k
0 votes
0 answers
7 views

SQL Server transactional replication doesn't replicate stored procedure changes even though they are shown as articles

I have transactional replication setup between SQL Server 2017 Standard Edition instance on a VM and a AWS RDS for SQL Server 2017 Standard Edition instance. All stored procedures are part of it. ...
Yoni Sade's user avatar
  • 169
-1 votes
1 answer
40 views

how to set Stored procedure with IN parameter so that it sees empty ('') as command to select all values

I have a code CREATE DEFINER=`root`@`localhost` PROCEDURE `find_stock_order`( in_product_name varchar(45), in_date DATE) BEGIN SELECT * from stock_order_view where product_name=...
Him's user avatar
  • 1
-1 votes
1 answer
39 views

Deal with CROSS APPLY in stored procedure when using a JSON to load data

I have 2 tables to populate using a SP in SQL Server. In my case, I'm passing a JSON array as data input and then populate data. In these 2 tables all the primary keys are auto generated. When I ...
codebot's user avatar
  • 2,548
1 vote
1 answer
32 views

Atomicity through object segregation

I am facing a problem I don't know how to solve efficiently that involves an heavy use of the DBMS. I have a long running procedure refreshing (through bulk inserts/deletes/updates) many tables. Such ...
Chaos's user avatar
  • 113
0 votes
0 answers
21 views

MySQL Transaction Question - Order of operation in calling

Update: MySQL Version 8.0.34 My understanding is MySQL is purely synchronous in operation and when a connection calls a stored procedure, the database doesn't "return" from that call (...
Floobinator's user avatar
0 votes
1 answer
46 views

SELECT command doesn't work properly in Stored procedure [duplicate]

I want to create Stored procedure that selects specific rows after entering 2 values for parameters. So my code is: CREATE DEFINER=`root`@`localhost` PROCEDURE `find_stock_order`( in product_name ...
Him's user avatar
  • 1

1
2 3 4 5
739