can i validated database through sql

Is there any way i can validate my results in database through sql query ?if there is a solution,then Egg plant licensing in offfice is going to more for sure :D

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    What kind of SQL database are you using? If it's one with a command line interface available, such as MySQL or Oracle, you can use the shell() function to run queries. Here's some sample code and additional information about running against MySQL:
    (* Using mysql from within a SenseTalk script isn't quite as simple
    as it seems like it should be. Using "open process" and related
    commands will work, but it seems that the output doesn't become
    available to read until after a "quit" command is issued. So it isn't
    really usable as an interactive session.
    *)
    set mysql to "/usr/local/mysql/bin/mysql"
    open process mysql with options (parameters:"-t")
    write "select now();" & return to process mysql
    write "select 'XXXX';" & return to process mysql
    write "show databases;" & return to process mysql
    write "quit" & return to process mysql
    read from process mysql until end
    put it
    close process mysql
    
    (* Since "open process" doesn't seem to work interactively, using a
    batch file containing the mysql commands is a simpler approach. *)
    put ,"-------- Another Approach using a Batch File --------"
    set file "/tmp/mysqlcommands" to {{
    select now();
    select 'XXXX';
    show databases;
    }}
    put shell ("/usr/local/mysql/bin/mysql -t </tmp/mysqlcommands")
    
    (* Notes:
    I've used the '-t' flag to tell mysql to format the output the same as when the commands are issued interactively (with boxes drawn around the output). This is nice for debugging, but probably not ideal for a script. Omitting that option simplifies the output, but the output from all the commands isn't separated. The "select 'XXXX'" command is there as a way to make the output easier to parse in this case. *)
    
    Once you've executed the query, it's very easy to parse it with SenseTalk and compare the returned data to a known set of values.
  • Thanks Matt.
    It answered my questions and good that we use MySQL and Oracle as DB.
    let me try with my application and let you know if i found any difficulty
  • Follow up on answer
    In my case,the MySql is not locally available.It is in a seperate box.Kindly guide me
    How to connect to that MySQL box instead of local machine.
    set mysql to "/usr/local/mysql/bin/mysql"
    
    Secondly,the box is 64 bit where MySQL avilable and Application is under different box which is 32 bit.will that make differnce?
  • EggplantMattEggplantMatt ForumAdmin admin
    One approach is to set up a public key pair and use ssh to connect to the other machine. I think you should be also be able to install mySQL on the EggPlant machine and specify the other server/database in the connect command.
Sign In or Register to comment.