Questions tagged as 'stored-procedure'

1
answer

Insert in 2 tables with last_insert_id ()

Good day, I'm trying to make an insert in 2 tables that are related by the main ID of one that is the FK of the other. I'm using a Stored Procedure for this, but I get an error when I try to load data that is: Column count does not match valu...
asked by 05.12.2017 / 17:00
0
answers

Trigger To update Field every 24 hours

Update my question to reference me and explain better what I want to do. In my table I have a field called days, I want every 24 hours to run and trigger and subtract that field in 1 if it has a 30 subtract 29 and so on, but I do not know how...
asked by 04.11.2017 / 01:02
2
answers

Add value of a table related to itself

Hello I have a question about how to make a query in sql to add the total time it takes to produce the product. The diagram is a table of products that has sub-products, the design is an NN relationship with itself so I made an auxiliary tabl...
asked by 13.10.2017 / 14:04
1
answer

Can I use the return of a stored procedure as part of the where clause?

The idea is that the stored procedure returns a set of identifiers. Ex. pra_id: 303 404 Currently this is what I am trying to do, and it is to use the return of the pra_id as filters: SELECT rea.rea_id, rea.pra_id, etr.etr_id, etr.etr...
asked by 13.10.2017 / 00:02
2
answers

Compare the fields of the same column

I have the following table: create table cumpleanios( Id_cumpleanios pk ai, Id_user mediumint, cumpleanios varchar(12) ); What I want to do is compare the field cumpleanios to know if a user has already inserted the birthda...
asked by 23.08.2017 / 12:28
1
answer

Arranged stored procedure with bifurcations in sql server 2000

I'm complicated when it comes to putting together a stored procedure. The query is hardcodeed in php in this way: if(trim($id) != ''){ $query = "select * from PACIENTES where idpac in (select pac_id from contacto where id = ".$id.") ";...
asked by 10.08.2017 / 21:31
1
answer

Stored Procedure to concatenate a varchar and an incremental integer in fields with repeated data - SQLServer [duplicated]

I need to edit the name of a field (in case it already exists) of my table in my database in SQLServer 2014. • If the @pNameTarea parameter is NULL or empty, an automatic Name is created, this YYMMDD being created and if there is a Task with...
asked by 14.08.2017 / 14:48
1
answer

Error executing two procedures in Codeigniter

The problem is that in a controller I try to execute the two procedures I skip this error:    A Database Occurred Error       Error Number: 2014       Commands out of sync: you can not run this command now       CALL charges ();       F...
asked by 10.08.2017 / 04:21
1
answer

Values by default MVC with entity framework and stored procedures

I have a stored procedure for saving records that has default values. Guardar(@ID int, @autor varchar (20)='anonimo',@isbn int,@titulo varchar(25)='TBD', @descripcion varchar(250)='N/A') public virtual int Guardar(ObjectParameter ID, strin...
asked by 13.07.2017 / 16:26
0
answers

How to execute a procedure in a View? SQL Server 2012

In my Procedure a dynamic query is executed (use PIVOT ) where the last columns are dynamic, so when I want to create the view I have tried to use Openquery and OPENROWSET but always shows the same message.    You...
asked by 12.07.2017 / 01:14