Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EGL Development Tools » How do I know if a GET succeeded in fetching the record?
How do I know if a GET succeeded in fetching the record? [message #811661] Fri, 02 March 2012 17:04 Go to next message
Daniel Rippa is currently offline Daniel RippaFriend
Messages: 10
Registered: March 2012
Junior Member
I'm posting some code to make my point, but it's really a more general question.

function fetchSomeField(someOtherRecordID bigInt) returns (Timestamp?)
  someRecord1 SOMERECORD;
  get someRecord1 from ds using (someOtherRecordID) with #sql{
    select * from someTable where OTHERRECORD_ID = ?
  };
  if (someRecord1 != null) <-- Fails, it's not null, even though such record doesn't exist 
    return (someRecord1.timestampField1);
  else
    return (null);
  end
end


How do I know if the GET action did actually fetch a record or not?
Re: How do I know if a GET succeeded in fetching the record? [message #811740 is a reply to message #811661] Fri, 02 March 2012 19:18 Go to previous messageGo to next message
Daniel Rippa is currently offline Daniel RippaFriend
Messages: 10
Registered: March 2012
Junior Member
In the meanwhile, I'm using this:

function fetchSomeField(someOtherRecordID bigInt) returns (Timestamp?)
  someRecord1 SOMERECORD;
  rs SQLResultSet?;
  open rs from ds using(someOtherRecordID) with #sql{
    select * from someTable where OTHERRECORD_ID = ?
  };
  if (rs.setNext())
    get someRecord1 from rs;
    return (someRecord1.timestampField1);
  else
    return (null);
  end
end


It looks quite right actually! Smile
Re: How do I know if a GET succeeded in fetching the record? [message #812398 is a reply to message #811661] Sat, 03 March 2012 19:04 Go to previous messageGo to next message
Joseph Vincens is currently offline Joseph VincensFriend
Messages: 31
Registered: December 2011
Location: Prospect CT
Member
Hi

The first code you wrote was almost correct. You are checking someRecord1 for null, but you did not define it as nullable. Without a ? the initial value is an empty record and you can't even assign null to it.

someRecord1 SOMERECORD;
should be:
someRecord1 SOMERECORD?;

Adding the ? to the declaration sets someRecord1's initial value to null. If no record is returned from the get it will remain null.

The second example accomplishes the same thing.

regards,
Joe
Re: How do I know if a GET succeeded in fetching the record? [message #813815 is a reply to message #812398] Mon, 05 March 2012 18:39 Go to previous message
Daniel Rippa is currently offline Daniel RippaFriend
Messages: 10
Registered: March 2012
Junior Member
I forgot about nullable semantics. Thanks, Joe!
Previous Topic:EGL EDT V 0.8.0 M2
Next Topic:selectionListeners
Goto Forum:
  


Current Time: Sun Nov 03 06:58:48 GMT 2024

Powered by FUDForum. Page generated in 0.03893 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top