Error 208, Ayuda favor | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Error 208, Ayuda favor

hola a todos
Tengo un sp, que al momento de ejecutarlo de esta forma:
execute sp_mic_cuentas ‘0000102232640’,null,’C’,null
en el profiler puedo notar que me da 3 execepciones que apunta a lo mismo:
Error: 208, Severity: 16, State: 0
Pero no se porque da esto:
Adjunto el sp yla definición de las tablas.
Cabe recalcar que estoy trabajando con SQLServer 2000 con sp3a.
Gracias por su ayuda y orientación. –CREATE procedure sp_mic_cuentas
( @i_cliente varchar(20) = null,
@i_cta varchar(10) = null,
@i_operacion char(1) = null,
@i_tabla char(1) = null
) as
declare
@w_cliente varchar(20),
@w_statuschar(1),
@w_oficial int,
@w_nombre_ofc varchar(25),
@w_fechadatetime,
@w_remesas float,
@w_24h float,
@w_12h float,
@w_disponible float,
@w_error int,
@w_desc_error varchar(64) — obtengo el codigo del cliente
if datalength(@i_cliente) = 13 –viene del call
select @w_cliente = cliente
from clientes
where numero_identificacion = @i_cliente
else
select @w_cliente = @i_cliente if @i_operacion = ‘C’
begin
create table #mic_cuentas
(
mic_cliente int null,
mic_oficial int null,
mic_cta varchar(10) null,
mic_saldo float null,
mic_tipo_ctachar(1) null
) — selecciono las cuentas AHORROS
insert into #mic_cuentas
select @w_cliente,
oficial,
cuenta_ah,
(RET_REMESAS + RET_24H + RET_12H + DISPONIBLE),
‘A’
from ahorros
where cliente = @w_cliente — selecciono las cuentas CORRIENTES
insert into #mic_cuentas
select @w_cliente,
oficial,
cuenta_cte,
(RET_REMESAS + RET_24H + RET_12H + DISPONIBLE),
‘C’
from ctacte
where cliente = @w_cliente — retorno al front end
select mic_cta,
mic_saldo,
mic_tipo_cta,
mic_oficial
from #mic_cuentas
where mic_cliente = @w_cliente
end if @i_operacion = ‘E’
begin
if @i_tabla = ‘A’
begin
select @w_status = status,
@w_oficial = oficial,
@w_fecha = fecha_apertura,
@w_remesas = RET_REMESAS,
@w_24h = RET_24H ,
@w_12h = RET_12H,
@w_disponible = DISPONIBLE
from ahorros
where cliente = @w_cliente
and cuenta_ah = @i_cta
end if @i_tabla = ‘C’
begin
select @w_status = status,
@w_oficial = oficial,
@w_fecha = fecha_ap,
@w_remesas = RET_REMESAS,
@w_24h = RET_24H ,
@w_12h = RET_12H,
@w_disponible = DISPONIBLE
from ctacte
where cliente = @w_cliente
and cuenta_cte = @i_cta
end — obtengo el nombre del oficial
select @w_nombre_ofc = nombre
from oficiales
where oficial = @w_oficial — retorno al front end
select ‘Estado’ = @w_status,
‘Oficial’ = ltrim(rtrim(convert(char(10),@w_oficial))) + ‘ (‘ +
ltrim(rtrim(@w_nombre_ofc)) + ‘)’,
‘Remesas’ = @w_remesas,
’24h’ = @w_24h,
’12h’ = @w_12h,
‘Disponible’ = @w_disponible,
‘Fecha’ = @w_fecha
end
CREATE TABLE dbo.CLIENTES
(
CLIENTE int NOT NULL,
NOMBRE varchar(96) NULL,
DIRECCION varchar(255) NULL,
TELEFONO varchar(12) NULL,
PROFESION varchar(40) NULL,
TASA_PROV varchar(7) NULL,
LOG varchar(7) NULL,
PASSWORD varchar(6) NULL,
DEP_EFECTIVO varchar(7) NULL,
DEP_PLAZO float NULL,
REFERENCIAS varchar(40) NULL,
TIPO_CLIENTE varchar(10) NULL,
OFICINA_APERTURA varchar(3) NULL,
TIPO_IDENTIFICACION varchar(1) NULL,
NUMERO_IDENTIFICACION varchar(30) NULL,
FECHA_APERTURA datetime NULL,
NO_OFICIAL varchar(3) NULL,
ACTIVIDAD varchar(10) NULL,
GRUPO_ECONOMICO varchar(6) NULL,
ORIGEN_PROV varchar(1) NULL,
STATUS varchar(2) NULL,
PATRIMONIO float NULL,
CALIFICACION varchar(10) NULL,
FLAG_IMPTO varchar(1) NULL,
DEP_CHEQ varchar(50) NULL,
SECTOR_BCE varchar(10) NULL,
IMPTO_RENTA varchar(1) NULL,
FECHA_NACIMIENTO datetime NULL,
FILLER varchar(3) NULL,
FECHA_ACT_PAT datetime NULL,
VINCULA varchar(10) NULL,
cl_dir_trabajo varchar(255) NULL,
CONSTRAINT PK_CLIENTES_1
PRIMARY KEY NONCLUSTERED (CLIENTE) WITH FILLFACTOR=90
ON [PRIMARY]
)
CREATE TABLE dbo.CTACTE
(
cuenta_cte varchar(10) NULL,
cliente int NULL,
status char(1) NULL,
tipo int NULL,
cod_mon tinyint NULL,
categoria char(1) NULL,
oficial smallint NULL,
ciclo char(1) NULL,
michoficha int NULL,
tipo_cliente int NULL,
cobro_estado int NULL,
bloqueo_fecha datetime NULL,
bloqueo_oficial int NULL,
fecha_ap datetime NULL,
fecha_cierre datetime NULL,
ret_remesas float NULL,
ret_24h float NULL,
ret_12h float NULL,
disponible float NULL,
cr_24h float NULL,
fecha_aut_24h datetime NULL,
fecha_ven_24h datetime NULL,
cr_rem float NULL,
fecha_aut_rem datetime NULL,
fecha_ven_rem datetime NULL,
sob_ocasional float NULL,
fecha_aut_ocas datetime NULL,
fecha_vig_ocas datetime NULL,
fecha_ven_ocas datetime NULL,
fecha_liq_ocas datetime NULL,
ocas_utilizado int NULL,
tot_ocas_util int NULL,
ocas_mora int NULL,
dias_ocas smallint NULL,
cont_utilizado int NULL,
sob_contratado float NULL,
nro_contratado int NULL,
fecha_aut_cont datetime NULL,
fecha_ven_cont datetime NULL,
interes_cont int NULL,
comision_cont int NULL,
fecha_con_cont int NULL,
tot_cont_util int NULL,
dias_cont smallint NULL,
nro_revocados int NULL,
nro_protestados int NULL,
protesto_ano tinyint NULL,
fecha_utl_mov datetime NULL,
saldo_utl_corte float NULL,
saldo_ayer float NULL,
tipo_prom char(1) NULL,
promedio_1 float NULL,
promedio_2 float NULL,
promedio_3 float NULL,
promedio_4 float NULL,
promedio_5 float NULL,
promedio_6 float NULL,
ult_sec_hist int NULL,
ult_item int NULL,
ult_mov_dia int NULL,
dias_consecutivo int NULL,
mov_dia_control int NULL,
nromov_mes int NULL,
ofic_reten int NULL,
ult_sec_hist_ant int NULL,
saldo_ult_corte_ant float NULL,
ult_cheque int NULL,
ret_36h int NULL,
despacho int NULL,
ind_costos int NULL,
int_acum int NULL,
senal_int int NULL,
tot_dep int NULL,
dev_loc int NULL,
dev_rem int NULL,
mes_dep int NULL,
mes_loc int NULL,
mes_rem int NULL,
num_loc int NULL,
num_rem int NULL,
dep_efec_mes int NULL,
cupo_dep int NULL,
int_suspenso int NULL,
efectivo_dia int NULL,
cuenta_ant int NULL,
sec_dep int NULL,
valid_chequera int NULL,
oper int NULL,
valida_cheque int NULL,
remesas_dia int NULL,
tipo_publico int NULL,
impuesto int NULL,
saldo_bloqueo int NULL,
senal_nombre int NULL,
moneda_ant int NULL,
roles char(1) NULL,
log int NULL,
dep_inicial tinyint NULL,
prom_liq float NULL,
pag_max int NULL,
filler int NULL,
cc_cuenta int NULL
)
goCREATE TABLE dbo.AHORROS
(
cuenta_ah varchar(10) NOT NULL,
cliente int NULL,
status char(1) NULL,
tipo_cuenta varchar(2) NULL,
cod_mon tinyint NULL,
categoria int NULL,
oficial smallint NULL,
tipo_promedio char(1) NULL,
tipo_control_mov char(1) NULL,
saldo_ult_corte float NULL,
saldo_int_ult float NULL,
nro_movimientos int NULL,
ult_sec_hist int NULL,
ult_item int NULL,
fecha_apertura datetime NULL,
fecha_cierre datetime NULL,
ret_remesas float NULL,
ret_24h float NULL,
ret_12h float NULL,
disponible float NULL,
saldo_interes float NULL,
linea_cr_24h char(1) NULL,
fecha_aut_24h datetime NULL,
fecha_ven_24h datetime NULL,
linea_cr_rem char(1) NULL,
fecha_aut_rem datetime NULL,
fecha_ven_rem datetime NULL,
fecha_ult_mov datetime NULL,
saldo_ayer float NULL,
saldo_libreta float NULL,
pri_linea smallint NULL,
ult_linea smallint NULL,
nro_lineas smallint NULL,
bloqueos float NULL,
bloqueos_ult smallint NULL,
debitos float NULL,
creditos float NULL,
promd_actual float NULL,
promd_1_per_ant float NULL,
promd_2_per_ant float NULL,
ult_trm_rrn int NULL,
real_ult_mov int NULL,
nromov_trim int NULL,
bloqueos_ult_rrn smallint NULL,
oficina smallint NULL,
ret_36h float NULL,
saldo_int1 float NULL,
saldo_int2 int NULL,
senal_tope int NULL,
num_libreta int NULL,
porcint int NULL,
dep_efec_mes int NULL,
cupo_dep int NULL,
ind_costos int NULL,
oper int NULL,
remesas_dia float NULL,
impuesto_1 int NULL,
saldo_bloqueo int NULL,
senal_nombre int NULL,
moneda_ant int NULL,
roles char(1) NULL,
log1 int NULL,
promd_3_per_ant float NULL,
dep_inicial tinyint NULL,
pag_max int NULL,
filler int NULL,
ah_cuenta int NULL
)
go

El problema más común (20<img src=’/community/emoticons/emotion-11.gif’ alt=’8)’ /> es que algún campo no sabe de qué tabla tomarlo.<br /><br />Por ejemple el campo "oficio" figura en la tabla ctacte y ahorros.<br />Verifica sino tienes que calificar a cada uno de esos campos, es decir ctacte.oficio y ahorros.ctacte.<br /><br />Si no lo encuentras, escríbe nuevamente y trataré de reproducir el error.<br /><br /><br /><br />Luis Martin<br />Moderator<br />SQL-Server-Performance.com<br /><br /><font size="1">All in Love is Fair <br />Stevie Wonder<br /></font id="size1"><br /><br /><font size="1">All postings are provided “AS IS” with no warranties for accuracy.</font id="size1"><br /><br /><br /><br />
Gracias por la aclaración Luis.
Le cuento que hice los cambios en el sps, y hasta lo que he visto ya no sale el error 208. Sin embargo quisiera saber si donde he colacado el nombre de la tabla esta bien o solo debería colocar en los campos del select y no en la condición where:
Gracias por vuestra ayuda. ALTER procedure sp_mic_cuentas
( @i_cliente varchar(20) = null,
@i_cta varchar(10) = null,
@i_operacion char(1) = null,
@i_tabla char(1) = null
) as
declare
@w_cliente varchar(20),
@w_statuschar(1),
@w_oficial int,
@w_nombre_ofc varchar(25),
@w_fechadatetime,
@w_remesas float,
@w_24h float,
@w_12h float,
@w_disponible float,
@w_error int,
@w_desc_error varchar(64) — obtengo el codigo del cliente
if datalength(@i_cliente) = 13 –viene del call
select @w_cliente = cliente
from clientes
where clientes.numero_identificacion = @i_cliente
else
select @w_cliente = @i_cliente if @i_operacion = ‘C’
begin
create table #mic_cuentas
(
mic_cliente int null,
mic_oficial int null,
mic_cta varchar(10) null,
mic_saldo float null,
mic_tipo_ctachar(1) null
) — selecciono las cuentas AHORROS
insert into #mic_cuentas
select @w_cliente,
ahorros.oficial,
cuenta_ah,
(RET_REMESAS + RET_24H + RET_12H + DISPONIBLE),
‘A’
from ahorros
where ahorros.cliente = @w_cliente — selecciono las cuentas CORRIENTES
insert into #mic_cuentas
select @w_cliente,
ctacte.oficial,
cuenta_cte,
(RET_REMESAS + RET_24H + RET_12H + DISPONIBLE),
‘C’
from ctacte
where ctacte.cliente = @w_cliente — retorno al front end
select mic_cta,
mic_saldo,
mic_tipo_cta,
mic_oficial
from #mic_cuentas
where mic_cliente = @w_cliente
end if @i_operacion = ‘E’
begin
if @i_tabla = ‘A’
begin
select @w_status = ahorros.status,
@w_oficial = ahorros.oficial,
@w_fecha = ahorros.fecha_apertura,
@w_remesas = ahorros.RET_REMESAS,
@w_24h = ahorros.RET_24H ,
@w_12h = ahorros.RET_12H,
@w_disponible = ahorros.DISPONIBLE
from ahorros
where ahorros.cliente = @w_cliente
and ahorros.cuenta_ah = @i_cta
end if @i_tabla = ‘C’
begin
select @w_status = status,
@w_oficial = oficial,
@w_fecha = fecha_ap,
@w_remesas = RET_REMESAS,
@w_24h = RET_24H ,
@w_12h = RET_12H,
@w_disponible = DISPONIBLE
from ctacte
where cliente = @w_cliente
and cuenta_cte = @i_cta
end — obtengo el nombre del oficial
select @w_nombre_ofc = nombre
from oficiales
where oficiales.oficial = @w_oficial — retorno al front end
select ‘Estado’ = @w_status,
‘Oficial’ = ltrim(rtrim(convert(char(10),@w_oficial))) + ‘ (‘ + ltrim(rtrim(@w_nombre_ofc)) + ‘)’,
‘Remesas’ = @w_remesas,
’24h’ = @w_24h,
’12h’ = @w_12h,
‘Disponible’ = @w_disponible,
‘Fecha’ = @w_fecha
end
GO
En los dos lados. Una forma de clarificar la escritura es calificar las tablas. Por ejemplo en lugar de: select @w_nombre_ofc = nombre
from oficiales
where oficiales.oficial = @w_oficial escribir select @w_nombre_ofc = nombre
from oficiales as of
where of.oficial = @w_oficial
Luis Martin
Moderator
SQL-Server-Performance.com All in Love is Fair
Stevie Wonder
All postings are provided “AS IS” with no warranties for accuracy.
Te cuento que pese al cambio igual sigue saliendo el error.
Aún no he hecho el cambio con los sinónimos o segunda forma. Perp iguial debería de funcionar. Sin embargo no se porque en algunos momentos como que deja de salir el error pero en otros continua.
Esta forma de clarificar la escritura también aplica a tablas temporales # o esas no se las debe considerar.
También las puedes aplicar a las temporales sin problema. No entiendo porque algunas veces aparece y otras no el error. Lo mejor parece normalizar todo con los sinónimos y ver que pasa.
Luis Martin
Moderator
SQL-Server-Performance.com All in Love is Fair
Stevie Wonder
All postings are provided “AS IS” with no warranties for accuracy.
]]>