All Questions
Tagged with sql stored-procedures
12,394
questions
0
votes
1
answer
43
views
How to update a SQL column in a stored procedure if the column was added?
I have a stored procedure where I select records from a table and I added a column for a flag (ReviewedFlag).
If I need to update this field how can I do it outside of the stored procedure? I need to ...
0
votes
1
answer
31
views
PostgreSQL Trigger Procedures Asynchronously From Main Overall Procedure
I am currently working on building a pipeline using a PostgreSQL DB hosted by AWS RDS. In my pipeline, I have a stored procedure in PostgreSQL that is triggered by cron and used to executed other ...
-1
votes
1
answer
51
views
Select maximum values and indicate the time (hour) [closed]
When I run this SQL script:
WITH MaxValues AS
(
SELECT
Par.CodEst AS 'BNA',
Est.GLS_ESTACION AS 'ESTACION',
Par.FecMed,
DAY(Par.FecMed) AS 'DIA',
MONTH(...
0
votes
1
answer
66
views
Prevent Insert in stored procedure from being rolled back by caller
I created a stored procedure with an insert like this:
CREATE PROCEDURE MyProcedure
@Param1 varchar(50)
@Param2 varchar(50)
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO MyTable
@...
0
votes
1
answer
34
views
Language plpgsql not supported for CREATE FUNCTION
I have created a function in redshift. But it is throwing an error of language plpgsql not supported for create function. How do I resolve this?
Expected other languages but didn't work. Also I tried ...
0
votes
0
answers
23
views
Stored Proc having UNION operator gives different Column name from Dbeaves and Spring Boot API
I have stored proc which makes use of unions to extract the data. Columns are renamed in first SELECT query as Deal_Id, Deal_Version, Book_Id.
When this proc is executed using Dbeaves Client, columns ...
0
votes
1
answer
104
views
Why were functions introduced when stored procedures were already available in SQL Server?
What factors led to the introduction of functions alongside stored procedures in SQL, and how do functions specifically enhance the flexibility and efficiency of database operations compared to stored ...
0
votes
1
answer
48
views
Unknown syntax error with Snowflake SQL procedure
I am writing a Snowflake SQL procedure to drop row access and masking policies from a database once it is cloned.
CREATE or REPLACE PROCEDURE DBMGT.DBADMIN.Q_DROP_MASKING_and_ROP_ON_BKP_DB("...
1
vote
1
answer
68
views
Using SSMS is there any way to easily identify what alias a reference is from?
For instance let's say I have the following query in a stored procedure:
SELECT apples
FROM Fruits T
JOIN Things T2 ON T.Id = T2.FruitId
How can I easily know which table "apples" is from? ...
0
votes
1
answer
93
views
Stored Procedure: add parameter for month or hour
I have the below Stored Procedure on Snowflake that sends out an email with all the load errors that exist in table SNOWFLAKE.ACCOUNT_USAGE.COPY_HISTORY for the last 24 hours. This is working ok but ...
-1
votes
2
answers
64
views
Postgres query work when executed normally but throw error when executed as procedure
When I run the below query it executes correctly. But when called as a procedure throws an error
Exception assignment source returned 2 columns 42601
From the analysis I found it's coming from here.
...
0
votes
2
answers
82
views
Loop through all stages in schema within a stored procedure and pass them on as arguments
I am trying to tweak my stored procedure in Snowflake so that I can loop through all external stages (in S3) from my schema manual_adjustments and not have to call this other procedure CHECK_LOAD() ...
0
votes
0
answers
45
views
Snowflake - dynamic "copy into" across different stages
I am trying to create a procedure in Snowflake that will dynamically copy files from different external stages in S3 into a table. Please see the procedure below:
CREATE OR REPLACE PROCEDURE ...
1
vote
3
answers
90
views
Getting only one row of data per primary key when there are many foreign keys that equals it [duplicate]
I have a procedure where I am trying to fetch the only on row of data per foreign key (FK) per (PK) in a table (turning a one-to-many relationship into a one-to-one table).
I have some tables that ...
0
votes
2
answers
67
views
Trying to execute a simple stored procedure - Help! Can't find an answer that works here
I'm completely new to SQL and am trying to execute a stored procedure that I'm not even sure I wrote correctly. It's supposed to give the total number of patients for a given dr, and this is the ...