Focal Point
SQL Object - insert statement

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/7101010682

May 30, 2008, 07:38 PM
ESky
SQL Object - insert statement
Hi All,

I created a SQL Object via Adapter Designer. It's used to insert a record into a table (for instance table1).

I put the following sql statement into statement tab.
INSERT INTO table1 (A,B) VALUES(?ValueA,?ValueB)

I definded two 'User defined properties'
ValueA - the value is string (for instance a)
ValueB - the value is a string (for instance b)

When I ran the sql object. I got "ORA-00917: missing comma" error.

The runtime sql statement is "INSERT INTO table1(A,B) VALUES(a,b)". It's not correct. The "a" and "b" should be put into a pair of single quote.

I tried _CONCAT("\'",a,"\'") and _CONCAT("\'",b,"\'") they dont work.

I am wondering if someone encountered the same problem before.

Thanks,


iWay adapter manager
SAP Adapter
Web Services
SAP BASIS, Java Core
May 31, 2008, 05:17 AM
Majid Jeddi
Hi,

If your table contains more fields than A and B, you may need to add them with null values in the insert statement.

Majid.


WebFocus 7.6.5
AND WebLogic server as web server
sql2005 as database server
June 02, 2008, 01:09 PM
ESky
Maybe I didn't make myself cleary.

The problem is in the statement tab of SQL Object. The sql statment is "insert into table1(a,b) values(?ValueA,?ValueB)"

During runtime, after it gets the values. The sql statement looks like:

INSERT INTO table1 values(A,B).

which is not a valid statement. it should be:

INSERT INTO table1(a,b) values('A','B')

I am wondering if anybody knows how to put the pair of single quotes in.

thanks,
Dennis


iWay adapter manager
SAP Adapter
Web Services
SAP BASIS, Java Core
June 02, 2008, 06:00 PM
<nklamen>
Instead of:



INSERT INTO table1 (A, B) VALUES( ?ValueA, ?ValueB )



Code the statement as:



INSERT INTO table1 (A, B) VALUES(‘?ValueA’, ‘?ValueB’)



…making the single quotes part of the statement prior to parameter substitution. This approach should always work because the type (char vs. numeric.) is a known, fixed attribute of each target column. Obviously the single quotes should be omitted around parameters which do not need to be quoted at execution (those inserted into numeric columns).
June 02, 2008, 08:22 PM
ESky
Thanks. It works.


iWay adapter manager
SAP Adapter
Web Services
SAP BASIS, Java Core
September 20, 2010, 12:20 PM
Ted Michalski
I'm using this syntax:

INSERT INTO table1(a,b) values('A','B')

But, if I have a numeric variable that I want to store in a numeric field and I put quote marks around it I get the following error message:

FOC1414) EXECUTE IMMEDIATE ERROR.(FOC1400) SQLCODE IS 8114 (HEX: 00001FB2) XOPEN: 22018: Microsoft OLE DB Provider for SQL Server: [22018] Error converting data: type varchar to numeric.

If I leaave the quote marks out, I get this error messaage:

: Microsoft OLE DB Provider for SQL Server: [42000] The name "SRS_CRTFC_PC: " is not permitted in this context. Valid expressions are constants, con: stant expressions, and (in some contexts) variables. Column names are no: t permitted.

So, what do I do?


7.7.02
Windows
EXCEL, PDF, CSV, TEXT