ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

how to convert this front-end SQL to AS400 SQLRPGLE

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to convert this front-end SQL to AS400 SQLRPGLE

    Hi guys,

    my team have a dilema if we can code this in the SQLRPGLE. This is a front end SQL function. and i am not sure how to code this on our end.

    Code:
    declare @string varchar(500)
    set @string = ?ABC,DEF,GHIJK,LMNOPQRS,T,UV,WXY,Z?
    
    declare @pos int
    declare @piece varchar(500)
    
    ? Need to tack a delimiter
    if right(rtrim(@string),1) <> ?,?
     set @string = @string  + ?,?
    
    set @pos =  patindex(?%,%? , @string)
    while @pos <> 0 
    begin
     set @piece = left(@string, @pos ? 1)
     
     ? do whatever you want to with it.
     print cast(@piece as varchar(500))
    
     set @string = stuff(@string, 1, @pos, ?)
     set @pos =  patindex(?%,%? , @string)
    end
    thanks for the info.
    idiot and stoopid with SQL
Working...
X