Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Reading S_xxxx records from Sql
Reading S_xxxx records from Sql [message #38871] Thu, 24 January 2013 21:20 Go to next message
Alboni is currently offline  Alboni
Messages: 203
Registered: January 2012
Location: Deventer, Netherlands
Experienced Member
Hello,

Is it possible to read whole records from sql instead of fields?

something like: (different syntax probably)

Sql sql;
S_SOMETABLE rec;
sql*Select(SqlAll()).From(SOMETABLE).Where(key==1);
if (sql.Fetch()
{
rec=sql;
}


Would be awfully handy.....

[Updated on: Thu, 24 January 2013 21:21]

Report message to a moderator

Re: Reading S_xxxx records from Sql [message #38875 is a reply to message #38871] Fri, 25 January 2013 00:19 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 607
Registered: December 2005
Location: Budapest, Hungary
Contributor
I did not test it, but the correct syntax would be something like this:
Sql sql;
S_SOMETABLE rec;
sql*Select(rec).From(SOMETABLE).Where(key==1);
if (sql.Fetch(rec)
{
  //do something with the first record in rec
}


Or:

while (sql.Fetch(rec)
{
  //do something with all records
}


Read Sql Tutorial's 6th chapter.
Re: Reading S_xxxx records from Sql [message #38876 is a reply to message #38871] Fri, 25 January 2013 00:57 Go to previous messageGo to next message
Alboni is currently offline  Alboni
Messages: 203
Registered: January 2012
Location: Deventer, Netherlands
Experienced Member
Cool thanks!

What's the difference between:

sql*Select(SqlAll())

and

sql*Select(rec)

Does the latter also always select all colums in the table?
Re: Reading S_xxxx records from Sql [message #38884 is a reply to message #38876] Fri, 25 January 2013 12:01 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 607
Registered: December 2005
Location: Budapest, Hungary
Contributor
I think, you are right Smile
sql*Select(SqlAll()) results shorter sql.
Re: Reading S_xxxx records from Sql [message #39077 is a reply to message #38884] Wed, 13 February 2013 08:30 Go to previous message
sergeynikitin is currently offline  sergeynikitin
Messages: 741
Registered: January 2008
Location: Moscow, Russia
Contributor

If you use not all fields in your sql schema, then SqlAll() may transfer unwanted fields (maybe BLOBs...).

rec transfers fields only present in your schema.

PS
For screen buffer to read DataFileRecord use SqlCtrls screen sctructure in header file of window class.

SqlCtrls ctrls;


and in constructor

ctrls
   (sqlfield1,dlg.ScreenField1)
   (sqlfield2,dlg.ScreenField2)
   (sqlfield3,dlg.ScreenField3)
   (sqlfield4,dlg.ScreenField4)
;


And when you read record use this code:

SQL * Select(dlg.ctrls).From(TABLE).Where(TAB_ID == ptr);
if(!dlg.ctrls.Fetch(SQL))
   return;


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Previous Topic: How to view immediately the primary key in SqlArray
Next Topic: SqlArray with Ctrls (in place)
Goto Forum:
  


Current Time: Fri Jan 22 03:42:02 CET 2021

Total time taken to generate the page: 0.02182 seconds