i'm trying execute parameterized "upsert" query using nhibernate named parameters i'm getting exception. syntax appears correct still throwing:
nhibernate.exceptions.genericadoexception unhandled user code hresult=-2146232832 message=could not execute native bulk manipulation query: ... innerexception: basemessage=syntax error @ or near "on" code=42601 errorcode=-2147467259 file=scan.l hresult=-2147467259 internalposition=0 line=1053 message=42601: syntax error @ or near "on" messagetext=syntax error @ or near "on" position=536 routine=scanner_yyerror severity=error source=npgsql sqlstate=42601 stacktrace: @ npgsql.npgsqlconnector.doreadmessage(datarowloadingmode datarowloadingmode, boolean isprependedmessage) @ npgsql.npgsqlconnector.readmessagewithprepended(datarowloadingmode datarowloadingmode) @ npgsql.npgsqlconnector.readexpecting[t]() @ npgsql.npgsqldatareader.nextresultinternal() @ npgsql.npgsqldatareader.nextresult() @ npgsql.npgsqlcommand.execute(commandbehavior behavior) @ npgsql.npgsqlcommand.executenonqueryinternal() @ nhibernate.adonet.abstractbatcher.executenonquery(idbcommand cmd) @ nhibernate.engine.query.nativesqlqueryplan.performexecuteupdate(queryparameters queryparameters, isessionimplementor session) innerexception:
- if helps, full exception here (moved gist due long length , repeating content that's below): https://gist.github.com/bherila/7ce76cbb3fb38ce12602d9ca91128b01
to knowledge syntax correct according postgresql documentation here: https://www.postgresql.org/docs/9.5/static/sql-insert.html
the query
insert session (session_expiry, session_last_page, session_fbr_lh_state, session_user_id, session_user_guid, session_user_name, session_user_fname, session_image_url, session_user_balance, session_user_url_profile, session_user_cloud_name, session_last_qty, session_email, session_utm_source, session_utm_campaign, session_utm_medium, session_user_agent, session_guid) values ( :session_expiry, :session_last_page, :session_fbr_lh_state, :session_user_id, :session_user_guid, :session_user_name, :session_user_fname, :session_image_url, :session_user_balance, :session_user_url_profile, :session_user_cloud_name, :session_last_qty, :session_email, :session_utm_source, :session_utm_campaign, :session_utm_medium, :session_user_agent, :session_guid ) on conflict update set session_expiry = :session_expiry, session_last_page = :session_last_page, session_fbr_lh_state = :session_fbr_lh_state, session_user_id = :session_user_id, session_user_guid = :session_user_guid, session_user_name = :session_user_name, session_user_fname = :session_user_fname, session_image_url = :session_image_url, session_user_balance = :session_user_balance, session_user_url_profile = :session_user_url_profile, session_user_cloud_name = :session_user_cloud_name, session_last_qty = :session_last_qty, session_email = :session_email, session_utm_source = :session_utm_source, session_utm_campaign = :session_utm_campaign, session_utm_medium = :session_utm_medium, session_user_agent = :session_user_agent
how i'm populating parameters (in c#)
dbmodel.createsqlquery(session_upsert) .setparameter("session_guid", data.sessionid) .setparameter("session_expiry", data.sessionexpiration) .setparameter("session_last_page", data.sessionlastpage) .setparameter("session_fbr_lh_state", data.sessionfbrlhstate) .setparameter("session_user_id", data.sessionuserid) .setparameter("session_user_guid", data.sessionuserguid) .setparameter("session_user_name", data.sessionusername) .setparameter("session_user_fname", data.sessionuserfname) .setparameter("session_image_url", data.sessionuserimageurl) .setparameter("session_user_balance", data.sessionuserbalance) .setparameter("session_user_url_profile", data.sessionuserurlprofile) .setparameter("session_user_cloud_name", data.sessionuserreferralcloudname) .setparameter("session_last_qty", data.sessionlastqty) .setparameter("session_email", data.sessionemail) .setparameter("session_utm_source", data.sessionutmsource) .setparameter("session_utm_campaign", data.sessionutmcampaign) .setparameter("session_utm_medium", data.sessionutmmedium) .setparameter("session_user_agent", data.sessionuseragent) .executeupdate();
i answered own question. had update postgresql v9.5. doh!
Comments
Post a Comment