0

I am trying to export the data from a Firebird store procedure using a loop. I am using Flamerobin tool to do this. I get the results but the columns and rows are all messed up when I export them to csv file! All headers will be in one cell and values are all over the place! Is there any way to export the result to excel or csv file?

 set term!!;
EXECUTE BLOCK RETURNS (
    SOD_AUTO_KEY Integer,
    CURRENCY_CODE Char(3),
    SO_CATEGORY_CODE Char(10),
    SO_NUMBER Char(12),
    INVC_NUMBER Char(12),
    ENTRY_DATE Timestamp,
    SHIP_DATE Timestamp,
    NEXT_SHIP_DATE Timestamp,
    CONDITION_CODE Varchar(10),
    QTY_ORDERED Double precision,
    QTY_PENDING_INVOICE Double precision,
    QTY_INVOICED Double precision,
    UNIT_PRICE Double precision,
    EXCHANGE_RATE Double precision,
    UNIT_COST Double precision,
    ITEM_NUMBER Integer,
    CONSIGNMENT_CODE Char(10),
    NOTES Blob sub_type 1,
    STOCK_LINE Integer,
    STM_AUTO_KEY Integer,
    SERIAL_NUMBER Varchar(40),
    REMARKS Varchar(50),
    PN Varchar(40),
    PNM_AUTO_KEY Integer,
    GR_CODE Varchar(10),
    CUSTOMER_PRICE Double precision,
    OPEN_FLAG Char(1),
    ROUTE_CODE Char(1),
    ROUTE_DESC Varchar(20),
    COMPANY_CODE Varchar(10),
    SITE_CODE Varchar(10),
    COMPANY_NAME Varchar(50),
    COMPANY_REF_NUMBER Varchar(30),
    CUST_REF Varchar(15),
    HOT_PART Char(1) 
    )
     AS
declare i integer;
BEGIN
i=0;
while ( i <= 2 ) do 
BEGIN
   for SELECT SOD_AUTO_KEY,CURRENCY_CODE,SO_CATEGORY_CODE, SO_NUMBER,INVC_NUMBER,ENTRY_DATE, SHIP_DATE, NEXT_SHIP_DATE, CONDITION_CODE, QTY_ORDERED,QTY_PENDING_INVOICE, QTY_INVOICED, UNIT_PRICE, EXCHANGE_RATE, UNIT_COST,ITEM_NUMBER, CONSIGNMENT_CODE, NOTES, STOCK_LINE, STM_AUTO_KEY, SERIAL_NUMBER,REMARKS, PN, PNM_AUTO_KEY, GR_CODE, CUSTOMER_PRICE, OPEN_FLAG, ROUTE_CODE,ROUTE_DESC, COMPANY_CODE, SITE_CODE, COMPANY_NAME, COMPANY_REF_NUMBER, CUST_REF, HOT_PART
   FROM SPB_SALESHISTORY (i)
   into :SOD_AUTO_KEY, :CURRENCY_CODE, :SO_CATEGORY_CODE, :SO_NUMBER, :INVC_NUMBER,
   :ENTRY_DATE, :SHIP_DATE, :NEXT_SHIP_DATE, :CONDITION_CODE, :QTY_ORDERED,:QTY_PENDING_INVOICE,
   :QTY_INVOICED, :UNIT_PRICE, :EXCHANGE_RATE, :UNIT_COST,     :ITEM_NUMBER, :CONSIGNMENT_CODE, :NOTES, :STOCK_LINE,
   :STM_AUTO_KEY, :SERIAL_NUMBER,     :REMARKS, :PN, :PNM_AUTO_KEY, :GR_CODE, :CUSTOMER_PRICE, :OPEN_FLAG, :ROUTE_CODE,:ROUTE_DESC,
   :COMPANY_CODE, :SITE_CODE, :COMPANY_NAME, :COMPANY_REF_NUMBER, :CUST_REF,:HOT_PART
   DO
    suspend;
   i = i + 1;
    end
END!!
SET TERM;!!
7
  • 1
    I voted as off topic as this question seems to be about a database query tool and its export functionality, not about programming Commented Jun 6, 2014 at 7:24
  • Also when asking such a question somewhere where it is on topic, at least include the options you used to export to CSV and a sample (two or three lines) of the exported data and describe the problem in more detail (or show a screenshot of what happens with the sample lines). Commented Jun 6, 2014 at 7:26
  • As far as I know flameRobin query/proc generated results gets shown in an HTML table, you should save the html and maybe create a small Delphi app to parse the HTML - store it in s TStringGrid, you an then properly export the TStringGrid data to .CSV Commented Jun 6, 2014 at 9:08
  • 1
    Flamerobin is a very Lite RDBMS tool for firebird - I suggest you use IBEXPERT (ibexpert.net) - It has a personal(free) edition that works beautifully Commented Jun 6, 2014 at 9:10
  • @RynoCoetzee Flamerobin has an 'export to CSV' option. Commented Jun 6, 2014 at 10:33

2 Answers 2

1

I ended up using IBEXPERT according to Ryno's response.

Sign up to request clarification or add additional context in comments.

Comments

0

I often use 2 SQL comands into FlameRobin SQL editor:

output filename_to_export.txt;
select field1, field2 from tablename;

First you say command what file you whant the result of your query will be stored, second you say the query itself. Do not forget, they are two separated (distinct) commands, note the ; after each one. The order doesn't matter. The output remains opened for append results if you perform more queries.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.