CEGE
asked on
SQL syntax
Hello:
Can someone please help me with this SQL syntax. why is it giving me this error:
Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'THEN'.
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near 'ELSEIF'.
Can someone please help me with this SQL syntax. why is it giving me this error:
Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'THEN'.
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near 'ELSEIF'.
IF [g_entr_espec_est]=NULL THEN
SELECT [dbo].[PreferenciasCliente].[EspecEst] from [dbo].[PreferenciasCliente] where [dbo].[PreferenciasCliente].[CodigoCliente] = [g_concat_codigo]
ELSEIF NOT([g_entr_espec_est]=NULL) THEN
select [dbo].[PreferenciasCliente].[EspecEst] from [dbo].[PreferenciasCliente] where [dbo].[PreferenciasCliente].[CodigoCliente] = [g_concat_codigo_dir]
IF [g_entr_espec_est] is NULL
begin
SELECT [dbo].[PreferenciasCliente ].[EspecEs t] from [dbo].[PreferenciasCliente ] where [dbo].[PreferenciasCliente ].[CodigoC liente] = [g_concat_codigo]
end
else if [g_entr_espec_est] is not NULL)
begin
select [dbo].[PreferenciasCliente ].[EspecEs t] from [dbo].[PreferenciasCliente ] where [dbo].[PreferenciasCliente ].[CodigoC liente] = [g_concat_codigo_dir]
end
begin
SELECT [dbo].[PreferenciasCliente
end
else if [g_entr_espec_est] is not NULL)
begin
select [dbo].[PreferenciasCliente
end
Hi,
YOu have some mistakes in your code, here is the correct one:
You can find me on: www.extremedev.blogspot.com
YOu have some mistakes in your code, here is the correct one:
IF [g_entr_espec_est]=NULL
SELECT [dbo].[PreferenciasCliente].[EspecEst] from [dbo].[PreferenciasCliente] where [dbo].[PreferenciasCliente].[CodigoCliente] = [g_concat_codigo]
ELSE IF NOT([g_entr_espec_est]=NULL)
select [dbo].[PreferenciasCliente].[EspecEst] from [dbo].[PreferenciasCliente] where [dbo].[PreferenciasCliente].[CodigoCliente] = [g_concat_codigo_dir]
You can find me on: www.extremedev.blogspot.com
roma1123. Your code is still incorrect. You don't check for NULL using the = operator. You check for using "is". angelIII's code is the best answer.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks, this last code works well, but what would I need to do for it to execute based on another variable? like if espec_chk=0 then (execute code), but if espec_chk=0, then do nothng.
thanks.
joseph
thanks.
joseph
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the deal is that I am using a BPM which has an SQL action tool, that executes SQL code and returns a value. What i've done is create two actions. One that goes to the table and pulls info in for a specific register, there may or may not be. Then In the BPM I evaluate it, and then in a second step, depending on chk value, it should pull in the generic information.
if [l_entr_espec_est_chk] =1 then
select [dbo].[PreferenciasCliente ].[EspecEs t] from [dbo].[PreferenciasCliente ] where [CodigoCliente] = [g_codcli]
(but this is not accepted by the BPM SQL area)
thanks.
if [l_entr_espec_est_chk] =1 then
select [dbo].[PreferenciasCliente
(but this is not accepted by the BPM SQL area)
thanks.
ASKER
thanks for the help.
what you actually see to want is this:
Open in new window