Convert SQL to RDMLX?

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Convert SQL to RDMLX?

Post by atostaine »

I have a SQL Statement similar to this that I'd like to convert to RDMLX. The group_by is a problem for RDMLX? This SQL writes one record per group, with a total of QTY. I'd like to write one list entry per group. I've been looking at Keep_total but haven't tried that yet.

I'd rather convert this than use Select_Sql.

insert into Workfile (
shp,sea,sty,clr, fab,mod,msz,qt3)
select ls.shp,ls.sea, ls.sty, ls.clr, ls.fab, ls.mod, ls.msz, sum(ls.qty)
from locsku00 ls
where ls.rid>:invrid and ls.shp=:shp and ls.sty=:sty
and (:clr='*ALL' or clr=:clr)
and (:fab='*ALL' or fab=:fab)
and (:mod='*ALL' or mod=:mod)
and (:msz='*ALL' or msz=:msz)
and (:siz='*ALL' or siz=:siz)
and lp.reg='RCV'
group by
:#sdjb#,ls.shp,
ls.sea, ls.sty, ls.clr,
ls.fab, ls.mod, ls.msz
;

Any ideas appreciated.

Art
Art Tostaine
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Convert SQL to RDMLX?

Post by soa »

Why wouldn't you just build a select_sql statement with using then put the insert inside the loop?
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Convert SQL to RDMLX?

Post by atostaine »

It stinks that I have to create my where by using SqlSelect := 'sty = ' + #quote + '12345' + quote . Lots of room for errors.

Art
Art Tostaine
caseywhite
Posts: 192
Joined: Thu May 26, 2016 1:17 am

Re: Convert SQL to RDMLX?

Post by caseywhite »

You should be able to do this.

#SQL := "sty='" + "12345" + "'"

That is use double quotes instead of single quotes to wrap literals which allows you to use single quotes in the string.
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Convert SQL to RDMLX?

Post by soa »

I think having to handle quotes is a small price to pay for accessing the full functionality of sql within an RDMLX function. The speed improvements over traditional SELECT and FECH type coding can be astounding.
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Convert SQL to RDMLX?

Post by atostaine »

The where parameter of the command should let me build a string with my field names in there.

The quotes aren’t the only thing. You have numeric and dates
To deal with also.
Art Tostaine
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Convert SQL to RDMLX?

Post by soa »

I just built this a couple of minutes ago. Without select_sql I would have had to build two select loops with appropriate logicals and a fetch. I was able to test this select logic in the green screen sql function before hand and I know that if I was to debug this I could add a breakpoint to the select_sql statement then cut and paste to strsql command to check the statement out and modify the text on the fly. Like I said a lot of power, easy to use.

If Cond(#CRSID_CT *EQ *ZERO)
#wrk5000 := 'select STDID, STDSTS, STDNMF, STDGNM from STDENT'
#wrk5000 += ' where CALYR=' + #CALYR_W.AsString
#wrk5000 += ' and STUDYR=' + #STUDYR_W.AsString
#wrk5000 += ' and STDMSI=' + #SCHID_CT.AsString
#wrk5000 += ' order by UPPER(STDNMF), UPPER(STDGNM)'
Else
#wrk5000 := 'select A.STDID, B.STDSTS, B.STDNMF, B.STDGNM from STSCCR A'
#wrk5000 := ' join STDENT B on A.CALYR=B.CALYR and A.STUDYR=B.STUDYR and A.STDID=B.STDID'
#wrk5000 += ' where CALYR=' + #CALYR_W.AsString
#wrk5000 += ' and STUDYR=' + #STUDYR_W.AsString
#wrk5000 += ' and SCHID=' + #SCHID_CT.AsString
#wrk5000 += ' and CRSID=' + #CRSID_CT.AsString
#wrk5000 += ' and STDSTS=' + #QUOTE + 'ACTIV' + #QUOTE
#wrk5000 += ' order by UPPER(STDNMF), UPPER(STDGNM)'
Endif

Select_Sql Fields(#STDID #STDSTS #STDNMF #STDGNM) Io_Error(*NEXT) Using(#WRK5000)
endselect
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Convert SQL to RDMLX?

Post by atostaine »

This doesn’t look like lowcode to me. :)
Art Tostaine
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Convert SQL to RDMLX?

Post by soa »

What is your question? This is how you do SQL with RDML. Perhaps you could make a suggestion in the 'Product Enhancement Forum'
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Convert SQL to RDMLX?

Post by atostaine »

That’s a good idea. I will submit it.

Sql db access is where modern platforms are but LANSA’s OAM’s don’t fit in there very well.

Don’t get mad. I’m a lansa fanboy since 1999.
Art Tostaine
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Convert SQL to RDMLX?

Post by soa »

I agree that in an sql world i/o modules don't make as much sense as they did the rpg days. It should be possible to implement all the validation rules in the repository as native sql constraints and access routes as views etcetera and basically do away with i/o modules but I guess there's only so much they can do. I noticed in the last epc that they've quietly allowed the use of ALTER TABLE for adding fields to files rather than the old $$ copy which is a step forward. It would also be nice if RDML had native a .Net Entity Framework style way of accessing databases but I'm not holding my breath!

Resources are limited but what LANSA has recently delivered with VLWEB Material Design is such a huge leap forward and allows us to easily deliver modern looking web applications for the first time. I'd rather they put their effort in this area even if it means I have to keep on handcrafting SQL!

(not mad)
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Convert SQL to RDMLX?

Post by atostaine »

soa wrote: Fri Aug 31, 2018 1:21 pm Resources are limited but what LANSA has recently delivered with VLWEB Material Design is such a huge leap forward and allows us to easily deliver modern looking web applications for the first time. I'd rather they put their effort in this area even if it means I have to keep on handcrafting SQL!
(not mad)
LOL. Ok. I agree VLWEB is fantastic. We are live with many applications on Ipad's and every other kind of device.

Art
Art Tostaine
Post Reply