37,162
questions
-7
votes
2
answers
92
views
How to ignore WHERE in a SQL statement [duplicate]
I have a simple statement:
SELECT *
FROM Articles
WHERE Category = @category
When the @category is 0 or null, I need the WHERE condition to be ignored and SQL select all articles
0
votes
1
answer
48
views
Generate a unique random 12 digit number in mysql
I'm trying to populate a column in a table with 12-digit unique random number using my stored procedure code below. The problem I encountered is the generated value for the random number is same when ...
1
vote
2
answers
74
views
Use aliases in CASE in stored procedure [duplicate]
I have SQL Server stored procedure:
Select
A.Id, A.Title, A.BriefText,
I.ArticleView, U.DisplayName AS Author,
U.Avatar,
(SELECT COUNT(*) FROM Articles_Like WHERE ArticleId = A.Id) ...
-1
votes
0
answers
27
views
Is it cheaper to calculate statistics over a huge data set directly in pl/pgsql or in an outside script? [closed]
Imagine I have a huge data set, like 100M sales from thousands of vendors over 12 months.
I'd like to incrementally calculate some statistics, like ~10-20 different formulas, among which are weighted ...
0
votes
0
answers
13
views
Stored Procedure Creation Returns Success but No Procedure Exists
I'm trying to create a stored procedure in SQL Server, and while the command executes with a "Commands completed successfully" message, the procedure does not actually appear in the database ...
-4
votes
0
answers
58
views
Complex stored procedure with one parameter should return a view or table for ALL parameter values [closed]
I have inherited a SQL Server 2016 database with a stored procedure that has a parameter @klkID.
As a result, this stored procedure returns a result set for ONE @klkID value that I can see in the MS ...
-2
votes
0
answers
47
views
Issues writing a PostgresSQL procedure [closed]
I'm currently working on a personal project. I'm trying to set up a database in PostgresSQL. I'm trying to write a procedure that checks to see if an artist's name is already in the table.
If it is, ...
1
vote
1
answer
60
views
Execute Prepared Statement in a Stored Procedure in Informix
I am using Informix 12.10 on most of my systems, and I am trying to run this using dbaccess on a Windows server. I am trying to understand how to work with stored procedures and prepared statements. ...
0
votes
0
answers
38
views
Stored Procedure null exception not handled successfully [closed]
In the following MySQL stored procedure, I am trying to check if the client_id parameter is NULL and raise a custom error using SIGNAL SQLSTATE '45000' if it is. Additionally, there is a NOT NULL ...
-4
votes
2
answers
131
views
Another conversion failed when converting from a character string to uniqueidentifier issue [closed]
Anyway, this is for SQL Server 2022. The error only happens at run time, and only when I right click on the stored procedure in the list and select to execute.
When I click the execute button it runs ...
2
votes
1
answer
60
views
How to efficiently FOR-loop over a huge SELECT result set in PL/pgSQL
In a PL/pgSQL stored procedure, I would like to calculate multiple averages (simple, weighted, etc) over different periods of time and over different number of data points, all in a single loop.
...
0
votes
1
answer
49
views
Mysql/Mariadb Cursor loop is being executed only once returning empty string and exiting
I wanted to do a partial back up of tables good and org and all tables that has foreign keys to these tables. To do that I wrote two procedures. The first one generates insert statements for the data ...
0
votes
0
answers
51
views
TSQL Stored procedure returning "string or binary data would be truncated" only when I try to insert the text "Date" or "DateTime"
So this issue is a real headscratcher for me. I have the below TSQL Stored Procedure where I open a cursorDateField to work through setting up some fields for what will become a date dimension. ...
0
votes
3
answers
65
views
How to know the database where my procedure was originally called from
I am developing a stored procedure and I would like to know from where it was originally called, by that I mean, in which database I was when I called my procedure.
I would like to achieve this ...
0
votes
1
answer
65
views
ORA-01031 : Cross Schema Procedure Execution Issue
I have three schemas META, DATA and a Custom schema in an Oracle DB.
I've declared one simple procedure in META schema.
CREATE OR REPLACE PROCEDURE TEST1 ( v_name IN VARCHAR2 ) IS
BEGIN
DBMS_OUTPUT....