Parse SQL string using Zql or SQL4J
any used zql or sql4j.
if then plz give me some example
import org.apache.xerces.dom.DOMParser;
import org.w3c.dom.Document;
import org.w3c.dm.NodeList;
DOMParser parser new DOMParser();
parser.parse("xyz.xml"); // Instead of xml file it could be a InputStream.. not sure though
// You need to llok at documentation
Document doc = parser.getDocument()
// Once you have got the Document you can manipulate it using DOM api
// For example following code prepares a list of nodes having a tag = "product_id"
NodeList prodList = new NodeList();
prodList = doc.getNodeByTagName("product_id");
Hope this helps !!!
Sunil
Similar Messages
-
Parsing a string using StringTokenizer
Hi,
I want to parse a string such as
String input = ab{cd}:"abc""de"{
and the extracted tokens should be as follows
ab
cd
"abc""de"
As a result, I used the StringTokenizer class with deilmeter {,},:
StringTokenizer tokenizer = new StringTokenizer(input,"{}:", true);
In this was, I can separate the tokens and also can get the delimeters. The problem is I don't know how to parse the string that has double quote on it. If a single quote " is taken as a delimeter then
", abc, ",", de," all of them will be taken as a separate token. My intention is to get the whole string inside the double quote as a token including the quotes on it. Moreover, if there is any escape character "", it should be also included in the token. Help please.
ThanksA bit of a "sticky tape"-solution...
import java.util.StringTokenizer;
public class Test {
public static void main(String[] args) {
String input = "ab{cd}:\"abc\"\"de\"";
StringTokenizer st = new StringTokenizer(input, "{}:", true);
while(st.hasMoreTokens()) {
String token = st.nextToken();
if(token.startsWith("\"") && token.endsWith("\"")) {
token = token.substring(1,token.length()-1);
System.out.println(token);
} -
Need Help Parsing JSON String using PLJSON
Hello,
I have JSON stored in a database field:
--Query
select data1 from table1 where id= 339207152427;
--Results:
[{"name":"Home"},{"code":"JPNWC74ZKW9"},{"start date":"01\/02\/2014"},{"person name":"hhh, RamS"}]
I need to parse the above results into 3 fields in a separate table. For now, i'm just trying to parse the results using PLJSON, but am getting the ORA-20101: JSON Parser exception - no { start found error when running the following pl/sql block:
declare
VIN_JSON varchar2(4000);
jsonObj json;
listOfValues json_list;
listElement json_value;
begin
select data1 into VIN_JSON from table1 where id= 339207152427;
jsonObj := new json(VIN_JSON);
listOfValues := jsonObj.get_values();
for i in 1..listOfValues.count loop
listElement := listOfValues.get(i);
end loop;
end;
I believe my syntax is close, but was hoping for some further instruction.
Thanks in advance!
JohnI have no idea what you are trying to do or in what version so help, at this point, is not possible.
Let's start with this:
I need to parse the above results into 3 fields in a separate tableAnd the parsing rules?
And what the result should be?
You apparently want us to guess. Which is something most of us do not like to do. (and don't forget your full version number if you want help).
PS: This forum has a FAQ: I recommend you read it as you didn't even put your listing into tags. -
How to parse xml string using JSTL
Suppose this is my string:-----
<books>
<book>
<title id=1>Book Title A</title>
<author>A. B. C.</author>
<price>17.95</price>
</book>
<book>
<title id=2>Book Title B</title>
<author>X. Y. Z.</author>
<price>24.99</price>
</book>
</books>
and I want to read title id = 1 then, how to parse it, I found tutorials regarding parsing simple xml document but how to parse attributes of a given XMLBut both of them either parse a file or data from an input source. I don't think they handle strings.An InputSource can be constructed with a Reader as input. One useful subclass of Reader is StringReader, so you'd use something likeDocument doc = documentBuilder.parse(new InputSource(new StringReader(myXMLString)));
-
Parsing Query string using Client Object model [ECMA]
hello
i want to access querystring using client object model using ECMA script.
for eg http://localhost:80/demopage.aspx?test=123
can we read value of test using ECMA script
regards
Manishthanks ...
i did that...using
<script type="text/javascript">
function queryString(parameter) {
var loc = location.search.substring(1, location.search.length);
var param_value = false;
var params = loc.split("&");
for (i=0; i<params.length;i++) {
param_name = params[i].substring(0,params[i].indexOf('='));
if (param_name == parameter) {
param_value = params[i].substring(params[i].indexOf('=')+1)
if (param_value) {
return param_value;
else {
return false; //Here determine return if no parameter is found -
Workspace to parse SQL statements from multiple database schema's
Hi ,
When go through the following link of workspace admin user :
Home>HTML DB Workspace Administration>Manage Services>Schema Reports>Workspace Schemas there I saw "Your workspace has the privilege to parse SQL statements using the following database schemas. Note that the terms database schema and database user can be used interchangeably.
" at the right pane.
So how can i make my workspace to parse SQL statements from multiple database schema's ?That must be listed there .But i have only one schema in view ? Can i make it multiple ?If then How ?
Anybody have an idea ?
ROSYAssign as many schemas to your workspace as you want using the administration app. Read about it in the doc.
Scott -
How can i pass sql string in proc as in parameter and use in cursor forloop
Dear Experts ,
Please help me in below code.
create or replace PROCEDURE Sample_Spool_Data (SQLSTRING IN VARCHAR2, FILENAME in VARCHAR2) IS
v_spool_file UTL_FILE.FILE_TYPE ;
SQLSTRING VARCHAR2(1000);
BEGIN
v_spool_file := UTL_FILE.FOPEN('MPLD_DQMT',FILENAME,'w');
UTL_FILE.PUT_LINE(v_spool_file,'Start: '||to_char(sysdate,'dd/mm/yyyy hh:mi s'));
FOR c1_rec in SQLSTRING
LOOP
UTL_FILE.PUT_LINE(v_spool_file,c1_rec.rec);
end loop;
UTL_FILE.PUT_LINE(v_spool_file,'End: '||to_char(sysdate,'dd/mm/yyyy hh:mi s'));
SQL String is having like select col1, col2, col3 from table_name;Looks like you're tring to write a generic way of outputting the results of a query to a file.
You won't do it the way you're trying to, because your dynamic SQL means that you don't know the resultant columns of the query so that you can output them. To do that you need to use the DBMS_SQL package to describe the query and fetch the returned columns by position e.g.
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
ELSE
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
END CASE;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required. -
Passing / parsing XML String IN / OUT from PL / SQL package
Hello, People !
I am wondering where can I find exact info (with code sample) about following :
We use Oracle 8.1.6 and 8.1.7. I need to pass an XML String (could be from VARCHAR2 to CLOB) from VB 6.0 to PL/SQL package. Then I need to use built in PL/SQL XML parser to parse given string (could be large hierarchy of nodes)
and the return some kind of cursor thru I can loop and insert data into
different db Tables. (The return value may have complex parent/child data relationship - so I am not sure If this should be a cursor)
I looked online many site for related info - can't find what I am looking
for - seems like should be a common question.
Thanx a lot !Hello, People !
I am wondering where can I find exact info (with code sample) about following :
We use Oracle 8.1.6 and 8.1.7. I need to pass an XML String (could be from VARCHAR2 to CLOB) from VB 6.0 to PL/SQL package. Then I need to use built in PL/SQL XML parser to parse given string (could be large hierarchy of nodes)
and the return some kind of cursor thru I can loop and insert data into
different db Tables. (The return value may have complex parent/child data relationship - so I am not sure If this should be a cursor)
I looked online many site for related info - can't find what I am looking
for - seems like should be a common question.
Thanx a lot ! -
Parsing a string in PL/SQL?
I am parsing a string in PL/SQL and at a certain point(Length 45) of the string I would like to add a carriage return (Chr(10)), then continue with the string at that point and then again if the string is greater than Length 45 add a carriage return.
I program in Powerbuilder and have figured it out, but I have a problem when trying to add a carriage return at a certain point in the string in PL/SQL. There is the REPLACE(), but that will replace everything, but I only want to add it at that certain point of the string. With the PB function I can add the carriage return at a certain point, see code:
Li_pos = PosA( Ps_data, '*')
DO WHILE Li_pos > 0
ll_length = Li_pos - ll_old_pos
IF ll_length > 45 THEN
ll_old_pos = Li_pos
Ps_data = ReplaceA( Ps_data, Li_Pos, 1, ls_carriage_rtn) **This function gives me the ability to add a carriage return at a certain point in the string. **
Li_pos = PosA( Ps_data, '*', Li_pos + 1 + ls_carriage_rtn)
ELSE
Li_pos = PosA( Ps_data, '*', Li_pos + 1)
END IF
LOOP
I have incorporated the same logic in PL/SQL but I am looking for something similar to the ReplaceA function in PB, that will replace at a certain point in a string. I use an '*' as a placeholder and measure the length. Below is the PL/SQL code:
t_pos NUMBER;
t_old_pos NUMBER;
t_length NUMBER;
BEGIN
t_old_pos := 0;
t_pos := INSTR(in_model_list, '*');
WHILE t_pos > 0 LOOP
t_length := t_pos - t_old_pos; -- This looks at current position minus the old position, measures the length
IF t_length > 45 THEN
t_old_pos := t_pos;
*** add that carriage return
t_pos := INSTR(in_model_list, '*', t_pos + 1 + Chr(10)); -- get the new position
NULL;
ELSE
t_pos := INSTR(in_model_list, '*', t_pos + 1);
END IF;
NULL;
END LOOP;
Here is the data, what it looks like: William 112,* 500-A,* 500-U,* 520,* 560-A,* 560-E,* 680-E,* 680-F,* 680-V*
Any help would be much appreciated.
Thank you,
William
Edited by: William on Feb 28, 2012 6:56 AMFrank Kulash wrote:
[example]I played with your example and came to this:SQL> WITH my_string AS
2 (SELECT '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'
3 AS mt
4 FROM DUAL)
5 , line_length AS
6 (SELECT 13 AS chars
7 FROM DUAL)
8 SELECT LISTAGG (REGEXP_SUBSTR (mt,'(.{'|| line_length.chars|| '})', 1, LEVEL),chr(10)) WITHIN GROUP (ORDER BY LEVEL)
9 ||chr(10)
10 ||substr(mt,-mod(LENGTH (mt),line_length.chars)) as wrapped_text
11 FROM my_string
12 CROSS JOIN line_length
13 CONNECT BY LEVEL < 1+LENGTH (mt) ;
WRAPPED_TEXT
1234567890123
4567890123456
7890123456789
0123456789012
3456789012345
6789012345678
9012345678901
2345678901234
5678901234567
8901234567890
1234567890123
WRAPPED_TEXT
4567890123456
7890
SQL>*[Edit]* annotated that this is 11g only...
Edited by: T.PD on 29.02.2012 21:17 -
Need Help in Splitting a String Using SQL QUERY
Hi,
I need help in splitting a string using a SQL Query:
String IS:
AFTER PAINT.ACOUSTICAL.1..9'' MEMBRAIN'I would like to seperate this string into multiple lines using the delimeter .(dot)
Sample Output should look like:
SNO STRING
1 AFTER PAINT
2 ACOUSTICAL
3 1
4
5 9" MEMBRAIN
{code}
FYI i am using Oracle 9.2There's this as well:
with x as ( --generating sample data:
select 'AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN' str from dual union all
select 'BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN' str from dual)
select str,
row_number() over (partition by str order by rownum) s_no,
cast(dbms_xmlgen.convert(t.column_value.extract('//text()').getstringval(),1) as varchar2(100)) res
from x,
table(xmlsequence(xmltype('<x><x>' || replace(str,'.','</x><x>') || '</x></x>').extract('//x/*'))) t;
STR S_NO RES
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 1 AFTER PAINT
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 2 ACOUSTICAL
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 3 1
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 4
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 5 9" MEMBRAIN
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 1 BEFORE PAINT
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 2 ELECTRIC
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 3 2
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 4
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 5 45 caliber MEMBRAIN
{code} -
How to get numeric data from a string using t-sql
Hi All,
I have a table with 2 columns ID as Int and Message as nvarchar(max)
Create table Sample
ID int not null,
Message nvarchar(max) null,
CONSTRAINT [PK_ID_Msg] PRIMARY KEY CLUSTERED
ID asc
Insert statement:
INSERT INTO
Sample (ID, Message)
VALUES (1, 'X_YRS: 00 ; X_MONS: 18 ; X_DAYS: 000 ; Y_YRS: 00 ; Y_MONS: 16 ; Y_DAYS: 011 ; Z: 1 ; Z_DATE: 09/04/2014
INSERT INTO Sample (ID, Message) VALUES (2, 'X_YRS: 01 ; X_MONS: 15 ; X_DAYS: 010 ; Y_YRS: 00 ; Y_MONS: 18 ; Y_DAYS: 017
; Z: 1
; Z_DATE: 06/02/2012')
Data in the table looks like:
ID Message
1 X_YRS: 00 ; X_MONS: 18 ; X_DAYS: 000 ; Y_YRS: 00 ; Y_MONS: 16 ; Y_DAYS: 011 ; Z: 1 ; Z_DATE: 09/04/2014
2 X_YRS: 01 ; X_MONS: 15 ; X_DAYS: 010 ; Y_YRS: 00 ; Y_MONS: 18 ; Y_DAYS: 017 ; Z: 1 ; Z_DATE: 06/02/2012
Need out put as below, just with numeric data:
ID X-Column Y-Column
1 00 18 000 00 16 011
2 01 15 010 00 18 017
So, please I need t-SQL to get above output.
Thanks in advance.
RH
sql;With CTE
AS
SELECT s.ID,RTRIM(LTRIM(STUFF(Val,1,CHARINDEX(':',Val),''))) AS Val,RTRIM(LTRIM(LEFT(Val,CHARINDEX('_',Val+'_')-1))) AS Pattern,
--ROW_NUMBER() OVER (PARTITION BY LEFT(Val,CHARINDEX('_',Val+'_')-1) ORDER BY RTRIM(LTRIM(STUFF(Val,1,CHARINDEX(':',Val),'')))*1)
f.ID AS Seq
FROM Sample s
CROSS APPLY dbo.ParseValues(s.[Message],';')f
WHERE ISNUMERIC(RTRIM(LTRIM(STUFF(Val,1,CHARINDEX(':',Val),'')))+'0.0E0')=1
SELECT ID,
STUFF((SELECT ' ' + Val FROM CTE WHERE ID = c.ID AND Pattern = 'X' ORDER BY Seq FOR XML PATH('')),1,1,'') AS XCol,
STUFF((SELECT ' ' + Val FROM CTE WHERE ID = c.ID AND Pattern = 'Y' ORDER BY Seq FOR XML PATH('')),1,1,'') AS YCol,
STUFF((SELECT ' ' + Val FROM CTE WHERE ID = c.ID AND Pattern = 'Z' ORDER BY Seq FOR XML PATH('')),1,1,'') AS ZCol
FROM (SELECT DISTINCT ID FROM CTE)c
ParseValues can be found here
http://visakhm.blogspot.in/2010/02/parsing-delimited-string.html
Numeric check logic is as per below
http://visakhm.blogspot.in/2014/03/checking-for-integer-or-decimal-values.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
To generate sql string of desired row using function.
Hi l,
I return the below query to get sum of vehicles which falls between the specific weight ranges.
It returns 20 rows( As I selected 4 classification vehicles).I was expect only 4 rows .One row for each classification of vehicles.
Is there a way if do some loop or decode in my function logic?
will tht work?
"(This is only smple. In my real appilication, if I use 15 classification vehicles it returns 320 rows. But i expect only 16 rows - 0 to 15 one row for each classification .Duirng runtime I'm getting an error as buffer string too small)"
How could I solve this?
I use this query inside a function and I call that function in a dynamic sql.
SELECT 'SUM('
|| 'CASE '
|| 'WHEN weight_report_data.weight >= '|| repo_range_param.min_value ||'
AND weight_report_data.weight < repo_range_param.max_value
THEN weight_report_data.weight_count '
|| 'ELSE 0 '
|| 'END '
|| ') "Class ' || repo_param.r_value || '" '
FROM repo_param
JOIN repo_range_param
ON repo_param.r_id = repo_range_param.r_id
WHERE repo_param.r_id = 1
AND repo_param.r_group = 'class'
AND repo_param.r_name = 'class'
AND repo_range_param.r_group = 'gvw'
AND repo_range_param.r_name = 'gvw'
ORDER BY CAST(repo_param.r_value AS NUMBER) ASC;
"sample sql string output when I run the above query "
SUM(CASE WHEN weight_report_data.weight >=10
AND weight_report_data.weight <15
THEN weight_report_data.weight_count ELSE 0 END ) "Class 0"
SUM(CASE WHEN weight_report_data.weight >=15
AND weight_report_data.weight <20
THEN weight_report_data.weight_count ELSE 0 END ) "Class 1"
SUM(CASE WHEN weight_report_data.weight >=5
AND weight_report_data.weight <10
THEN weight_report_data.weight_count ELSE 0 END ) "Class 2"
SUM(CASE WHEN weight_report_data.weight >=20
AND weight_report_data.weight <25
THEN weight_report_data.weight_count ELSE 0 END ) "Class 3"
"sample data for the tables involved"
CREATE TABLE weight_report_data
start_date_time TIMESTAMP NOT NULL,
end_date_time TIMESTAMP NOT NULL,
weight NUMBER(12,0) NOT NULL,
weight_count NUMBER(12,0) NOT NULL
INSERT INTO weight_report_data(start_date_time, end_date_time, weight, weight_count)
VALUES('01-JUL-08 12:00:00','03-JUL-08 12:00:00',4,5);
INSERT INTO weight_report_data(start_date_time, end_date_time, weight, weight_count)
VALUES('01-JUL-08 12:00:00','03-JUL-08 12:00:00',3,1);
INSERT INTO weight_report_data(start_date_time, end_date_time, weight, weight_count)
VALUES('01-JUL-08 12:00:00','03-JUL-08 12:00:00',8,6);
INSERT INTO weight_report_data(start_date_time, end_date_time, weight, weight_count)
VALUES('01-JUL-08 12:00:00','03-JUL-08 12:00:00',25,9);
CREATE TABLE repo_param
R_ID NUMBER(12,0),
R_GROUP VARCHAR2(10),
R_NAME VARCHAR2(10),
R_VALUE VARCHAR2(10)
INSERT INTO repo_param(r_id, r_group, r_name, r_value)
VALUES(1,'class','class',0);
INSERT INTO repo_param(r_id, r_group, r_name, r_value)
VALUES(1,'class','class',1);
INSERT INTO repo_param(r_id, r_group, r_name, r_value)
VALUES(1,'class','class',2);
INSERT INTO repo_param(r_id, r_group, r_name, r_value)
VALUES(1,'class','class',3);
CREATE TABLE repo_range_param
R_ID NUMBER(12,0),
R_GROUP VARCHAR2(10),
R_NAME VARCHAR2(10),
MIN_VALUE NUMBER(3,0),
MAX_VALUE NUMBER(3,0)
INSERT INTO repo_range_param(r_id, r_group, r_name, min_value, max_value)
VALUES(1,'gvw','gvw',0,5);
INSERT INTO repo_range_param(r_id, r_group, r_name, min_value, max_value)
VALUES(1,'gvw','gvw',5,10);
INSERT INTO repo_range_param(r_id, r_group, r_name, min_value, max_value)
VALUES(1,'gvw','gvw',10,15);
INSERT INTO repo_range_param(r_id, r_group, r_name, min_value, max_value)
VALUES(1,'gvw','gvw',15,20);
INSERT INTO repo_range_param(r_id, r_group, r_name, min_value, max_value)
VALUES(1,'gvw','gvw',20,25);
Thanks in advance
Edited by: user10641405 on Jun 18, 2009 4:10 PM
Edited by: user10641405 on Jun 18, 2009 4:15 PM
Edited by: user10641405 on Jun 18, 2009 4:15 PM
Edited by: user10641405 on Jun 18, 2009 4:16 PM
Edited by: user10641405 on Jun 18, 2009 4:17 PM
Edited by: user10641405 on Jun 18, 2009 7:47 PM
Edited by: user10641405 on Jun 19, 2009 4:15 PMSay you have a 3 tables
Table name Description rowcount()
============================================================================
weight_report_data report table having weights and counts 4
repo_param having id column gives different classes 4
repo_range_param is detail table of repo_param with id 4
as foreign key and defines weight
min max ranges.
Now you need to report
per class how many weights weights are there ?
--not understood report id clearly in relation to weight_report_data
step1:
need to map each row of weight_report_data againist its class.
select wrd.weight,wrd.weight_count,(select rp.class||rp.value
from repo_range_param rrp,
repo_param rp
where rrp.id= rp.id
and rp.id=1 -- add your other join condition
and wrd.weight between rrp.min and rrp.max ) class_nm
from weight_report_data wrd ;
This will give 4 rows , i.e for each row in wrd it tells which class it falls.
now you want to group by class_nm to get sum or count of weights.
step2:
select class_nm,sum(weight), count(weight), sum(weight_count)
from (
select wrd.weight,wrd.weight_count,(select rp.class||rp.value
from repo_range_param rrp,
repo_param rp
where rrp.id= rp.id
and rp.id=1 -- add your other join condition
and wrd.weight between rrp.min and rrp.max ) class_nm
from weight_report_data wrd ) wrd_classnm
group by class_nm;
I hope this helps .
suggestion: first analyse and breakdown into stpes how you r going to do if you do by hand and then translate into sql and then optimise -
Problem in parsing a xml string using dom parser
i want to parse a Xml String using a Dom parser......the parse function in dom parser takes only input stream as argument.......so i made the code as
InputStream inputstream = new StringBufferInputStream(XmlData) ;
InputSource inputSource = new InputSource(inputstream );
but saxexception is coming and also warning called
"java.io.StringBufferInputStream in java.io has been deprecated"
please help me.........i want to parse a Xml String using a Dom
parser......the parse function in dom parser takes
only input stream as argument.......This is not true of the DOM parser in Java 1.4. So you might want to get rid of your old parser and replace it by something more current. Or perhaps you are using 1.4 and you just didn't read all of the API docs. -
Hi all,
How do i use Native SQL String in the Reciver JDBC Adapter.
Do i need to change the message format could u suggest me some blogs on the same.
Also please can anyone let me knw if i can use this for stored procedure.hi aditya,
there shud be no format as such. for sql xml format there are specific structure. but for native sql there shudnt be any specific structure.
as pointed in sap documentaion:
Instead of an XML document format, a text is expected that represents any valid SQL statement.
When inserting a line into a table the corresponding document looks as follows:
INSERT INTO tableName (column-name1, column-name2, column-name3) VALUES(column-value1, column-value2, column-value3)
so jus make sure that u give a valid sql statement becoz if will be passed as it is to the database and try ur scenario.
regards,
latika. -
Parse a string that uses nested string delimiters
I’m looking for a way to parse a string that uses double quotes as the delimiter that contains a nested string with double quotes. I want to keep the double quotes in the nested string. Is there a function in Labview that I can use to easily do this? Does Labview have a command line parser / interpreter?
The string example is: While match "Send Test "Sleep 5" ">""
The result string would be: Send Test "Sleep 5" ">"Here is another solution which is slightly faster. Speed won't be
an issue unless you are running millions at a time, as in my test the
difference was only 1-2 ms in 10000 iterations. In this image the
Match Pattern function retrieves the desired string, including the
outside quotes, so the String Length and String Subset functions are
used to remove the first and last characters of the result.
Message Edited by tuba on 04-11-2006 10:35 PM
Attachments:
parse.gif 3 KB
Maybe you are looking for
-
Changing art board colour Boarder
I find myself using Black Backgrounds often in illustrator. Bleeding a Black BG makes it impossible to see the art board boarder. The solution to this has been for me to either place guild lines on these guide lines (silly really) and jarring. specia
-
whats the best/safest way for me to clean the smudges off my macbook pro screen?
-
I have a Mac Mini Server running Snow Leopard Server. It is currently configured as a webserver(Development) and all the sites that are in the /Library/Webserver/Sites Directory. I am trying to move all the sites(Files) to a network share that is on
-
New C20's Are super loud! Over 65db! Is this normal?
We just recieved two new C20's. However, they are super loud. I've measured the sound at around 65db. I've set the fan mode to "quiet" in the bios, but that made no difference. Is this normal? Thanks! Solved! Go to Solution.
-
Even files of small size are not getting attached in yahoo mail when I use firefox. However there is no problem when I use IE.