Comma missing in Execute Non Query

Hi,

I am getting this error → Execute Non Query: ORA-00917: missing comma
my query looks like this →

“insert into table_name(col1,col2,col3,col4,col5,create_date,created_by) values (00,0,'”+variable_1+“‘,’”+system.Environment.UserName+“‘,’”+“New”+“‘,’”+“TO_DATE('23-04-49 20:18:07”+“‘,’”+“DD-MM-YY HH24:MI:SS’)”+“‘,’”+system.Environment.MachineName+“')”

Needed help on how to correctly write this query.

1 Like

Any help ? @loginerror @divyagupt @AshwinS2 @aksh1yadav

can i have a screesshot of where this expression is mentioned that is in the editable area because we can find the red curly marks with which we can identify where we want to add the comma
@hss

@hss - I’d start with some basic troubleshooting - First try removing all variables and hardcode to see if it is working. If it is working, then add in one variable at a time and re-run until you get it working with all of the variables/paramaters

1 Like

@Palaniyappan the edit query box doesn’t show any red marks…

This is my workflow screenshot

Here is the output:

As u can see the way comma is being put is wrong i feel… am not sure how to correctly put… (I put the query in write line activity )… Pls see this.

@Dave i tried hardcoding… it shows this… am doing some mistake here…
pls help… maybe this what @Palaniyappan was talking about… the red lines…

@hss - i copy + pasted your code from the original post and it looks like the incorrect “double quote” character is being used, that is what is causing at least some of your issues. You can tell immediately within your screenshot as well since the correct double quote will change the color of the text when you’re working in uipath

EDIT: Here is your original post with the correct ‘single’ and “double” quotes. Note that I didn’t check the syntax or anything else, just that the correct quotes are being used:

"insert into table_name(col1,col2,col3,col4,col5,create_date,created_by) values (00,0,'"+variable_1+"','"+system.Environment.UserName+"','New’,'"+"TO_DATE('23-04-49 20:18:07"+"','"+"DD-MM-YY HH24:MI:SS')"+"','"+system.Environment.MachineName+"')"

great
New is a keyword
mention that within ‘New’ like this
@hss

1 Like

yes it is changing sometimes green , sometimes red

@hss and @Palaniyappan - New is indeed a keyword, but it should not be in brackets, that is only for column names/headers. This is a string value, so you fix it by enclosing within ‘single quotes’ which has already been done

yah sorry single quotes
but stil here it is with double quotes
image

@hss

@Dave @Palaniyappan

Sorry for 2 posts confusion… While i ran the corrected query by @Dave it is giving me missing comma error on my original post

Here is the screenshot:

and here is the query

@hss - i have copied + pasted into a text editor and am putting everything onto it’s own line like I’d normally write out a SQL query which i’ve found to be very helpful. What is the expected format of the TO_Date portion? Is that a date field within your oracle db? Everything up to the ‘system.environment.username’ portion is working correctly. There is an extra comma and some single quotes in that area that is causing issues but i can’t recommend a solution as I’m not sure what field type you are trying to insert (i’m guessing date field, but I can’t remember PL/SQL syntax all that well)

@Dave So the Date field is of Type : TIMESTAMP(6) and when i see the field value of the date column… it has values like this 23-04-49 20:18:07

@hss - I think this is should work. I am assuming PL/SQL and used this for the TO_Date syntax: Oracle / PLSQL: TO_DATE Function

"insert into table_name(
col1,
col2,
col3,
col4,
col5,
create_date,
created_by
)
values(
00,0,
'"+variable_1+"',
'"+system.Environment.UserName+"',
'New’,
TO_DATE('23-04-49 20:18:07','DD-MM-YY HH24:MI:SS'),
'"+system.Environment.MachineName+"')"

EDIT: Here it is so it’ll actually work in uipath (removed all newline): "insert into table_name(col1,col2,col3,col4,col5,create_date,created_by)values(00,0,'"+variable_1+"','"+system.Environment.UserName+"','New’,TO_DATE('23-04-49 20:18:07','DD-MM-YY HH24:MI:SS'),'"+system.Environment.MachineName+"')"

@Dave
It is showing me new error now
Execute Non Query: ORA-01756: quoted string not properly terminated

@hss - can you run it in PL/SQL developer or other tool? That will give us better information haha. So you don’t have to re-write it, just write the query to .txt file using the robot, then copy+paste from the text file into PL/SQL and can just click run.

@Dave thank u so much for your quick responses, indeed helped me a LOT

The query worked. I am mentioning the mistakes i was doing while writing them:
2nd statement is the correct working statement. Indicating by arrows and numbers

Full Query is here:
"insert into table_name(col1,col2,col3,col4,col5,create_date,created_by) values(00,0,'"+variable_1+"','"+system.Environment.UserName+ "','New',TO_DATE('23-04-49 20:18:07','DD-MM-YY HH24:MI:SS'),'" +system.Environment.MachineName+"')"

This error : ORA-00933: SQL command not properly ended

was resolved with proper spacing . Pls refer this click hereSpacing provided at 1, 3(as shown in screenshot)

This error : ORA-01756: Quoted String Not Properly Terminated

was resolved by changing the quote style for --New-- as shown by 2 in screenshot.
Pls refer this click here

Thanks again @Dave

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.