Most voted "procedure" questions
A Procedure is a subroutine that does not return a value. DO NOT use this tag for stored procedures,use the tag [stored-procedures].
Learn more…115 questions
Sort by count of
-
63
votes2
answers17606
viewsWhy use WHERE 1 = 1 in an SQL query?
During the maintenance of a legacy system I found the following Procedure: DECLARE @sql AS varchar(MAX); DECLARE @param as varchar(50); SET @sql = 'SELECT * FROM Destinatario where 1 = 1'; IF(@param…
-
12
votes2
answers15638
viewsWhat is the difference between Function and Procedure?
What are the differences between the two, and examples of where and generally are used.
-
10
votes1
answer7950
viewsWhat is the difference between functions and procedures?
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 code with algorithm in Portugol.…
-
9
votes2
answers3276
viewsHow to make a Stored Procedure dynamic by taking data from other tables in the database?
I’m on a project to build a social network with the @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…
-
9
votes2
answers295
views -
5
votes2
answers645
viewsPassing a variable within a precedent
I have this 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 it as follows:…
-
4
votes1
answer1914
viewsProcedure oracle to copy data between tables
I need to make a trial copy of my TAB_FORNECEDOR table, everything you have in it and pass to TAB_FORNECEDOR2 table. I know I need to make a loop cursor, a commit delete before everything, can give…
-
4
votes1
answer1434
viewsProcedure with IF NOT EXISTS
Hello stackoverflow developers, I started to delve into sql commands a little while ago, I have some stupid error of syntax of this project, but for countless attempts, I could not Scan it, follow…
-
3
votes2
answers10109
viewsSet Value Local SQL Server Variable
I would like to assign the value of the local variable within the SELECT, as in the example below, but displays the following error message: "A SELECT statement that assigns a value to a variable…
-
3
votes1
answer393
viewsSpool task for the server
Good night! Guys, currently in my job, I have to generate multiple files. txt to be exported to another company’s database. I roll it in my hand and it sucks, every day I spin it, I wait to send it…
-
3
votes1
answer109
viewsMigrating from Firebird to Mysql
I’m migrating a project in Firebird to Mysql, I’m with a difficulty in converting a trial, would like any hint in how to proceed, below goes the Trial in FIREBIRD. CREATE PROCEDURE…
-
3
votes2
answers426
viewsSQL command in String Mysql
I am making a precedent that saves a select in a varchar variable. Now I need to run this sql command, how do I do that? I am using Mysql. Procedure: delimiter $$ create procedure eixos_caminhao (in…
-
2
votes1
answer1825
viewsAllow a user to view stored procedures created by other users
I have a Mysql database populated with some stored procedures. The problem is that two different users have created several procedures, so that only the user who created the stored Procedure can see…
-
2
votes1
answer1670
viewsPassing parameters to the postgresSQL
I will create a Rigger in postgresql to copy the information from one table to another, the tables will always have the same structure, so I intend to pass the table names, make a WHILE and copy the…
-
2
votes1
answer2608
viewsAssign execute command to a variable
I need the return of the execute command to be assigned to the @PAGO variable because I will insert it into a temporary table only what returns is the script and not the value. DECLARE…
-
2
votes1
answer388
viewsStored Procedure with low performance
I’m having trouble at the Oracle, where I have two procedures that run one after the other. Where in the first procedure, I have a cursor that does insert on a table. This Insert has approximately…
-
2
votes3
answers16754
views"Must declare the scalar variable" error
When I run the following Procedure, Sqlserver gives the error: Must declare the scalar variable error "@VDIAPARALYZED". Procedure: BEGIN SELECT @VDIAPARALISADO = COUNT(F.DATA) FROM ED_FERIADO F…
-
2
votes1
answer66
viewsMake an IF to set WHERE
I need help with a command in a proc SQL. Basically I need something like this: ... ... WHERE IF ( @Id_ProductClass IS NULL ) WHERE CLIENTPROD.Id_ProductClass NOT IN (59, 150) ELSE WHERE…
-
2
votes1
answer1443
viewsORA-01460 error on Oracle
I have the trial below: PROCEDURE GRAVA_(P_IMEI_DISPOSITIVO IN NVARCHAR2, P LONG, P_DET LONG, RETORNO_OPERACAO OUT VARCHAR2) In the P and P_DET parameters I receive strings with XML data, and inside…
-
2
votes0
answers226
viewsCursor stored Mysql precedent
I am inside a cursor that has 10 Rows of result. 2 Rows percentem is a number. example: 1,2 = 1, 3,4 = 2, 5,6 = 6, 7,8 = 9 , 9,10 = 3. How do I add only the values that correspond to the same number…
-
2
votes1
answer3703
viewsError: Process or Function has Too Many Arguments specified
Criei uma procedure para popular uma grid view: create procedure [dbo].[spc_listaafiliadosadmin] ( @nome varchar(100), @login varchar(100), @cpf varchar(100) ) as begin if(@nome is not null) begin…
-
2
votes1
answer667
views"Trace" no (VBA/Excel), how do I get the name of a subroutine?
How do I take the name of a subroutine (VBA/Excel) within itself to use in a code of type "Trace"? (see basic code in block UPDATE after the example code) The idea is to use something like…
-
2
votes1
answer143
viewsMake a SELECT multiple tables and save to a spreadsheet
I’m trying to make a SELECT with multiple tables, where I have a product with your information, and I have another table structure to be able to add an extra field and its information. What I tried…
-
2
votes1
answer656
viewsUsing last_insert_id(), is it credivel if several users enter at the same time in the database?
I have a doubt about the method last_insert_id() mysql. And the following: I am creating a procedure to insert into 3 tables, example: person (idPessoa, surname,) employee(idEmployment,idPessoa,)…
-
2
votes1
answer50
viewsI can’t run a trial in Firebird
Good afternoon guys. I need to enter a record in the database but no duplicates. I tried this: create procedure My_Proc as begin if(not exists(select * from alunos where nome = 'Mateus')) then…
-
2
votes2
answers1894
viewsCreate total sales (value) per customer (SQL)
I need to make a procedure to install the column cli_TotalCompras of the customer table with the total (in value) of the customer’s purchases. On the table vendaProduto have the value…
-
2
votes1
answer13534
viewsProcedure Oracle return query lines
I have the following table: CREATE TABLE CARRO ( CD_CARRO INT ,DONO VARCHAR(20) ,MARCA VARCHAR2(20) ); The Inserts INSERT INTO CARRO VALUES (1,'VICENTE','FERRARI'); INSERT INTO CARRO VALUES…
-
2
votes1
answer66
viewsSelection with LEFT JOIN
I’m studying sql and I don’t know if this is possible. But I have the following tables: Table contatos ______________________ id | nome | sobrenome | ______________________ That contains only one…
-
2
votes1
answer342
viewsMsg 207, Level 16, State 1 and Msg 4413, Level 16, State 1 error
When I try to execute the following query, these two errors appear to me: Msg 207, Level 16, State 1, Procedure V_RECLAMACOES, Line 3 [Batch Start Line 0]Invalid column name 'Reason'. Msg 4413,…
-
2
votes1
answer260
viewsC# - Run Oracle Procedure and then select from the created session table
Hello, I’m trying to do the following. I have a database that performs a select and inserts the data into a table that only exists in that session. I need to run this trial and then refer to the…
-
2
votes0
answers86
views -
2
votes2
answers65
viewsList data from Procedure sqlsrv PHP
Good morning, someone with experience in PHP and microsoft sqlsrv drive ? I found it difficult to display data from a Procedure in SQL SERVER with the "Microsoft sqlsrv driver". Something strange is…
-
1
votes3
answers720
viewsHow to find values in pascal
I’m setting up a program here at Pascal, where I have a record with 3 positions, each with name, age and weight. I also have a procedure called query, which will allow me to search for a registered…
-
1
votes3
answers2037
viewsSuspend function in Firebird
What is the function of suspend in a Procedure in the Firebird?
-
1
votes2
answers2023
viewsPass table field as parameter in a precedent
I made this precedent to bring records from a table between dates, but I need to pass the date field of the table for the between command to work, follow the code: DELIMITER // CREATE PROCEDURE…
-
1
votes2
answers104
viewsData string-to-date Procedure
I am creating a Trial, which receives a date string '2015-09-11', checks if it is indeed a Monday, if not, it takes this date and play for Monday of the week itself. But my concept with sql is very…
-
1
votes1
answer86
viewserror when converting an Oracle precedent into a Postgresql function in pl/pgsql
I adapted the code, but there is the following error : ERROR: relation "fields" does not exist CONTEXT: compilation of PL/pgsql function "p_grava_log" CREATE OR REPLACE FUNCTION F_GRAVA_LOG ( TIPO…
-
1
votes0
answers48
viewsHow to turn Procedure into DLL?
Good evening. I am new in the area of programming, I got an internship recently despite not having experience. For without experience I do not say layman, have only notions of POO, Database, etc.…
-
1
votes3
answers412
viewsFilter records via datetime and bring them between an initial and final date
I have the balance table, that always when running a precedent, It is generated a new record in the same, You can have several record in the same day... However, when making a query, I want to bring…
-
1
votes1
answer782
viewsOrder by SQL Server under Procedure
Hello, I have the following situation: I need to select the amount of care of people of some age groups and of those who are male and female. I have the following tables: cadastro (id, natendimento,…
-
1
votes1
answer584
viewsCreate Precedent to adjust price as per conditions (SQL Server)
In a comic book of a bookstore need to create a precedent to readjust the price column according to the percentage and gender reported (using transaction control). Like I should do? create table…
-
1
votes1
answer271
viewsSTORED PROCEDURE
I have 2 procedures and I wanted to call the trial sp_is_temporada in the past sp_calcula_curso, where the value of the sp_is_temporada return will be used in procecure sp_calcula_curso, and the…
-
1
votes1
answer123
viewsStored Procedure loop
I built this project, it makes the query inside the cursor right, but when I select SPA_VALOR_ACOMODACAO, it returns the 0, which was set before the loop_duracao. Looks like it’s not getting into…
-
1
votes1
answer983
viewsException SQL Oracle - Update and Insert
I have a question regarding a precedent that I am making oracle bank. A small explanation for what I am doing: I am reading data from a table, and throwing them on a cursor, after playing on the…
-
1
votes1
answer52
viewsRetrieve Browser Information in Procedure Mysql
You can pick up browser information on a PROCEDURE via Mysql code? No need to pick up via back-end code and pass as parameter. That is, Mysql has some function that returns information from the…
-
1
votes1
answer133
viewsProcedure pl/sql
Do you guys talk? Well I am new in PL/SQL and I am creating my first Precedent, because I need to load in two tables (Insert or Change), I am using Merge. But when I try to run my past I already get…
-
1
votes1
answer340
viewsOracle End of file when running
I’m getting the following error message when running this trial *Encontrado simbolo "end of file" quando era esperado:* DECLARE -- LOCAL VARIABLES HERE I INTEGER; BEGIN FOR NCM IN (SELECT * FROM…
-
1
votes2
answers62
viewscensor a registered word in a database
Is there a way to censor and replace a word registered in Mysql through a precedent or Trigger for example? The word in the case would be Flash House and I need it replaced by Old School.…
-
1
votes0
answers344
viewsError Code: 1452. Cannot add or update a Child Row: a Foreign key Constraint fails
I’d like to ask a question, or just show me the way. There is a table called Questionrio from it I take the records in a precedent and organize the data in it. Here is my code: CREATE…
-
1
votes1
answer22
viewsBecause my project is not being accepted, I am using mysql6.3
create procedure cadastrar_nadador (out nome_v varchar(80),out sexo_v varchar(1),out nascimento_v date,out patrocinio_v varchar(80)) begin insert into…