Questions tagged as 'procedure'

2
answers

Why use WHERE 1 = 1 in a SQL query?

During the maintenance of a legacy system I noticed the following procedure : DECLARE @sql AS varchar(MAX); DECLARE @param as varchar(50); SET @sql = 'SELECT * FROM Destinatario where 1 = 1'; IF(@param IS NOT NULL) SET @sql = (@sql + '...
asked by 10.04.2014 / 18:53
2
answers

how to do a dynamic Stored Procedure picking up data from other database tables?

I'm in a social networking project with @RodrigoBorth , and we have the problem of How to index and update a user comparison system ... We were given the idea of working with Stored Procedure in MySQL and then I went back! I read about concep...
asked by 07.03.2014 / 13:57
2
answers

Report showing column index

I have a question for generating a report, I need it to get the data from an SQL table and instead the name of the precise table of its ID, below the data that the query generates COD_CLIENTE NOME ENDERECO CPF...
asked by 06.05.2015 / 20:21
2
answers

What is the difference between Function and Procedure?

What are the differences between the two, and examples of where they are usually used.     
asked by 27.04.2015 / 20:30
1
answer

What is the difference between functions and procedures? [duplicate]

I'm studying algorithms and I'm having a hard time understanding the difference between them and when to use these sub-algorithms in a program. I'm learning to program with portugol algorithm.     
asked by 09.04.2016 / 03:54
1
answer

Procedure oracle to copy data between tables

I need to do a procedure that copies from my table TAB_FORNECEDOR, everything in it and go to table TAB_FORNECEDOR2. I need to make a cursor with a loop, a delete with commit first of all, can you give me a light on how to mount my procedure?...
asked by 16.12.2014 / 18:52
2
answers

Passing a variable within a procedure

I have this procedure in my project procedure DocumentComplete(ASender: TObject; const pDisp: IDispatch; const URL: OleVariant); Now I need to use it in a loop by passing the count variable. I tried the following: procedure DocumentComple...
asked by 08.11.2016 / 22:16
2
answers

SQL Command in String MySQL

I'm doing a procedure that holds a select in a varchar variable. Now I need to run this sql command, how do I do this? I'm using MySql. Procedure: delimiter $$ create procedure eixos_caminhao (in numeroEixos int) declare comando varchar(500);...
asked by 09.10.2018 / 17:42
1
answer

Procedure with IF NOT EXISTS

Hello stackoverflow developers, I started to delve into sql commands a short time ago, I'm having some kind of syntax error with this procedure, but for a number of attempts, I could not fix it, follow the code there, I'd be very grateful if can...
asked by 29.09.2014 / 01:10
2
answers

Set Value Variable Local SQL Server

I would like to assign the value of the local variable within SELECT , as in the example below, but it displays the following error message:    "A SELECT statement that assigns a value to a variable must not be combined with data-retrie...
asked by 18.06.2014 / 21:18