<HTML >
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3268" name=GENERATOR></HEAD>
<BODY >
<DIV>
<DIV dir=ltr align=left><SPAN class=515471518-05032008><FONT face=Arial
color=#0000ff size=2>Here's something I got to work:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=515471518-05032008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=515471518-05032008><FONT face=Arial
color=#0000ff size=2>screen t<BR>temp sk_flag char*1<BR>declare x cursor for
select branch, city, branch as sk from branches where (:sk_flag = 'B') union all
select branch, city, city as sk from branches where (:sk_flag = 'C')<BR>cursor x
occurs 10<BR>access request sk_flag orderby sk<BR>field sk_flag<BR>align (,,1)
(,,25) (,,50)<BR>cluster occurs with x<BR>field sk size 20<BR>field branch size
20<BR>field city size 20</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=515471518-05032008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=515471518-05032008><FONT face=Arial
color=#0000ff size=2>When you do a find on this screen, you're prompted for
sk_flag. Entering a B results in a sequence by Branch and entering C results in
a sequence by City. Note that the temp sk_flag must be declared before the
cursor. It's the cursor statement where the SQL is parsed. For some reason I had
to put the orderby on the access statement. I kept getting syntax errors when I
put it on the declare cursor.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=515471518-05032008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=515471518-05032008><FONT face=Arial
color=#0000ff size=2>I'm sure you could run a DESIGNER procedure from your
function keys that set sk_flag and did a PUSH FIND or something
similar.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=515471518-05032008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=515471518-05032008><FONT face=Arial
color=#0000ff size=2>Bob</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
powerh-l-bounces+bob.deskin=cognos.com@lists.sowder.com
[mailto:powerh-l-bounces+bob.deskin=cognos.com@lists.sowder.com] <B>On Behalf
Of </B>Ken Langendock<BR><B>Sent:</B> March 5, 2008 11:17 am<BR><B>To:</B>
powerh-l@lists.sowder.com<BR><B>Subject:</B> Help with Cursor in
QDESIGN<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial size=2>Hello all, I need
some help with making my screen work the way I want it
too.</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial size=2>I have a table
(simplified version):</FONT></SPAN><SPAN class=247380616-05032008><FONT
face=Arial size=2></FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Courier size=2>RECORD
Users</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Courier size=2> UserId
CHARACTER * 8, &</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Courier size=2> UserName
CHARACTER * 40</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial size=2>On a screen the
User can select to view the data in UserId or UserName order by
means of a function key (toggle switch).</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial size=2>I use a variable
(not actual syntax)</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Courier size=2>Element T-Option
CHARACTER * 1 </FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Courier size=2> Values
"C" CAPTION "Code" </FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Courier
size=2> "D" CAPTION
"Description"</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial size=2>In my screen I
created a cursor to handle the orderby but I have no idea if I can "override"
a field size in the statement.</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial size=2>See below,
SortField needs to be the same size (character * 40) for the Cursor to work
but I can't get the syntax to work.</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial size=2>Maybe this needs a
declare clause embedded...not sure</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Courier size=2>@if
ORACLE<BR>SQL IN MYDB &<BR> DECLARE UsersCursor CURSOR FOR
&<BR> SELECT Users.UserId,
&<BR>
Users.UserName,
&<BR>
<FONT color=#ff0000>Users.UserName AS SortField
&<BR></FONT> FROM Users
&<BR> WHERE 'D' = :T-Option
&<BR> UNION ALL &<BR> SELECT
Users.UserId,
&<BR>
Users.UserName,
&<BR>
<FONT color=#ff0000>Users.UserId AS SortField
&<BR></FONT> FROM Users
&<BR> WHERE 'C' = :T-Option
&<BR> ORDER BY SortField</FONT></SPAN></DIV>
<DIV><FONT face=Courier size=2></FONT> </DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Courier size=2>CURSOR
UsersCursor PRIMARY &<BR> ALIAS Users
&<BR> OCCURS 17<BR>@else<BR>FILE Users
PRIMARY &<BR> OCCURS 17<BR> ACCESS VIA
UserId &<BR>
SEQUENTIAL<BR>@endif<BR></FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Courier size=2>Any help would
be appreciated.</FONT></SPAN></DIV>
<DIV><SPAN class=247380616-05032008><FONT face=Courier
size=2>Ken</DIV></FONT></SPAN>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> </DIV></BLOCKQUOTE></DIV>
<DIV> </DIV>
<DIV> This message may contain privileged and/or confidential information. If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so. Thank you. </DIV></BODY></HTML>