2

I am new to openedge and i am trying to export initially a table to xml file. My final aim is to export three tables to xml file.

I have tried to export in a simple delimited and is working. I have tried

  • For txt

        OUTPUT TO c:\temp\file.txt.
          FOR EACH cGrSIRVATNBR:
            EXPORT DELIMITER ";" cGrSIRVATNBR.
          END.
        OUTPUT CLOSE.   
    
  • For xml

       cGrSIRVATNBR:WRITE-XML("FILE","c:\temp\tt.xml", TRUE).
    

For xml i thing is only supported from 102b. That's why i am taking error (Unable to understand after -- cGrSIRVATNBR:) when using WRITE-XML.

I will appreciate any help.

kostas ch.
  • 1,960
  • 1
  • 17
  • 30
  • Is cGrSIRVATNBR actually a table name? Or is it a variable containing a table name? If it is a table name it is one of the oddest I've ever seen. If it is a table name and there are no errors in the EXPORT example that could just mean that there is no data in the table. – Tom Bascom Feb 17 '14 at 14:29
  • @TomBascom ttGrSIRVATNBR is the actual name. Indeed is strange but it has meaning in my business logic :). I have data to export for sure. I have also have change my code the table name but the same shit different day. – kostas ch. Feb 17 '14 at 14:32
  • The EXPORT snippet should work fine if the code above is what you are actually running and there is data in a table with that name. FWIW I usually enclose file names in quotes and I would use NO-LOCK on the FOR EACH -- but syntactically that shouldn't matter. – Tom Bascom Feb 17 '14 at 14:40
  • @TomBascom You r right, the file exported ok by in the server and not in my pc!!!! Anyway, i will change my question a bit, but the challenge is to create xml from table. – kostas ch. Feb 17 '14 at 14:48
  • You mention an error when attempting to WRITE-XML with 10.2A. What is the text of that error? – Tom Bascom Feb 17 '14 at 16:25
  • If, as you mention, the real name is ttGrSIRVATNBR and that is actually a temp-table rather than a real table, then the problem is probably that you have omitted "temp-table" so that the compiler can know what sort of handle ttGrSIRVATNBR is. See the example below. – Tom Bascom Feb 18 '14 at 14:44

1 Answers1

3

This works fine for me:

define temp-table ttCust no-undo like customer.

for each customer no-lock where custNum = 1:
  create ttCust.
  buffer-copy customer to ttCust.
end.

temp-table ttCust:write-xml( "file", "cust.xml", true ).

You cannot directly write a db table to XML. You have to copy the records that you want into a temp-table first.

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
  • I have error from server "You cannot define a TEMP-TABLE inside an internal procedure." Are you using 102a version on this statement? – kostas ch. Feb 18 '14 at 07:58
  • Finally i will create my xml through code and exported to file. Thx a lot for your time. – kostas ch. Feb 18 '14 at 08:46
  • There is no internal procedure in the sample that I provided. – Tom Bascom Feb 18 '14 at 11:25
  • In .p file i have created o proc which my .net api call it. But it's ok, i have succeed my aim through string concatenation. As .net developer, i faced some problems but it is working perfect :). Thx again for your time. – kostas ch. Feb 18 '14 at 11:34
  • Thanking me for my time might involve marking the answer correct and maybe even giving it an up vote. Also, in the future it would save a lot of guessing if you posted the actual error messages that you are getting. – Tom Bascom Feb 18 '14 at 12:13
  • I don't think if your answer is right to vote it as correct (i have mention in the header that i am using 102a version). That will confuse other people. Also i don't think that we guess a lot. I should upvote and mark as correct if your post was correct. – kostas ch. Feb 18 '14 at 13:41
  • Well you still haven't actually posted what the error you mentioned on your question actually is so anyone reading this is guessing about that. And my code works fine for 10.2a but you're trying to run it differently (all in an internal procedure). You're putting a lot of restrictions on solutions that aren't part of your question so there's really no way to know what will satisfy you - thus a lot of guessing. – Tom Bascom Feb 18 '14 at 13:58
  • As for the error, you are right and i have fixed. You r also right about the restrictions (unfortunately progress is part of an erp i am customize that's why are existing restrictions). So you r right +1. But i still have not found yet any progress document about 102a and write xml. If you have something post me a link please. Thx – kostas ch. Feb 18 '14 at 14:10
  • You never asked for documentation... Progress documentation (including 10.2a) can be found online at: https://community.progress.com/technicalusers/w/openedgegeneral/1329.openedge-product-documentation-overview.aspx In the 10.2A docs you want the "ABL Reference". Page 1735 of the PDF version of that doc details WRITE-XML(). Which works exactly as shown above. – Tom Bascom Feb 18 '14 at 14:40