Welcome Guest | My Membership | Login

Communicate with SQL - D3 Code Sample


Summary

Look at perl and DBI.  Perl has a simple DBI interface and all the picks have the simple ability to execute local os programs.  You are not going to find any product that does all the mapping work for you, but perl can quickly do this for you.

001 SUBROUTINE WHIRLER.DO.SQL(OPT,CMND,RESULT)
002 ** THIS ROUTINE WILL GENERATE A PERL SCRIPT ON THE FLY
003 RESULT=''
004 OPEN 'unix:/tmp/scripts/' TO SCRIPT.FILE ELSE RETURN
005 CODE='use Pg;'; * replace this with specific database driver
006 DATABASE=OPT<1>
007 CODE<-1>="$conn = Pg::connectdb('dbname=":DATABASE:"');"
008 Q="'"
009 CODE<-1>='$result = $conn->exec("':CMND:'");'
010 IF INDEX(CMND,'SELECT',1) THEN
011    * DOING A SELECT STATEMNET
012    DOING.SELECT=1
013    CODE<-1>='while (@d = $result->fetchrow) {'
014    CODE<-1>="     print join('|', @d);"
015    CODE<-1>='     print "\n";'
016    CODE<-1>='}'
017    CODE<-1>='exit;'
018 END ELSE
019    CODE<-1>='$r = $result->resultStatus;'
020    CODE<-1>='print $r;'
021    CODE<-1>='print "\n";'
022    CODE<-1>='exit;'
023 END
024 ID=SYSTEM(19)
025 WRITE CODE ON SCRIPT.FILE, ID
026 EXECUTE '!perl /tmp/scripts/':ID CAPTURING RESULT
027 DELETE SCRIPT.FILE, ID
028 CONVERT '|' TO CHAR(253) IN RESULT
029 RETURN
 

Now this script connects to Postgres sql database.  It outputs all SQL Select statements as | delimited files.

Now I have used this in pick in the manner you have asked as such.

Read More...

Social Media Login

Use your existing social media logins to access your Membership/Subscription information.

Existing Magazine/Newsletter Subscriber (Quick Access)

If you are an existing International Spectrum subscriber, but have not registered with the website, please enter the Reference Code found on the magazine or in the e-mails you receive from us.

Magazine Reference Code location

Spectrum Login

New Subscriber

If you currently do not receive the Magazine or other emails from International Spectrum, select the "Subscribe" button below to create an new membership account.


 

Find out more about the different between the FREE and a Professional Membership at:
Compare Account Options

 

# # #          # # #          # # #

 

Related Articles

  • Connecting SQL Server 2000 From Linux using Perl DBI

    Resource for setting up Perl and Sybase protocols on Linux/Unix so MultiValue Applications can access Microsoft SQL Server.

  • MS SQL Resources

    ARticles and resources for MS SQL for people without much SQL knowledge

  • QM and VFS

    Company: Ladybridge Systems Ltd Database: OpenQM

    Sometimes MultiValue can be the complete solution. Sometimes we just use pieces. The database can be used without using mvBASIC or Proc. Or, you can code the middle in MultiValue and let SQL hold the data. Here's a success story with QM can playing that middle role.

  • SQL Server/Management Studio

    SQL Server/Management Studio Downloads for Integrating MS SQL with MultiValue Applicaitons Webinar

  • Using SQL Server's BULK INSERT in MVON BASIC

    Company: ONgroup Intl Database: MVON

    The following twelve-line MVON BASIC program builds a BULK INSERT command and passes it to SQL Server.


Return to top