Substring selection in Stored Procedure
Posted in 1999
Topics: Stored Procedures & SPL, Versions, Editions & End-of-Life
Hi Does anybody knows if there is a way of perform a substring selection inside a stored procedure ??? I'm sending an example above, wich is Hope somebody can help me Thanks in advance for k = 1 to 10 select vllimite[k] from tab1 where 1=1;with a syntax error, but I don't know how to handle with this. I'm using IDS 7.31 end for -- Paulo Roberto Marelli de Amorim TS&0 Consulting Brasil Sent via Deja.com http://www.deja.com/ Before you buy.
Substringing can be done either of 2 ways using inline substring notation: column[start,end] or if you have v7.30+ using htenew substr() function: substr(column,start,end) You just did not specify the second parameter to the inline substring expression, ie the ending position. So that query S/B: select vllimite[k,k] from tab1 where 1=1; But you have another problem which will cause a problem unless table 'tabl' has only one row. It is an error to SELECT more than one row from a table without a cursor so you will have to make the where clause more specific or create a cursor. Assuming that vllimite is a local variable and not a column in 'tabl' there is a better way to get a single value using SELECT to return calculation results is: select vllimite[k,k] from systables where tabid = 1; Art S. Kagel Paulo Amorim wrote: > > Hi > > Does anybody knows if there is a way of perform a substring selection > inside a stored procedure ??? I´m sending an example above, wich is > Hope somebody can help me > Thanks in advance > > for k = 1 to 10 > select vllimite[k] from tab1 where 1=1;with a syntax error, but I > don´t know how to handle with this. > I´m using IDS 7.31 > > end for > > -- > Paulo Roberto Marelli de Amorim > TS&0 Consulting > Brasil > > Sent via Deja.com http://www.deja.com/ > Before you buy.
Almost correct (sorry Art). Column[k] is acceptable syntax. Same as column[k,k] More important, k cannot be a variable. It must be a hardcoded value (e.g Column[1], Column[2],... but not Column[k]). A variable can only be used with substr(). -- Bashar Chalabi CTL, London Art S. Kagel <kagel@bloomberg.net> wrote in message news:386A6D07.8D926DF@bloomberg.net... > Substringing can be done either of 2 ways using inline substring notation: > > column[start,end] > > or if you have v7.30+ using htenew substr() function: > > substr(column,start,end) > > You just did not specify the second parameter to the inline substring > expression, ie the ending position. So that query S/B: > > select vllimite[k,k] from tab1 where 1=1; > > But you have another problem which will cause a problem unless table 'tabl' > has only one row. It is an error to SELECT more than one row from a table > without a cursor so you will have to make the where clause more specific or > create a cursor. Assuming that vllimite is a local variable and not a > column in 'tabl' there is a better way to get a single value using SELECT to > return calculation results is: > > select vllimite[k,k] from systables where tabid = 1; > > Art S. Kagel > > Paulo Amorim wrote: > > > > Hi > > > > Does anybody knows if there is a way of perform a substring selection > > inside a stored procedure ??? I'm sending an example above, wich is > > Hope somebody can help me > > Thanks in advance > > > > for k = 1 to 10 > > select vllimite[k] from tab1 where 1=1;with a syntax error, but I > > don't know how to handle with this. > > I'm using IDS 7.31 > > > > end for > > > > -- > > Paulo Roberto Marelli de Amorim > > TS&0 Consulting > > Brasil > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy.