cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Nodejs: Insert HTML content in Hana Table

former_member25214
Participant
0 Likes
687

Hi, I'm having difficulty in insertion of a string that contains special characters. Below is my query

INSERT INTO "3D5F24CF599F49B2B3D8FD219665A30B"."TEST_FAQ" VALUES(
	'2021-02-10T12:41:01.928Z'/*CREATEDAT <TIMESTAMP>*/,
	'admin'/*CREATEDBY <NVARCHAR(255)>*/,
	'2021-02-10T12:41:01.928Z'/*MODIFIEDAT <TIMESTAMP>*/,
	'admin'/*MODIFIEDBY <NVARCHAR(255)>*/,
	'5e3efc3e-6b9d-11eb-9439-0242ac130002'/*ID <NVARCHAR(36)>*/,
	'That's my question'/*QUESTION <NVARCHAR(5000)>*/,
	<p style='box-shadow: 1px 1px 5px #999999;position: relative;margin: 5px 10px;'><p style='padding: 10px;border: 1px solid transparent;'><p style='font-size:16px;word-wrap: break-word;'>Job Description
</p><p><p><strong>Primary Duties and Responsibilities</strong></p><ul><li>'/*ANSWER <NVARCHAR(5000)>*/
)


It gives me incorrect syntax error. Do I have to change my datatype ? How should I do this ?

Accepted Solutions (1)

Accepted Solutions (1)

former_member25214
Participant
0 Likes

I have to escape and using escape() function in nodejs. and use unescape after fetching ot from the database.

Answers (1)

Answers (1)

pfefferf
Active Contributor

There are two issues in your statement.

1) The opening single quote for the HTML content string is missing.

2) The single quotes in the HTML content string needs to be escaped. A single quote is escape with an additional single quote (' -> '').

former_member25214
Participant
0 Likes

Thanks for pointing it out, I I have to pre-process the string before saving it into my table. I'm not sure if its the right approach or not.