Discussion:
[nhusers] Hql Insert into Select from
Gökhan Abatay
2018-11-30 12:32:46 UTC
Permalink
Hi I need to pass sequence to hql but it gives me error?

sequenceNextValSql taken from dialect and it's value for oracle =
MY_SCHEMA.SEQUENCE_NAME.nextval

string sequenceNextValSql =
ISession.GetSelectSequenceNextValString(BaseEntityMap.DefaultSequenceName);
var query = ISession.CreateQuery(
$@"INSERT INTO {typeof(EodJobRunLog)}(Guid, EodDate,
EodJobDef, ErrorCode, ProcessCount,
StartDateTime, Stat)
SELECT ({sequenceNextValSql}) as Guid E.EodDate,
E.EodJobDef, E.ErrorCode, E.ProcessCount,
E.StartDateTime, E.Stat from {typeof(EodJobRunLog)} AS E");


Invalid path: 'MY_SCHEMA.SEQUENCE_NAME.nextval' [INSERT INTO


I know if i use sequence generator in my mapping everything works as
expected, but i need to use with this way.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
Oskar Berggren
2018-11-30 17:17:58 UTC
Permalink
But HQL is not SQL. Are you looking for CreateSQLQuery()?

/Oskar
Post by Gökhan Abatay
Hi I need to pass sequence to hql but it gives me error?
sequenceNextValSql taken from dialect and it's value for oracle =
MY_SCHEMA.SEQUENCE_NAME.nextval
string sequenceNextValSql =
ISession.GetSelectSequenceNextValString(BaseEntityMap.DefaultSequenceName);
var query = ISession.CreateQuery(
EodJobDef, ErrorCode, ProcessCount,
StartDateTime, Stat)
SELECT ({sequenceNextValSql}) as Guid E.EodDate,
E.EodJobDef, E.ErrorCode, E.ProcessCount,
E.StartDateTime, E.Stat from {typeof(EodJobRunLog)} AS E");
Invalid path: 'MY_SCHEMA.SEQUENCE_NAME.nextval' [INSERT INTO
I know if i use sequence generator in my mapping everything works as
expected, but i need to use with this way.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
Loading...