how to create insert command in native SQL?

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

how to create insert command in native SQL?

#1

Postby t4nu » Thu Dec 17, 2015 11:14 pm

Hi,
I have to use the native SQL to fetch data from table, retrieving the table data is not a problem, the problem is when I want to add new record or update existing record.
I understand that I have to put the INSERT command or UPDATE SQL command, but I confuse what parameter should I use as the parameter in the values part.
Here what I mean:

Code: Select all

INSERT INTO <myTable> &#40;field1, field2, field3&#41; VALUES &#40; --- this part confused me --&#41;;
I have tried using VALUES (:field1, :field2, :field3), but it gave the error message:
....Missing IN or OUT parameter at index:: 1

and when I change the : to && it gave the error:

ORA-00933: SQL command not properly ended

(I have no problem when inserting new record using sqlplus or SQL developer using the same syntax).
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#2

Postby Segi » Thu Dec 17, 2015 11:21 pm

the correct syntax is

INSERT INTO myTable (field1, field2, field3) VALUES (&&field1,&&field2,&&field3);

You also have to create the resource fields below by clicking on the green plus and adding the fields so for example, you'd add field1 and select its type if it is not the default varchar type.
0 x

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

#3

Postby t4nu » Fri Dec 18, 2015 1:05 am

Hi,
Thanks for the respond.

As I said in my previous post, I also have tried that but it gave me an error:

ORA-00933: SQL command not properly ended

Seeing the error I thought it would be the problem with database, but when I tried to copy the command and paste it to the sql developer or sqlplus, it can run without problem.
Segi wrote:the correct syntax is

INSERT INTO myTable (field1, field2, field3) VALUES (&&field1,&&field2,&&field3);

You also have to create the resource fields below by clicking on the green plus and adding the fields so for example, you'd add field1 and select its type if it is not the default varchar type.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#4

Postby Jon » Fri Dec 18, 2015 12:32 pm

Remove the semicolon at the end.
0 x

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

#5

Postby t4nu » Sat Dec 19, 2015 9:50 am

EXCELLENT!!!
Thank you very much, Jon.

Jon wrote:Remove the semicolon at the end.
0 x


Who is online

Users browsing this forum: No registered users and 16 guests