cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC Adapter Quoting of String

Former Member
0 Kudos

Hi everybody!

I am posting data to a JDBC Receiver adapter using the JDBC adapter's XML format. I have configured the logging of the adapter to show the SQL commands issued to the adapter, since I received some strange errors from the database.

I now find entries like:

INSERT INTO  xxx (field1, field2, field3) VALUES (value1, , value3)

Notice the "missing" value2 - the field's value is a space character (" "). However, I actually wanted to quote the values in this field, since this SQL command of course gives a syntax error because of the two consecutive commas...

How can I quote strings in this SQL command?

Regards, Joerg

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

You need to enclose the string within single quotes

regards

krishna

Former Member
0 Kudos

Hi,

You mean explicitly, in my mapping program? There is no configuration setting for this?

Regards,

Joerg

Former Member
0 Kudos

Hi

you should enter

INSERT INTO xxx (field1, field2, field3) VALUES ('value1', ' ' , 'value3')

regards

krishna

Former Member
0 Kudos

Hi,

I don't know if I stated my problem clearly enough... Here is the XML document I post to the JDBC adapter:


<root>
  <insert>
    <xxx action="INSERT">
      <field1>value1</field1>
      <field2> </field2>
      <field3>value1</field3>
    </xxx>
  </insert>
</root>

(note the blank character for field2's value). If I understand your answer correctly, I should use the following instead:


<root>
  <insert>
    <xxx action="INSERT">
      <field1>'value1'</field1>
      <field2>' '</field2>
      <field3>'value1'</field3>
    </xxx>
  </insert>
</root>

This is somewhat inconvenient, since there might be <b>NULL</b> values as well and I'd have to code manymany <b>if</b> statements and <b>mapWithDefaults</b>, then. I was wondering if there is something like the config setting "Interpretation of Empty String Values" for NULL values, some switch I set globally in order to <i>always</i> quote a string...

Regards, Joerg

Former Member
0 Kudos

Hi joerg

sorry .I did not get your question correctly. Now, as suggested add the hasQuot attributed

<root>

<insert>

<xxx action="INSERT">

<field1 >value1</field1>

<field2 hasQuot="Yes" > </field2>

<field3 > value1</field3>

</xxx>

</insert>

</root>

There is no need to add any explicit ' ' as i suggested earlier

regards

krishna

bhavesh_kantilal
Active Contributor
0 Kudos

In your mapping use MAPWITHDEFAULT.

regards

Bhavesh

Former Member
0 Kudos

Hi Joerg,

I am sure there is a way out . I dont remember exactly what i did.

But i am sure i didnt add hasQuote , i didnt add ' ' in mapping 2.

You can try this..If a certain value might not exist in the target what you can possibly do is..

When you create the datatype give the occurrence as 0..1 .

I think this might work.

Regards,

Sumit

Former Member
0 Kudos

yaa u can map with default function while mapping proceedure

Answers (1)

Answers (1)

Former Member
0 Kudos

Joerg,

You need to add the attribute, hasQuot to the fields <b>field1, field2, field3</b>. Look into help.sap for document formats.

http://help.sap.com/saphelp_nw70/helpdata/en/22/b4d13b633f7748b4d34f3191529946/frameset.htm

Regards,

Jai Shankar

Message was edited by:

Jai Shankar