Sponsored Content
Top Forums Shell Programming and Scripting Script which fill data in XML file Post 302666675 by zb99 on Thursday 5th of July 2012 05:00:08 AM
Old 07-05-2012
Thanks for the good idea.

I will use CONCAT to export the values from the database + tags. Like this:
Code:
SELECT '<ns1:messageId>' || ' ' || seq.nextval || '</ns1:messageId>'  FROM dual;

Code:
<ns1:messageId> 22</ns1:messageId>

Could you suggest me what to use in order to add the fixed values such as <<?xml version="1.0" encoding="UTF-8"?>> and how to export both(fixed values + result of queries) in a file?

---------- Post updated at 12:00 PM ---------- Previous update was at 10:42 AM ----------

I try to use this:

Code:
SQL> spool test2.txt
SQL> set serveroutput on
SQL> begin
  2  dbms_output.put_Line('<?xml version="1.0" encoding="UTF-8"?>');
  3  end;
  4  /
<?xml version="1.0" encoding="UTF-8"?>

PL/SQL procedure successfully completed.

SQL> SELECT '<ns1:messageId>' || ' ' || imk.nextval || '</ns1:messageId>'  FROM dual;

'<NS1:MESSAGEID>'||''||IMK.NEXTVAL||'</NS1:MESSAGEID>'
--------------------------------------------------------------------------------
<ns1:messageId> 47</ns1:messageId>

SQL> spool off

And here is the result:

cat test2.txt:
Code:
SQL> set serveroutput on
SQL> begin
  2  dbms_output.put_Line('<?xml version="1.0" encoding="UTF-8"?>');
  3  end;
  4  /
<?xml version="1.0" encoding="UTF-8"?>                                          

PL/SQL procedure successfully completed.

SQL> SELECT '<ns1:messageId>' || ' ' || imk.nextval || '</ns1:messageId>'  FROM dual;

'<NS1:MESSAGEID>'||''||IMK.NEXTVAL||'</NS1:MESSAGEID>'                          
--------------------------------------------------------------------------------
<ns1:messageId> 47</ns1:messageId>                                              
 
SQL> spool off

As I want to have only the marked in red I tried to turn off some of the settings
set termout off
set echo off
set verify off
set heading off

but it seems it didnt take effect.

Last edited by zb99; 07-05-2012 at 06:14 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing and getting data from XML file using ksh script

Hi All, I have a xml file for example as described below <xml> <address> <street><street> <address/> <isbn>426728783932020308393930303</isbn> <book> <name> </name> </book> . . . </xml> My problem is to get the isbn number from the above described file using ksh script. Could... (6 Replies)
Discussion started by: vinna
6 Replies

2. Shell Programming and Scripting

Help with shell script to extract data from XML file

Hello Scripting Gurus, I need help with extracting data from the XML file using shell script. The data is in a large XML and I need to extract the id values of all completedworkflows. Here is a sample of it. Input and output data is also in the attached text files. <wfregistry>... (5 Replies)
Discussion started by: yajaykumar
5 Replies

3. Shell Programming and Scripting

Convert XML to Data File in Shell Script

Hi All, I will be getting a huge XML file with a lot of records in it. I need to convert it into multiple data files. SAMPLE XML FILE <ABSProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <ProductSalesHierachy> - <Portfolios> - <Portfolio productCode="P1"> ... (8 Replies)
Discussion started by: ragha81
8 Replies

4. Shell Programming and Scripting

How to fill data from other file and get some output

Greetings, I have a hard time creating a large number of user profiles in a database. The data file looks like this : 01/01/80 Mitch Conley . . . . And I need to put the output into: Name: Mitch Surname: Conley Birthday: 01/01/80 Thanks in advance! (3 Replies)
Discussion started by: hemo21
3 Replies

5. Shell Programming and Scripting

fill in last column of data

Hello, I am fairly new to awk, and I have the following problem. My file has missing data in the last column, and the program I am pre-processing this file for cannot interpret correctly shortened rows (it just wraps the data around). Is there a way to force awk to create the same... (6 Replies)
Discussion started by: timert34
6 Replies

6. Shell Programming and Scripting

Fill in missing Data

hello everyone, I have a task to input missing data into a file. example of my data below: Wed Feb 01 09:00:02 EST 2012,,,0.4,0.3,,0.3,,0.3,,0.5,,0.3,,,0.4,0.3, Wed Feb 01 09:00:11 EST 2012,,,,,,,0.2,,,,,,,,,, Wed Feb 01 09:00:22 EST... (23 Replies)
Discussion started by: Nolph
23 Replies

7. Emergency UNIX and Linux Support

Script to fill the file system mount with empty files to desired size

We are regularly using for our testing, where we are manually filling up the mount with desired size with following command dd if=/dev/zero of=file_2GB bs=2048000 count=2000 We are planning to automate the task where taking input for % of size as one input and the name of the file system... (8 Replies)
Discussion started by: chandu123
8 Replies

8. Shell Programming and Scripting

Fill data if number range is given

Hi I want to get all numbers if number range is given as input. Eg: INPUT FILE 100-105 107 108-112 OUTPUT REQUIRED: 100 101 102 103 104 105 107 108 109 110 111 112 How can I do it using shell? :confused: Thanks in advance. (11 Replies)
Discussion started by: dashing201
11 Replies

9. Shell Programming and Scripting

Fill data in column with previous value

Gents, Kindly help me. I have a file with empty values in selected column, I will like to fill the empty values with the previous value. Example Input file X 4959 30010 66727.00 20457.001 1 1441 66512.00 20234.00 20520.001 X 4959 30010 66727.00 20457.001 145 ... (7 Replies)
Discussion started by: jiam912
7 Replies

10. Shell Programming and Scripting

Need get data from XML file through shell script..

hi all, here is the sample log file and these errors are repeated in log file.. i need all the repeated time stamp ,severity and message tags needs to print in output file.. through shell script <log-message> <timestamp>2019-03-13T04:52:49.648-05:00</timestamp> <severity>ERROR</severity>... (17 Replies)
Discussion started by: ravi
17 Replies
RDF::Query::Compiler::SQL(3pm)				User Contributed Perl Documentation			    RDF::Query::Compiler::SQL(3pm)

NAME
RDF::Query::Compiler::SQL - Compile a SPARQL query directly to SQL. VERSION
This document describes RDF::Query::Compiler::SQL version 2.908. METHODS
"new ( $parse_tree )" Returns a new compiler object. "compile ()" Returns a SQL query string for the specified parse tree. "emit_select" Returns a SQL query string representing the query. "limit_clause" Returns a SQL LIMIT clause, or an empty string if the query does not need limiting. "order_by_clause" Returns a SQL ORDER BY clause, or an empty string if the query does not use ordering. "variable_columns ( $var )" Given a variable name, returns the set of column aliases that store the values for the column (values for Literals, URIs, and Blank Nodes). "add_variable_values_joins" Modifies the query by adding LEFT JOINs to the tables in the database that contain the node values (for literals, resources, and blank nodes). "patterns2sql ( @triples, $level, %args )" Builds the SQL query in instance data from the supplied @triples. $level is used as a unique identifier for recursive calls. %args may contain callback closures for the following keys: 'where_hook' 'from_hook' When present, these closures are used to add SQL FROM and WHERE clauses to the query instead of adding them directly to the object's instance data. "expr2sql ( $expression, $level, %args )" Returns a SQL expression for the supplied query $expression. $level is used as a unique identifier for recursive calls. %args may contain callback closures for the following keys: 'where_hook' 'from_hook' When present, these closures are used to add necessary SQL FROM and WHERE clauses to the query. "_mysql_hash ( $data )" Returns a hash value for the supplied $data string. This value is computed using the same algorithm that Redland's mysql storage backend uses. "_mysql_node_hash ( $node )" Returns a hash value (computed by "_mysql_hash" for the supplied $node. The hash value is based on the string value of the node and the node type. "qualify_uri ( $uri )" Returns a fully qualified URI from the supplied $uri. $uri may already be a qualified URI, or a parse tree for a qualified URI or QName. If $uri is a QName, the namespaces defined in the query parse tree are used to fully qualify. "add_function ( $uri, $function )" Associates the custom function $function (a CODE reference) with the specified URI, allowing the function to be called by query FILTERs. "get_function ( $uri )" If $uri is associated with a query function, returns a CODE reference to the function. Otherwise returns "undef". AUTHOR
Gregory Williams <gwilliams@cpan.org> perl v5.14.2 2012-01-31 RDF::Query::Compiler::SQL(3pm)
All times are GMT -4. The time now is 11:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy