#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    London
    Posts
    13
    Rep Power
    0

    Lightbulb how to run sql script in an application.


    Hi guys,
    I am trying to build a directory importer and need to run this SQL script within the application to import the data. Can you guys suggest any utility where which can allow me to embeded this sql script.

    create sequence divseq;
    create sequence deptseq;
    create sequence ccseq;

    insert into DIVISIONS select divseq.nextval, v_div from
    (select distinct division v_div from TABLE1);

    insert into Departments select deptseq.nextval, v_dept from
    (select distinct deptartment v_dept from table1);

    insert into cc select ccseq.nextval, v_cc from
    (select distinct ccs v_cc from table1);

    insert into Extensions values
    select a.extno, a.name, b.div_no, c.dept_no, d.cc_no
    from table1 a, DIVISIONS b, Departments c, cc d
    where
    a.division = b.division and
    a.deptartment = c.department and
    a.ccs = d.cc
    a.rowid in (select max(rowid) from tb1 group by extno) ;
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Flint, MI
    Posts
    328
    Rep Power
    12
    You can read data in looking for a ";\n" combination, which indicates the end of an SQL statement. Then execute each sql statement individually via whatever mechanism your application dictates.
    Clay Dowling
    Lazarus Notes
    Articles and commentary on web development
    http://www.lazarusid.com/notes/
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    London
    Posts
    13
    Rep Power
    0
    nother question, I don't this some of the sql functions will work as they are probabely applicable for oracle only. but is it possible that i can store the result of an select statement to a text file or in an temp array.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Flint, MI
    Posts
    328
    Rep Power
    12
    it's entirely possible. The technique you use for storing them depends upon what you want to do with them. But anything can be written out to a file with a little work on the programmer's part. You need to find a way to delineate the fields, and that will really depend on your intended use for the file.

    I'm not sure how your database engine works. In MySQL, all returned fields can be treated as character string, and each tuple as an array of strings. So I keep a linked list of character string arrays when I want to pass a complete record set around to things that don't necessarily know about MySQL.
    Clay Dowling
    Lazarus Notes
    Articles and commentary on web development
    http://www.lazarusid.com/notes/

IMN logo majestic logo threadwatch logo seochat tools logo