Solved

WebFocus to DB2 conversion

Posted on 2014-04-30
5
939 Views
Last Modified: 2014-05-15
Hello,

I am having trouble converting the LAST function in WebFocus to DB2. The 'last' function in webfocus returns the last value returned for a column.

for example in WebFocus:
somevar/A5 = if (col_a ne last col_a) then 'AB' else 'CD'

what would be the equivalent to that in DB2?
0
Comment
Question by:CodeWrangler
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:daveslash
ID: 40032807
Could you explain the LAST function a bit more? Your example doesn't appear to reference that function.
0
 
LVL 45

Expert Comment

by:Kdo
ID: 40032814
Hi Wrangler,

There isn't an equivalent in DB2.  If you're using cursors to view rows one at a time, the easiest way is to just save the column value into a "last" variable whenever you fetch another row.


Kent
0
 

Author Comment

by:CodeWrangler
ID: 40032828
Kent - yeah, im starting to think that might be the way to go about it..

Dave - note the word 'last' enclosed in the if statement. you can look up some info on it using google. Basically, if the last value of col_a matches the current value of col_a then do something.
0
 

Author Comment

by:CodeWrangler
ID: 40033006
Kent - do you have any good examples (resources) of DB2 cursors?
0
 
LVL 45

Accepted Solution

by:
Kdo earned 500 total points
ID: 40033021
Here's a really short example that I copied from elsewhere...


create procedure DEPARTMENT_SALARY
  (in v_depno varchar(3), out v_totalsalary decimal(9,2))
begin
  declare SQLCODE  integer     default 0;
  declare i        decimal(9,2);
  declare mycur cursor for
      select SALARY
      from EMPLOYEE
      where WORKDEPT = v_depno;

  set v_totalsalary = 0;
  open mycur;
  fetch mycur into i;
  while SQLCODE <> 100
   do
     set v_totalsalary = v_totalsalary + i;
     fetch mycur into i;
  end while;
  close mycur;
end!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
report returning null 21 92
VBA MS Word "Table of Contents" extractor` 4 38
AWS RDS Backups? 3 36
Slow MySQL (InnoDB) Query with Inner Join & GroupBy 7 40
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now