Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
5| Name | Data Type | Length | Description |
|---|---|---|---|
| @accion | varchar | 20 | |
| @id_provincia | int | 4 | |
| @nombre | varchar | 100 | |
| @country_code | varchar | 4 | |
| @visible | int | 4 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.abm_provincias
@accion varchar(20),
@id_provincia int,
@nombre varchar(100),
@country_code varchar(4),
@visible int
AS
BEGIN
SET NOCOUNT ON;
--insertar
IF @accion = 'INSERT'
BEGIN
if @nombre is not null and @country_code is not null
BEGIN
if @nombre <> '' and @country_code <> ''
BEGIN
insert into provincias(prv_nombre, country_code, pai_codigo_ifx, prv_codigo, visible) values (@nombre, @country_code, 0, 0, 1)
END
END
return
end
---actualizar
IF @accion = 'UPDATE'
BEGIN
if (select count(*) from provincias p WHERE p.idReg = @id_provincia) = 1
begin
if @nombre is not null and @country_code is not null
BEGIN
if @nombre <> '' and @country_code <> ''
BEGIN
update provincias set prv_nombre = @nombre , country_code = @country_code WHERE idReg = @id_provincia
END
END
end
return
end
--- buscar un registro
if @accion = 'SEARCH'
BEGIN
select p.idReg, p.prv_nombre, p.country_code, p.visible, c.country_name from provincias p
left join country c on c.country_code = p.country_code where p.idReg = @id_provincia
return
END
---SELECCIONAR TODAS LAS PROVINCIAS
if @accion = 'SELECT'
BEGIN
select p.idReg, p.prv_nombre, p.country_code, p.visible, c.country_name from provincias p
left join country c on c.country_code = p.country_code
return
END
---SELECCIONAR TODAS LAS PROVINCIAS
if @accion = 'VISIBLE'
BEGIN
if (select count(*) from provincias p WHERE p.idReg = @id_provincia) = 1
begin
if @visible is not null
BEGIN
update provincias set visible = @visible WHERE idReg = @id_provincia
END
end
return
END
if @accion = 'BUSQUEDA-POR-PAISES'
BEGIN
SELECT p.prv_nombre, p.prv_codigo, p.idReg, c.country_name, c.country_code, p.visible, p.codigo_afip FROM provincias p
left join country c on c.country_code = p.country_code where c.country_code = @country_code
return
END
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.abm_provincias
@accion varchar(20),
@id_provincia int,
@nombre varchar(100),
@country_code varchar(4),
@visible int
AS
BEGIN
SET NOCOUNT ON;
--insertar
IF @accion = 'INSERT'
BEGIN
if @nombre is not null and @country_code is not null
BEGIN
if @nombre <> '' and @country_code <> ''
BEGIN
insert into provincias(prv_nombre, country_code, pai_codigo_ifx, prv_codigo, visible) values (@nombre, @country_code, 0, 0, 1)
END
END
return
end
---actualizar
IF @accion = 'UPDATE'
BEGIN
if (select count(*) from provincias p WHERE p.idReg = @id_provincia) = 1
begin
if @nombre is not null and @country_code is not null
BEGIN
if @nombre <> '' and @country_code <> ''
BEGIN
update provincias set prv_nombre = @nombre , country_code = @country_code WHERE idReg = @id_provincia
END
END
end
return
end
--- buscar un registro
if @accion = 'SEARCH'
BEGIN
select p.idReg, p.prv_nombre, p.country_code, p.visible, c.country_name from provincias p
left join country c on c.country_code = p.country_code where p.idReg = @id_provincia
return
END
---SELECCIONAR TODAS LAS PROVINCIAS
if @accion = 'SELECT'
BEGIN
select p.idReg, p.prv_nombre, p.country_code, p.visible, c.country_name from provincias p
left join country c on c.country_code = p.country_code
return
END
---SELECCIONAR TODAS LAS PROVINCIAS
if @accion = 'VISIBLE'
BEGIN
if (select count(*) from provincias p WHERE p.idReg = @id_provincia) = 1
begin
if @visible is not null
BEGIN
update provincias set visible = @visible WHERE idReg = @id_provincia
END
end
return
END
if @accion = 'BUSQUEDA-POR-PAISES'
BEGIN
SELECT p.prv_nombre, p.prv_codigo, p.idReg, c.country_name, c.country_code, p.visible, p.codigo_afip FROM provincias p
left join country c on c.country_code = p.country_code where c.country_code = @country_code
return
END
END
GO
Depends On
2Used By
No items found