Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 28th, 2006, 06:35 PM
kon kon is offline
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select iif problem

Does anyone know how I can use iif in this statement?
This is a foxpro code that works,

SELECT esm_namf as First_Name, esm_naml as Last_Name, ;

[<a href="View.rep?esm_id=] + TRANSFORM(esm_id) + [">View</a> | ] +;

[<a href="Create.rep?mode=edit&menu=1&esm_id=] + TRANSFORM(esm_id) +[">Edit</a> ] as action;

FROM TEsm ORDER BY First_Name ASC;
INTO CURSOR TQuery

But I have a problem:

if the esm_id=1 I want to show
[<a href="View.rep?esm_id=] + TRANSFORM(esm_id) + [">View</a> | ] +;

but if esm_id is not =1 I want to show both
[<a href="View.rep?esm_id=] + TRANSFORM(esm_id) + [">View</a> | ] +;

[<a href="Create.rep?mode=edit&menu=1&esm_id=] + TRANSFORM(esm_id) +[">Edit</a> ] as action;

This is a foxpro program, but maybe some sql programer can resolve for me.

I tried to use iif in several ways but I couldn't resolve.

Thanks
Kon

 
Old March 28th, 2006, 10:34 PM
kon kon is offline
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, I have already resolved the problem above.
But I have another one

I have the source code:

SELECT esm_namf as First_Name, esm_naml as Last_Name, ;
IIF(esmid == esm_id, ;
[<a href="ViewEsm.rep?esm_id=] + TRANSFORM(esm_id) + [">View</a> | ] +;
[<a href="CreateEditEsm.rep?mode=edit&menu=1&esm_id=] + TRANSFORM(esm_id) + [">Edit</a> ], ;
[<a href="ViewEsm.rep?esm_id=]+TRANSFORM(esm_id)+[">Kon</a>]) as action;
  WHERE esm_id > 0 FROM TEsm;
  ORDER BY First_Name ASC;
  INTO CURSOR TQuery

When esmid is equal as esm_id the program should show this 2 links

[<a href="ViewEsm.rep?esm_id=] + TRANSFORM(esm_id) + [">View</a> | ] +;
[<a href="CreateEditEsm.rep?mode=edit&menu=1&esm_id=] + TRANSFORM(esm_id) + [">Edit</a> ], ;

BUUTTT it's just showing the first one (View), never the Edit one appears.

Does anyone knows why?

Thanks again
Kon

 
Old March 28th, 2006, 11:24 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

What code are you writing here?

What are all the [ and ] all about in your code?

You are using a + when you should be using a & if your are trying to write ASP. If so replace:

[<a href="ViewEsm.rep?esm_id=] + TRANSFORM(esm_id) + [">View</a> | ] +;
[<a href="CreateEditEsm.rep?mode=edit&menu=1&esm_id=] + TRANSFORM(esm_id) + [">Edit</a> ], ;

With:

<a href="ViewEsm.rep?esm_id="<%= TRANSFORM(esm_id) %>">View</a>
<a href="CreateEditEsm.rep?mode=edit&menu=1&esm_id=<% = TRANSFORM(esm_id) %>">Edit</a>

Should this post be in the SQL section of the forum? I cant see an SQL related problem here. Sorry if I have completely mis understood and mis read your post

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
IIf umeshtheone Beginning VB 6 3 June 21st, 2007 12:24 AM
IIf problem Vince_421 Access 1 June 1st, 2006 11:35 AM
select problem mildge SQL Language 2 May 18th, 2004 06:35 PM
Select Within A Select Problem vinyl-junkie Classic ASP Databases 6 June 7th, 2003 04:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.