Multiple SQL Statement Support

190 views
Skip to first unread message

Yevgen Shramko

unread,
Jun 24, 2021, 8:27:29 AM6/24/21
to ScalikeJDBC Users Group
Hi, 
I am wondering if such feature supported by ScalikeJDBC.


If I try with   
NamedDB(dbPool.namedDB) localTx { implicit session =>
        SQL(sqlStmt).execute().apply()
   }

With  execute or executeUpdate I usually get error 

Failed preparing the statement (Reason: [Vertica][VJDBC](2446) ERROR: Cannot insert multiple commands into a prepared statement):

Execute statement example: 

SELECT SWAP_PARTITIONS_BETWEEN_TABLES('mtu_enricher.stg_f_flat_affiliate_hour_report_cost_keys', TO_DATE(CAST(:proc_date AS varchar), 'yyyy-mm-dd'), TIMESTAMPADD('HOUR',23,TO_DATE(CAST(:proc_date AS varchar), 'yyyy-mm-dd')), 'mtu_enricher.f_flat_affiliate_hour_report_cost_keys', true); 
TRUNCATE TABLE mtu_enricher.f_flat_affiliate_hour_report_keys; 
SELECT COPY_TABLE('mtu_enricher.f_flat_affiliate_hour_report_base_keys','mtu_enricher.f_flat_affiliate_hour_report_keys');

When I run the same with Native Jdbc statement.execute() it works. 
Is there any solution for that? 
Thank you,

Kazuhiro Sera

unread,
Jun 24, 2021, 8:30:03 AM6/24/21
to Yevgen Shramko, ScalikeJDBC Users Group
Hi Yevgen,

It seems that you have three SQL statements in the string. You can perform them separately (=call execute().apply() three times)

-Kaz

--
You received this message because you are subscribed to the Google Groups "ScalikeJDBC Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalikejdbc-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalikejdbc-users-group/114fa4bf-7b30-48c3-89f3-2a38b56a2001n%40googlegroups.com.

Yevgen Shramko

unread,
Jun 24, 2021, 8:38:05 AM6/24/21
to ScalikeJDBC Users Group

Hi Kazuhiro, 
Technically you are right but we have already functional application which one loading sql files as template, populated with correspondent values an just run as a whole.
 It would be nice to leave this functionality as it is. 

more complex example could be. 

connect to vertica :target_database user :target_user password ':target_password' on ':target_host', :target_port;
export to vertica :target_database.mtu_enricher.stg_f_flat_affiliate_hour_report_cost_keys
as
SELECT *
FROM f_flat_affiliate_hour_report_cost_keys
WHERE date >= to_timestamp(:proc_date, 'YYYY-MM-DD') AND date < to_timestamp(:proc_date,'YYYY-MM-DD') + 1

 Thank you. 
Yevgen 


P.S. Sorry for duplicates. 


Kazuhiro Sera

unread,
Jun 24, 2021, 8:44:47 AM6/24/21
to Yevgen Shramko, ScalikeJDBC Users Group
According to the error message returned by Vertica JDBC driver (the one you've shared), having multiple queries/commands in a single prepared statement is not supported. If so, there is nothing we can do for you on the ScalikeJDBC side.

To narrow your issue down, I would recommend trying to directly use the JDBC driver in your Scala code, as the first step.

Let us know if you find something that ScalikeJDBC can help you with.

-Kaz

Reply all
Reply to author
Forward
0 new messages