generate sql result into xml
Hi all,
How do I generate sql result into xml ? Tried this way (shown below), but it generates all data into single column. Tell me kindly what else should I post here to get help. Please help. Thanks ahead. Code:
generate_xml() |
I do not follow your snippet?
1. You set 2 variables, but i am guessing 'f2' is used in the part you have not shown 2. Ignoring the useless use of cat, you cat a file that you do not test if it exists until after you have used it and then you remove it?? 3. You print the incomplete header into a file you just removed 4. You give no advice as to where you got your example from, so not really able to assist further on why it would generate a single column |
Quote:
Please find edited code above, I added parts that was not shown before. I still struggle to complete this task, so thank ahead for any help. |
Ok so now we have more of the script. There are several issues with the code, so I will ask specifically which function is not performing as you wish and to please narrow it down
to what you have found? You must understand you have presented nearly 200 lines of code, which to be perfectly honest looks a mess. My suggestion would be to start with a single function and work out what it does and what you do not understand ... then come back and ask questions about those specific parts. It would also possibly help, once you have done some work, to provide both the current and the expected output for the section you look at. |
Quote:
We have columns in result file: RB FB FBH AB ABH FBAD FBHAD FBAC FBHAC ABAA ABHAA and values of these columns are all inserted into single RB column 941 189 211 2 3 0 0 0 0 3 0 They should be placed each into another column. How do I perform it? cat /etc/*-release LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch Red Hat Enterprise Linux Server release 6.6 (Santiago) Red Hat Enterprise Linux Server release 6.6 (Santiago) |
Quote:
.. checked file exists and removed it ?? while it should be checked before the line with cat and sed. So ok, please narrow down to whats not working !!! |
Quote:
Quote:
Code:
for i in `awk 'NR==1' $f1` I found that this line generates values 941 189 211 2 3 0 0 0 0 3 0 Code:
print ' <Cell ss:StyleID="s22"><Data ss:Type="String">'$k'</Data></Cell>' >> $SQL_QUERY_OUT I tried to play with "$k" variable and added "r" before, so this line is now Code:
print ' <Cell ss:StyleID="s22"><Data ss:Type="String">'r$k'</Data></Cell>' >> $SQL_QUERY_OUT r941 189 211 2 3 0 0 0 0 3 0 (all in one single column). So now my need is to understand how to divide values into different columns. Any help? |
Quote:
Quote:
use array to store all values in different indexes and print them in columns you need. Since you think you are not doing any other mistake or useless uses this is my suggestion. |
Before:
Quote:
Quote:
Thanks for attention. |
So as you have said it works great I am guessing this is SOLVED? (please mark as such)
I am interested that your previous reply to me suddenly mentioned migration which you never mentioned before. Little details are important if you want people to be able to help you properly. As for your new solution, you should virtually always quote unusual characters other wise the shell may make changes you are not prepared for. I would suggest only quoting the the tab (\t) as -F is a switch to awk and quoting it may make awk not behave as you expect (maybe not now but later on) |
Marked thread solved. Thanks to all.
|
All times are GMT -5. The time now is 06:25 AM. |