Re: Is there a D3 (or MVDBMS) equivalent statement for this SQL functionality?

256 views
Skip to first unread message

Tony Gravagno

unread,
Aug 2, 2012, 3:58:40 PM8/2/12
to mvd...@googlegroups.com
This challenge is a bit contrived.  Why is SELECT/READNEXT any different from ExecuteQuery/rs.Next?
If he wants to do that with Java, use MVSP for D3. If he wants to use .NET, use MVSP or mv.NET. The syntax for all of these is virtually the same as for SQL and Java/.NET. If you're using another language like BASIC, the syntax is a little different by a line or two but the result is the same.

How about this?
  EXECUTE \SELECT CUSTOMERS ID LNAME WITH SNUM "2001"\ RTNLIST RS
  LOOP READNEXT INFO UNTIL INFO  = ""
     CRT INFO
  REPEAT

I haven't looked at exactly what info produces, and you may need multiple readnexts to retrieve each field, but I believe that's the syntactical equivalent of the Java challenge, with the exact same number of lines.

HTH


On Thursday, August 2, 2012 11:27:20 AM UTC-7, Kevin Christensen wrote:

An SQL programmer that I work with is trying to accomplish something in D3 and thought for sure that something he considers so basic isn't available in D3. He wants to select data and direct specified fields to an array. In other words, not deal with re-processing the file by doing a readnext, read record, parse/process those fields. ...

Brian Stone

unread,
Aug 2, 2012, 4:10:23 PM8/2/12
to mvd...@googlegroups.com
Use REFORMAT or SREFORMAT
 
Brian
 


 
On Thu, Aug 2, 2012 at 11:27 AM, Kevin Christensen <kevinsch...@gmail.com> wrote:

An SQL programmer that I work with is trying to accomplish something in D3 and thought for sure that something he considers so basic isn't available in D3. He wants to select data and direct specified fields to an array. In other words, not deal with re-processing the file by doing a readnext, read record, parse/process those fields.


SQL returns can throw all that into an array that can processed without rereading/reprocessing the selection


Here are 2 examples of executeQuery command in java that returns a ResultSet. The values can be extracted from the result set by column number (the first example below) or by column name (the second example)

Example 1:_______________________________________________________
from
http://www.roseindia.net/jsp/execute-sql-query.shtml

**  // sql query to retrieve values from the specified table.
**   QueryString = "SELECT * from user_master1";
**   rs = statement.executeQuery(QueryString);
**   while (rs.next()) {
**   System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " + rs.getString(3) + " "+rs.getString(4)+"\n");
**   }


Example 2:_______________________________________________________

from:
http://www.devdaily.com/java/edu/pj/jdbc/jdbc0003

**   Statement stmt = conn.createStatement();
**   ResultSet rs = stmt.executeQuery("SELECT Lname FROM Customers WHERE Snum = 2001");
**   while (rs.next()) {
**   String lastName = rs.getString("Lname");
**   System.out.println(lastName + "\n");

 

--
You received this message because you are subscribed to
the "Pick and MultiValue Databases" group.
To post, email to: mvd...@googlegroups.com
To unsubscribe, email to: mvdbms+un...@googlegroups.com
For more options, visit http://groups.google.com/group/mvdbms

Tony Gravagno

unread,
Aug 2, 2012, 4:12:31 PM8/2/12
to mvd...@googlegroups.com

Correction:

 

This code can be run in the SQLDEMO account that is already in your D3 system:

 

EXECUTE \SELECT CUSTOMERS CUSTOMERID CITY WITH STATE "OHIO"\ RTNLIST RS

* RS is an array!

FOR N = 1 TO DCOUNT(RS,@AM) STEP 2

  CRT RS<N>:" ":RS<N+1>

NEXT N

 

geneb

unread,
Aug 2, 2012, 4:40:11 PM8/2/12
to mvd...@googlegroups.com
On Thu, 2 Aug 2012, Kevin Christensen wrote:

>
>
> An SQL programmer that I work with is trying to accomplish something in D3
> and thought for sure that something he considers so basic isn't available
> in D3. He wants to select data and direct specified fields to an array. In
> other words, not deal with re-processing the file by doing a readnext, read
> record, parse/process those fields.
>
>
I'd check out the Java MVSP library if you're using D3 v9.

The rs.next() is essentially the same as doing a readnext followed by a
read. If you're using MVSP, you could access the data via something like:
mvspExtract(dataRec,1), etc.

I can give you a good example if you're interested. I'm right in the
middle of moving a 300k+ LOC project from the old D3VBODBC library to the
new MVSP .Net library.

g.

--
Proud owner of F-15C 80-0007
http://www.f15sim.com - The only one of its kind.
http://www.diy-cockpits.org/coll - Go Collimated or Go Home.
Some people collect things for a hobby. Geeks collect hobbies.

ScarletDME - The red hot Data Management Environment
A Multi-Value database for the masses, not the classes.
http://www.scarletdme.org - Get it _today_!

Buying desktop hardware and installing a server OS doesn't make a
server-class system any more than sitting in a puddle makes you a duck.
[Cipher in a.s.r]

Mark Brown

unread,
Dec 9, 2012, 6:34:18 PM12/9/12
to mvd...@googlegroups.com
Sorry I got to this late in the game...
 
Add a verb to your master dictionary:
 
TAB-SORT
001) VA
002) AA]5D]53
003) B
 
Then in Basic
 
execute 'tab-sort customers id lname with snum "2001"' capturing array
convert char(254) to char(13) in array
print array
Reply all
Reply to author
Forward
0 new messages