This project is read-only.

INSERT new record

Jan 30, 2009 at 9:12 AM
Hi,

first of all, I have to say "you have done great job with this project". Everithing is working fine, but I get little stuck with inserting new record.
I didnt use mapping generator at all, because I'd like to understant how does it work, so the following problem is : When I'm trying insert new record
I get error ORA-00904 which is "invalid identifier" during checking  SQL query which was generated by LINQ statement, I've find out bug inside of
converting method.

Here is the generated code.:
DECLARE IDENTITY Number;
BEGIN
INSERT INTO my_tb ( Last_Name, First_Name ) VALUES ( :p0, :p1 );
SELECT EMP_SQ.CURRVAL INTO IDENTITY FROM DUAL;
OPEN :p2 FOR SELECT t0.Employee_Id FROM my_tb t0 WHERE t0.Employee_Id = ( CONVERT ( Int32, IDENTITY) );
END;

As you see the problem is inside of WHERE clause, where is bad data type Int32.
The property Employee_Id is data type int and has this attribute [Column(Storage = "employee_id", DBType="NUMBER NOT NULL ENP_SQ" Id=true, AutoGen=true)].

Could anyone give me some advice with that?
Regards n00by
Feb 9, 2009 at 9:12 PM
Hi,

sorry for my late, I'm very busy,

I think that your problem come from the attribute delcaration,

in fact, you should have something like [ColumnAttribute(Storage="employee_id", DBType="NUMBER IDENTITY ENP_SQ", Id = true, Autogen = true)]

please, let me know if you have solved your problem,

thank you very much
Feb 10, 2009 at 7:15 AM
Hi again,
so, I've done everything as you wrote above, and many other combinations, but the problem is still the same as before.
My opinion is that the parser of C# code to SQL has same issue, because there is sitl Int32 data type from .NET.

I didn't use any explicit declaration of IDENTITY variable, only inside of DBType="" parameter, but there is NUMBER, and the other
queistion is why is used method CONVERT(type, variable) when we have IDENTITY declared as Number why another convertion?

I'd like use your api, because it can make my work easier with .NET/Oracle.

Kind regards
n00by
Feb 10, 2009 at 11:16 AM
Hi,

I will try to find a solution for your problem quickly

and post a new release in next days,

thanks for your patience
Feb 10, 2009 at 12:23 PM
Hi,

Please, could you send me your generated class you use for the mapping ?

I think that the parser has a problem with the column's definition.

Thank you
Feb 10, 2009 at 7:17 PM
Ok, I'll send you my mapping class with other separate classes, that implements all data access.
Please give me your mail.

Cheers
Feb 11, 2009 at 6:26 AM
Hi,

your problem comes from the property declaration,

for the moment, ORACLE sequence are converted to decimal .NET type,

so you must use decimal .NET type for this kind of property,

the support of integer will be released in the next version,

in this manner, the CONVERT function will be removed

Thanks
Feb 11, 2009 at 7:17 AM
Hi,
that's work great now.
I'm very glad to help you with that.

Regards n00by