This is what I do....

Since you are on Linux, chances are you already have what you need installed.

I define a VOC item called "TMP" which looks like:

0001: F
0002: /tmp
0003: D_VOC

And coding that looks like:

   OPEN "","TMP" TO F.TMP ELSE STOP "NO /tmp"
   USRNO=@USERNO
   HOSTNAME="" ; * example: http://servername  (assumes port 3306) otherwise 
add --port=port#touse
   USERNAME=""
   PASSWORD=""
*
   TEST="mysql --connect_timeout=15 --user=":USERNAME:" --password=":PASSWORD:" 
-h ":HOSTNAME:" > /tmp/output":USRNO:" <<EOF"
   TEST<-1>="use orders;"
*
   TEST<-1>="select InvNo,TransID,GroupCode,Status from shippingdata where 
Status is not null;"
*
*
   TEST<-1>="quit"
   TEST<-1>="EOF"
*
   WRITE TEST ON F.TMP,"TSQLCMD":USRNO
   CMD1="/tmp/MYSQLCMD":USRNO
   DELETE F.TMP,"output":USRNO
   EXECUTE "SH -c '":CMD1:"'" CAPTURING ERRORS
*
   READ CRMDATA FROM F.TMP,"output":USRNO ELSE PRINT "NO MYSQLDATA FOR ":USRNO
   UU=DCOUNT(CRMDATA,CHAR(254))
   BLANK=CHAR(9):CHAR(9)
   RESULT="" ; SKIP=1
   FOR T=1 TO UU
      IF CRMDATA<T>#BLANK THEN
         IF INDEX(CRMDATA<T>,"InvNo",1)#0 THEN SKIP=0 ; CONTINUE
         IF SKIP=1 THEN CONTINUE
         RESULT<-1>=CHANGE(CRMDATA<T>,CHAR(9),CHAR(253))
      END
   NEXT T
*
   DELETE F.TMP,"MYSQLCMD":USRNO


When completed:
 RESULT will have a 2 dimensioned Dynamic array - with the X dimension being 
the columns, and the Y dimension being the Rows
 ERRORS will have any messages from the database

-----Original Message-----
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Manu Fernandes
Sent: Saturday, October 01, 2011 4:55 AM
To: u2-users@listserver.u2ug.org
Subject: [U2] [uv] from uv/linux, execute a remote mysql/sql stmt ?

Hi group,

I'm looking for your experiences...

>From Universe/linux, I'll execute a mySQL sql phrase. 
mySQL is installed on a remote server.

- What is the mysql-client to be installed beside Universe ?
- How to execute a sql-phrase from UV/BASIC ? and capture the result !?

Thanks for any advice.
Manu




_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to