![]() Thank you very much! RE: SIMPLE SQL EXAMPLE rstitzel (MIS) The program that I'm trying to create as a test is a simple Customer Address Listing.Ĭ+ SELECT CustNum, CustName, CustAddr, CustCity, CustState, CustZip from CUSTMAST If someone could please post a small complete RPG program using embedded SQL statements that would be great. I've read some of SQL posts in this forum but only see snippets of code and don't understand all of it. Can I do the select, dow not %eof(WMCUST), do some calcs, perform the select again, enddo Assuming the SELECT statement is like a READ (one record at a time) I would have to "wrap" the SELECT statement in a loop? Not sure how this would be coded. I have a lot of questions and an example probably would answer most. If we checked directly for = 0 then it will return the status of the last cursor operation whichever it was.I've decided to start to try using SQL in my RPG programs as I'm reading that there are some advantages and I also want to broaden my skills. This helps preserve the state of the cursors since we are using multiple cursors together. Once each table is retrieved in a cursor we stored the in a variable.',' + as varchar(30)) + '-' + as varchar(30))įetch next from into = next from outer_cursor into = match_cursor Select top 100 id, stationid, trackid, date, matchtimestart, matchtimeend, streamfileįrom matches where trackid = order by MatchTimeStart ĭeclare outer_cursor cursor static local forįetch next from outer_cursor into = 0 The T-SQL code is given below in the form of a Stored Procedure.Īlter PROCEDURE. Obviously it makes much more sense to simply do a JOIN, but this code is more to show nested cursor looping than do anything particularly useful. The example T-SQL code shows how to iterate rows in matches and then fetch the track row for that track from the track table. matches – table which stores tracks matched in external dataĪs you can see in the table rows below, the Id field of the track table is the foreign key in the matches table in the form of trackId. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |