Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
597 views
in Technique[技术] by (71.8m points)

websphere - esql command to insert query into data base using xml format

I tried to insert a sql query using esql code:

INSERT INTO Database.dbo.CUSTOMERS Values (9330,'Sai',7);

It is working fine but it was show error when it tried to insert code using xml format like:

INSERT INTO Database.dbo.CUSTOMERS(ID,NAME,AGE) Values (InputRoot.XMLNSC.emps.emp.id,InputRoot.XMLNSC.emps.emp.name,InputRoot.XMLNSC.emps.emp.age);

Then it was showing errors like BIP2230E, BIP2488E, BIP2321E.

enter image description here

If there is any connectivity problem means first insert command also should not work. Select also working fine.

Any suggestions to resolve problem?

question from:https://stackoverflow.com/questions/65847646/esql-command-to-insert-query-into-data-base-using-xml-format

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It is fairly obvious that your paths (InputRoot.XMLNSC.emps.emp.id, etc ) do not exist under InputRoot.XMLNSC. You could easily check this using the debugger or (better) a Trace node. To fix the problem, correct those paths.

You should also be declaring and using a REFERENCE variable, to make your ESQL more readable:

-- This is not the correct path, otherwise your code would be working already!
DECLARE refEmp REFERENCE to InputRoot.XMLNSC.emps.emp;
INSERT 
    INTO Database.dbo.CUSTOMERS(ID,NAME,AGE) 
    VALUES (refEmp.id,refEmp.name,refEmp.age)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...