How to handle XML string with Single Quotes as a parameter to SP dynamically?
Hi,
I would like to know if there is a way to handle the Single Quotes in XML value when it is passed to Stored Procedure?
I should be able to handle it without adding another Single Quote to it.
Thanks,
Chandra Shekar
Hi Chandra,
Your requirement is not precise. Based on my understanding and guessing, are you metioning something like the below sample?
/*If the xml is generated you have no need to escape the singe quote(')*/
DECLARE @xmlTbl TABLE (ID INT,name VARCHAR(99));
INSERT INTO @xmlTbl VALUES(1,'Eric''s')
INSERT INTO @xmlTbl VALUES(2,'Zhang''s')
DECLARE @xmlDoc1 XML
SELECT @xmlDoc1
FROM @xmlTbl FOR XML PATH('PERSON'),ROOT('PERSONS')
EXEC yourProcedure @xmlDoc1
/*If your copy and paste the xml, you have to escape the single quote(') with 2s('')*/
DECLARE @xmlDoc2 XML
SET @xmlDoc2 = '<PERSONS>
<PERSON>
<ID>1</ID>
<name>Eric''s</name>
</PERSON>
<PERSON>
<ID>2</ID>
<name>Zhang''s</name>
</PERSON>
</PERSONS>'
EXEC yourProcedure @xmlDoc2
If that is not regarding your requirement, please elaborate with more details.
Eric Zhang
TechNet Community Support
Similar Messages
-
How to concatenate a string with single quotes
Hi all,
how to concatenate a string with single quotes to a variable.
SathyaHi sathyabama,
1. simple
2. use TILDE character <b>(`)</b>
(just left to the '1' key)
<b> `'mystring'`</b>
3. just copy paste
report abc.
data : m(100) type c.
concatenate `'amit mittal'` 'hello' into m separated by space.
write m.
regards,
amit m. -
How to handle multiple reports with single hyperlink parameter
Please suggest in my drill down report
i have two reports linked with one hyperlink
parameter, how to handle this?
please suggest for popup window with sample solution.
for example
report A--->B--->Chosse Report c or D
based on parameter hyperlink at report B.
Thanks in advance
RajYes U R correct, that
I'm using srw.set_hyperlink in plsql format trigger
to open other reports , now the problem is
how to carry over the hyperlink parameter to popup window
and allow user to choose any reports based on the
parameter value.
for example
report A (Sales person summmary report)
|
| (choose sales person drilled to orders report B)
|
B (report has the hyperlink on order no)
|
|
C,D,E (many reports based on order no
customer,order details,pending items
to be shipped)
Now how to handle the situation from b to c,d,e
I suggest use hyperlink at B to open popup to show
reports C,D,E with the order no has parameter.
please suggest for javascript to open popup window
for reports c,d,e.
Thanks
Raj -
How can i insert values with single quote (')
How can i insert a values like ABC's ?
Edited by: LuKKa on Oct 6, 2010 12:48 PMLuKKa wrote:
I want to insert like this :-
INSERT INTO myTab values ('This is belong's to ABC's ');
Then how can i do ?In a old style you can do this
insert into mytab valeus('This is belong''s to ABC''s'); -
How to deal with single quote (') in a field value?
I can successfully insert value with single quoet using
Prepared statement with placeholder(?) construct .
I can also successfuly use value with single quote(') in
WHERE clause.
My question is, is there a way to use string with single
quote if a Statement like:
String slqString ="INSERT INTO customers (name, address) VALUES ( 'O'Reilly Bob', 'St Mary's Street') ";
Statement sqlStmt = con.createStatement();
sqlStmt.executeUpdate(sqlString);
The last statement will thow an SQLException because due to single quotes
Any ideas?I think the question was regarding the ' in O'Reily. Use ' twice when using the Statement interface, i.e.
("O''Reilly Bob", "St Mary''s Street")
So that's two single quotes, not a double quote, to successfully insert a single quote, if you know what I mean....
But like you said PreparedStatement does things like this for you. -
Escape XML Strings with JDK class
Hi,
can anyone tell me how to escape XML-Strings with classes of the JDK?
When searching I only was pointed to StringEscapeUtils from apache.commons.lang, but we would prefer to use the JDK instead of integrating an external lib.
Our aim is to escape an XML attribute, so a CDATA is not applicable for us in this case.
Thanks
JanI implemented it by myself:
public static String escapeXmlAttribute(String attributeValue) {
StringBuffer result = new StringBuffer();
for (int c = 0; c < attributeValue.length(); ++c) {
if (attributeValue.charAt(c) == '"') {
result.append(""");
} else if (attributeValue.charAt(c) == '&') {
result.append("&");
} else if (attributeValue.charAt(c) == '<') {
result.append("<");
} else if (attributeValue.charAt(c) == '>') {
result.append(">");
} else {
result.append(attributeValue.charAt(c));
return result.toString();
}{code} -
Problem in insertion with string containing ' (single quote)
i have a text field in jsp.
when i submit the content need to be inserted/updated.
when the text field contains character's with single quote( ' )..
i am unable to insert/update values in database..
where as if the text field contains characters without single quote..there is no problem in Database insertion/updation.
i am using create statement .. and oracle database..
can any one help ...The usual answer for this in the JDBC forum (where this should have been posted because it's completely about JDBC) is to use a PreparedStatement.
-
Dynamic SQL and Data with Single Quotes in it.
Hi There,
I have a problem in that I am using dynamic SQL and it happens that one of the columns does contain single quotes (') in it as part of the data. This causes the resultant dynamic SQL to get confused as the single quote that is part of the data is taken to mean end of sting, when in fact its part of the data. This leaves out a dangling single quote that was meant to enclose the string. Here is my dynamic SQL and the result of the parsed SQL that I have captured:
****Dynamic SQL*****
l_sql:='select NOTE_TEMPLATE_ID '||
'FROM TMP_NOTE_TEMPLATE_VALUES '||
'where TRIM(LEGACY_NOTE_CODE)='''||trim(fp_note_code)||''' '||
'and TRIM(DISPLAY_VALUE)='''||trim(fp_note_text)||''' ';
execute immediate l_sql INTO l_note_template_id;
Because the column DISPLAY_VALUE contains data with single quotes, the resultant SQL is:
******PARSED SQL************
select NOTE_TEMPLATE_ID
FROM TMP_NOTE_TEMPLATE_VALUES
where TRIM(LEGACY_NOTE_CODE)='INQ' and TRIM(DISPLAY_VALUE)='Cont'd'
And the problem lies with the single quote between teh characters t and d in the data field for DISPLAY_ITEM. How can I handle this?
Many thanks,I have been reliably informed that if one doesn't enclose char/varchar2 data items in quotes, the right indices may not be usedI am into oracle for past 4 years and for the first time i am hearing this.
Your reliable source is just wrong. Bind variables are variables that store your value and which are used in SQL. They are the proper way to use values in your SQL. By default all variables in PL/SQL is bind variable.
When you can do some thing in just straight SQL just do it. Dynamic SQL does not make any sense to me here.
Thanks,
Karthick. -
Change XML declaration from single quote to double quote
Hi all,
i have the following problem in my File Receiver Adapter. My XML File has the declaration <?xml version='1.0' encoding='utf-8'?> (With single quotes ') and want to change it to <?xml version="1.0" encoding="utf-8" ?> (With double quotes ")
I use the XMLAnonymizerBean but this does not change the XML declaration.
Any ideas how to change the declaration
Thanks MaxHi Suraj,
on the Modul Tab i have the following:
1 | AF_Modules/XMLAnonymizerBean | Local Enterprise Bean | Anonymizer
2 | CallSapAdapter | Local Enterprise Bean | 0
Anonymizer | anonymizer.acceptNamespaces | http://Post.AG/PartnerInterface/Schemas/PVSdeAt/Aviso_V1.0 ns0 http://PostAG.PartnerInterface.Schemas.PVS_deAt.AvisoHeader ns1 http://PostAG.PartnerInterface.Schemas.PVS_deAt.AvisoShipper ns2
Anonymizer | anonymizer.quote | "
That is all what i have on the module tab.
I send the data as Text (not Binär). Thats all what i have in the adapter. Do you need any further information?
Regards, Max -
How to handle "xsd:anyAttributes" with jaxb
Need help for how to handling "xsd:anyAttribute" with jaxb!
Here is part of my xml schema.
<xsd:attributeGroup name="DataAttributes">
<xsd:anyAttribute namespace="##local" processContents="lax"/>
</xsd:attributeGroup>
<xsd:element name="Data">
<xsd:complexType>
<xsd:attributeGroup ref="DataAttributes"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="MA_Verify">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Data" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attributeGroup ref="verifyAttributes"/>
</xsd:complexType>
</xsd:element>
I have an application which only knows the attribute names and values at runtime. (Thest attributes are string.) Therefore, I cannot define attribute names in the schema and have to use xsd:anyAttribute.
I was able to generate all jaxb code. However, the interfaces generated for Data and DataType are basically all empty. The impl classes are empty too, since no get or set methods exist for the attribute.
Some thoughts for handling this case, but do not know if it will work.
(1) write some derive classes on top of the generated jaxb classes.
(2) write customized method to handle the 'Data' element level and its attributes. Similar to parseMethod or printMethod for the javaType.
(if there is a way)
Can anyone give me suggestions, directions or an laternate way to handle the situation?
Your help will be greatly appreciated.
Ruthxsd:anyAttribute is not supported by JAXB.
http://java.sun.com/xml/jaxb/users-guide/jaxb-works.html#unsupported -
How to print a string with out using main method??
how to print a string with out using main method??
if we can tell me with example?
thanks in adavance
rajaHi,
actually there's none. The UITableView class needs to "know" the tableView's height so either it can calc <number of rows> times <row height> or it has to sum the height of each single row.
If the row which needs to be of different size always is the first or the last row you can user a tableHeader or tableFoot view.
Regards
Dirk -
I am using PL_SQL with Oracle8i and OAS 4.0 web server.I want to
use owa_text.vc_arr to pass the inputs in serval text areas in the form on a web application.
If the input string length is less than 4000 characters, everything works fine.However when the strings are longer than 4000 characters but less than the max length 32767 characters, I got this error message:
OWS-05101: Execution failed due to Oracle error 2005
ORA-02005: implicit (-1) length not valid for this bind or define datatype.
In the Oracle Application Server 4.0 documment, it says
about owa_text.vc_arr :Type vc_arr is table of varchar2(32767)
index by binary_integer. It means that owa_text.vc_arr can handle multiple strings and each string can have up to 32767 single byte characters, is it right?
Owa_text.vc_arr is supposed to handle the string with more
than 4000 characters, is it true? Could anyone tell me why? Any
help will be greatly appreciated!!!
Thanks very much.
Helena Wang
Here is the pl_sql procedure to create my form on the web:
PROCEDURE myform
IS
BEGIN
htp.p('
<form action="'||service_path||'helena_test.saveform3"
method=post>
<input type=hidden name=tdescription value="X">
Input1: <textarea name=tdescription rows=50 cols=70
WRAP=physical></textarea>
Input2: <textarea name=tdescription rows=50 cols=70
WRAP=physical></textarea>
<input type=submit name=WSave value="Save">
</form>
END;
/***** here is the pl_sql procedure which I use to save the
form***/
procedure saveform3(tdescription in owa_text.vc_arr,
WSave in varchar2 default 'No')
is
len pls_integer;
begin
for i in 2..tdescription.count loop
len := length(tdescription(i));
htp.p(len);
htp.p(tdescription(i));
end loop;
end;The maximum size of a VARCHAR2 field in Oracle 8i is 4000 bytes.
you'll ned to use a LOB type (or LONG if you prefer the old way) -
Importing excel files - problem with single quote
When importing excel files using 1.5, I can't get data with single quotes (') imported.
When I run the insert statement given in SQLPlus I get "ORA-01756: quoted string not properly terminated", which is different than the error that SQL Developer gives me (see below).
Also, I have a numeric value shown without a thousands comma-separator in the XLS file that I'm trying to load into a varchar2 field. But, the insert statements have added a thousands comma-separator which I don't want.
REM Error starting at line 1 in command:
REM INSERT INTO table (ID, NAME, CODE)
REM VALUES (2427407, 'Ed-u-care Children's Center', '73,000');
REM Error at Command Line:2 Column:37
REM Error report:
REM SQL Error: ORA-00917: missing comma
REM 00917. 00000 - "missing comma"
REM *Cause:
REM *Action:
One last thing, TOAD gives a way to automap columns chosen from XLS to the columns in the database. It sure would be nice to have this functionality in SQL Developer.
Thanks,
SteveDid you consider both to be bugs (i.e., single quote issue and thousands comma separator issue)?
Thanks -
How to handle Table controls with XD01 in BDC
How to handle Table controls with XD01 in BDC - If there are more than 5/6 records in Table control. - Can any one explain it with a piece of code plz..
Thanks & Regards,
Krishna ChaitanyaHi
check this code...viz for xko1....
DATA: BEGIN OF it_xk01 OCCURS 0,
f1(1),
f2(5),
f3(5),
f4(9),
f5(9),
END OF it_xk01.
DATA: v_count(2) VALUE '00',
v_koinh(14),
v_banks(14),
v_bankn(14),
v_bankl(14),
it_bdcdata TYPE STANDARD TABLE OF bdcdata WITH HEADER LINE,
wa_ctuparams type ctu_params.
PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_f4.
START-OF-SELECTION.
PERFORM upload_data.
END-OF-SELECTION.
LOOP AT it_xk01.
IF it_xk01-f1 = 'H'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-KTOKK'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02K-KTOKK'
it_xk01-f2.
ENDIF.
IF it_xk01-f1 = 'N'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-PSTLZ'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=VW'.
PERFORM bdc_field USING 'LFA1-ANRED'
'Mr'.
PERFORM bdc_field USING 'LFA1-NAME1'
it_xk01-f2.
PERFORM bdc_field USING 'LFA1-SORTL'
it_xk01-f3.
PERFORM bdc_field USING 'LFA1-PSTLZ'
it_xk01-f4.
PERFORM bdc_field USING 'LFA1-LAND1'
it_xk01-f5.
PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=VW'.
ENDIF.
IF it_xk01-f1 = 'I'.
v_count = v_count + 1.
IF v_count le 5.
CONCATENATE 'LFBK-KOINH(' v_count ')' INTO v_koinh.
CONCATENATE 'LFBK-BANKS(' v_count ')' INTO v_banks.
CONCATENATE 'LFBK-BANKN(' v_count ')' INTO v_bankn.
CONCATENATE 'LFBK-BANKL(' v_count ')' INTO v_bankl.
CONDENSE v_koinh NO-GAPS.
CONDENSE v_banks NO-GAPS.
CONDENSE v_bankl NO-GAPS.
CONDENSE v_bankn NO-GAPS.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
v_koinh.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING v_banks
it_xk01-f2.
PERFORM bdc_field USING v_bankl
it_xk01-f3.
PERFORM bdc_field USING v_bankn
it_xk01-f4.
PERFORM bdc_field USING v_koinh
it_xk01-f5.
else.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
v_koinh.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
v_count = 1.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
v_koinh.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
CONCATENATE 'LFBK-KOINH(' v_count ')' INTO v_koinh.
CONCATENATE 'LFBK-BANKS(' v_count ')' INTO v_banks.
CONCATENATE 'LFBK-BANKN(' v_count ')' INTO v_bankn.
CONCATENATE 'LFBK-BANKL(' v_count ')' INTO v_bankl.
CONDENSE v_koinh NO-GAPS.
CONDENSE v_banks NO-GAPS.
CONDENSE v_bankl NO-GAPS.
CONDENSE v_bankn NO-GAPS.
PERFORM bdc_field USING v_banks
it_xk01-f2.
PERFORM bdc_field USING v_bankl
it_xk01-f3.
PERFORM bdc_field USING v_bankn
it_xk01-f4.
PERFORM bdc_field USING v_koinh
it_xk01-f5.
ENDIF.
ENDIF.
CLEAR it_xk01.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
v_koinh.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
wa_ctuparams-DISMODE = 'A'.
wa_ctuparams-UPDMODE = 'S'.
wa_ctuparams-DEFSIZE = 'X'.
CALL TRANSACTION 'XK01' USING it_bdcdata MODE 'A'
UPDATE 'S'.
options from wa_ctuparams.
MODE 'A'
UPDATE 'S'.
*& Form upload_data
text
FORM upload_data .
DATA: lv_infile TYPE string.
lv_infile = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_infile
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_xk01.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " upload_data
*& Form get_f4
text
FORM get_f4 .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
FIELD_NAME = ' '
IMPORTING
file_name = p_file.
ENDFORM. " get_f4
Start new screen *
FORM bdc_dynpro USING program dynpro.
CLEAR it_bdcdata.
it_bdcdata-program = program.
it_bdcdata-dynpro = dynpro.
it_bdcdata-dynbegin = 'X'.
APPEND it_bdcdata.
ENDFORM. "BDC_DYNPRO
Insert field *
FORM bdc_field USING fnam fval.
IF FVAL <> NODATA.
CLEAR it_bdcdata.
it_bdcdata-fnam = fnam.
it_bdcdata-fval = fval.
APPEND it_bdcdata.
ENDIF.
ENDFORM. "BDC_FIELD
*H 0302
*N sdng dddsj 500020 IN
*I IN ICICI 734897597 xyz
*I IN SBH 768346687 abc
*I IN SBI 345687346 fgh
*I IN SBH 763846878 ujhgf
*I IN HSBC 797893778 fvdg
*I IN HDFC 723678638 fdgf
*I IN 4444 435645646 fgfg
*I IN 3400 763468768 gfgfg -
Hi,-
I am trying to parse an XML string with xpath as follows but I am getting null for getresult.
I am getting java.xml.xpath.xpathexpressionexception at line where
getresult = xpathexpression.evaluate(isource); is executed.
What should I do after
xpathexpression = xPath.compile("a/b");in the below snippet?
Thanks
String xmlstring ="..."; // a valid XML string;
Xpath xpath = XPathFactory.newInstance().newPath();
xpathexpression = xPath.compile("a/b");
// I guess the following line is not correct
InputSource isource = new inputSource(new ByteArrayInputStream(xmlstring.getBytes())); right
getresult = xpathexpression.evaluate(isource);My xml string is like:
<a>
<b>
<result> valid some more tags here
</result>
</b>
<c> 10
</c>
</a>Edited by: geoman on Dec 8, 2008 2:30 PMI've never used the version of evaluate that takes an InputSource. The difficulty with using it is that it does not save the DOM object. Each expression you evaluate will have to create the DOM object, use it once and then throw it away. I've yet to write a program that only needs one answer from an XML document. Usually, I use XPath to locate somewhere in a document and then read "nearby" content, add new content nearby, delete content, or move content. I'd suggest you may want to parse the XML stream and save the DOM Document.
Second, all of the XPath expressions search from a "context node". I have not had good luck searching from the Document object, so I always get the root element first. I think the expression should work if you use the root as the context node. You will need one of the versions of evaluate that uses an Object as the parameter.
Maybe you are looking for
-
Login scripts not running with AnyConnect NAM and ISE 1.2
I am using AnyConnect 3.1 NAM as my 802.1x supplicant for ISE 1.2. When users log in with EAP Chaining (User and Machine Auth), the login script seems hit or miss on if it runs to map their drives. If I uninstall the NAM client, they map drives eve
-
IPhone with 2.0 update and iTunes 7.7 - Will not sync.
I am unable to sync my iPhone at all with my MacBook. It was syncing fine, until I installed a few applications. Now it will not sync period, no errors either. It is in System Profiler: iPhone: Version: 0.01 Bus Power (mA): 500 Speed: Up to 480 Mb/se
-
WLC "radius server overwrite interface" setting
Hello I'm looking at using "radius server overwrite interface" on a WLAN as a replacement for Called-Station-ID for Radius to match on SSID. When I enable "radius server overwrite interface" on a WLAN and join a client to the SSID I can see (via pack
-
Exception:oracle.jsp.parse.JspParseException
hi, I deploy my bibeans application via jdeveloper in to application server and copy my lib file named bibeans.jar in web-inf/lib. after I try to view my jsp page which view my graph my browser show internal server error message (error 500 in IE)and
-
ICloud and pdf file attachments
Several of the small companies that I work with don't allow downloads of anything from any "cloud." But I'm using iCloud now for my emails. How do I send pdf files, but not through the cloud? Thank you for your help.