sql server - Invalid length parameter passed to the LEFT or SUBSTRING function in row concatenation -


I get the error "pending invalid length parameter for SUBSTRING function" on this function, it takes numbers from strings Is not like "abracadabra {34}" or in the string "{}" if not, I do not have the "case", but it seems that it does not work properly, definitely with this specific case Works perfectly - "abracdabra {34}", but because of the complex situation, Kshn can not see with the other cases. Maybe you get a mistake, just by looking at a glance. Please help me Function Function (@ NIODOP) Returns Varchar BEGIN DECLARE @Sreturn varchar (1000); SET @sreturn = ''; SELECT @sreturn = CASE CHARINDEX ('{', wp.description) WHEN 0 THEN @Sreturn ELSE @Sreturn + SUBSTRING (wp.description, CHARINDEX ('{', wp.description) + 1, CHARINDEX ('}', WP (Description) - CHARINDEX ('{', wp.description) - 1) + ',' by the end (/ * select some * /) TTT, RB_Worclass YP where wp.classified = ttt.ap depending on the case when CHARINDEX ('{', Wp. [Details])> Then Conversions (INT, SUBSTRING (wp. [Description], CHARINDEX ('{', wp. [Description]) + 1, CHARINDEX ('}', wp . [Description]) - CHARINDEX ('{', wp [details]) - 1)) ELSE 0 END; SET @Sreturn = SUBSTRING (@Sreturn, 1, LEN (@Sreturn) - 1) Return @ Surnder; Finished;

I give more information about this issue In this function, I am trying to migrate any other function from Oracle:

  Creating or changing the function function (numeric number in) returns varchar2 sreturn varchar2 (1000) Select the starting list (to_number (substr (wp.description, instr (wp.description, '{'} + 1, instr (wp.description, '}') - instr (wp.description, '{ ') - 1)),', 'within the group (order by to_number (substr (wp.description, instr (wp.description,' {'} + 1, instr (wp.description,'} ') - instr (Wp.description, '{') - 1))) in sreturn (/ * some selection * /), working ttt WP where wp.classified = ttt.ap; Return sreturn; An exception occurs when others get blank space; End fancy;   

Temporaly I've changed this non-my query, thanks to all the questions like "XML path ('')" Thanks for all, for example just return varchar instead of varchar (50) Due to the fact that there was only one item (in my case)

The error is coming from your order by section. You do not have a condition wrapped in the selection ( case or IIF ). Change your order according to:

  order by case when CHARINDEX ('{', wp. [Description]) & gt; CHARINDEX ('}', wp. [Description]) - CHARINDEX ('{', wp [ Description]) - 1)) ELSE 0 END; In addition, a good idea to specify the return type for  VARCHAR  without any length is  VARCHAR  / The default width of  NVARCHAR  is either 1 or 30, in which it is being said. Since your local variable has been declared as  VARCHAR (1000) , you should use 1000 to declare the output type.   

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -