Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] How to Return a 1 if nothing to SELECT

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] How to Return a 1 if nothing to SELECT
 Login/Join
 
Member
posted
I have a SQL statement for a table insert that will put incrementally the next number available into an ID field see below

(SELECT MAX(IDSTANDARD)+1 FROM STANDARD)

Works great if there is at least 1 item in the STANDARD table. If there are no items i would like to default it to 1. Any ideas?

This message has been edited. Last edited by: Kerry,


WebFOCUS 7.6.8
Unix
ALL
 
Posts: 15 | Registered: March 31, 2009Report This Post
Expert
posted Hide Post
Try the COALESCE function with SQL.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Platinum Member
posted Hide Post
CASE should work as well.

CASE WHEN (SELECT MAX(IDSTANDARD)+1 FROM STANDARD) > 1
THEN (SELECT MAX(IDSTANDARD)+1 FROM STANDARD)
ELSE 1
END


WebFOCUS: 7702
O/S : Windows
Data Migrator: 7702
 
Posts: 127 | Location: San Antonio | Registered: May 29, 2009Report This Post
Virtuoso
posted Hide Post
Which database are you working against? If it's Oracle, the NVL function may help.

...,
NVL((SELECT MAX(IDSTANDARD) + 1 FROM STANDARD), 1)
,...

This message has been edited. Last edited by: njsden,



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Platinum Member
posted Hide Post
Good idea, njsden. In DB2, the NULLIF function would work the same way.


WebFOCUS: 7702
O/S : Windows
Data Migrator: 7702
 
Posts: 127 | Location: San Antonio | Registered: May 29, 2009Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] How to Return a 1 if nothing to SELECT

Copyright © 1996-2020 Information Builders