﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Teradata Forums / Drivers and UDFs / Teradata   / JDBC and calling a macro / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Teradata Forums</description><link>http://www.teradata.com/teradataforum/</link><webMaster>info@teradata.com</webMaster><lastBuildDate>Sat, 06 Sep 2008 22:53:34 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: JDBC and calling a macro</title><link>http://www.teradata.com/teradataforum/Topic8197-11-1.aspx</link><description>Thanks very much. Works great.</description><pubDate>Tue, 01 Apr 2008 11:26:55 GMT</pubDate><dc:creator>Lars Hamann</dc:creator></item><item><title>RE: JDBC and calling a macro</title><link>http://www.teradata.com/teradataforum/Topic8197-11-1.aspx</link><description>Your multistatement macro returns both an update count and a result set. So you need to use the generic "execute" method, e.g.boolean isResultset = stmt.execute();// Returns FALSE, indicating first result is not a ResultSetint updateCount = stmt.getUpdateCount;// Returns the value of the UpdateCount result - optionalisResultSet = stmt.getMoreResults();// Positions to next result and returns TRUE, indicating it is a ResultSetResultSet rs = stmt.getResultSet();// Returns the results// NOTE: There are no more results when both// getMoreResults (or execute) returns FALSE (saying current result is not a ResultSet), and// getUpdateCount returns -1 (saying current result is not an UpdateCount)</description><pubDate>Fri, 28 Mar 2008 13:22:07 GMT</pubDate><dc:creator>Fred Pluebell</dc:creator></item><item><title>RE: JDBC and calling a macro</title><link>http://www.teradata.com/teradataforum/Topic8197-11-1.aspx</link><description>Hi,macros which use select only statements are working fine that way.Unfortunately I'm not successful executing macros that useupdate and select, e.g.:REPLACE MACRO m_get_next_id(in_name VARCHAR(100) NOT NULL)AS(update t_ref_max_id set id = id + 1 where id_name = :in_name;select id_name,         idfrom t_ref_max_idwhere id_name = :in_name;);Executing that macro using:PreparedStatement stmt = con.prepareStatement("EXECUTE m_get_next_id(?);");stmt.setString(1, "process_id");ResultSet rs = stmt.executeQuery();I get:SQL Exception: [NCR] [Teradata JDBC Driver] : executeQuery() cannot be used when there is no result set expected; use executeUpdate() or execute()Using Perl::DBI via ODBC it's working OK.So, is there any way to get that working using JDBC?</description><pubDate>Fri, 28 Mar 2008 11:21:02 GMT</pubDate><dc:creator>Lars Hamann</dc:creator></item><item><title>RE: JDBC and calling a macro</title><link>http://www.teradata.com/teradataforum/Topic8197-11-1.aspx</link><description>thanks a lot - it s working fine!</description><pubDate>Thu, 19 Jul 2007 12:16:32 GMT</pubDate><dc:creator>Rainer Kopp</dc:creator></item><item><title>RE: JDBC and calling a macro</title><link>http://www.teradata.com/teradataforum/Topic8197-11-1.aspx</link><description>Here's a sample code I could get to work ....&lt;br&gt;&lt;br&gt;&lt;br&gt;-- Macro definition&lt;br&gt;&lt;br&gt;REPLACE MACRO SEL_EMP_MAC(EMPID INTEGER)&lt;br&gt;AS&lt;br&gt;(&lt;br&gt;  SELECT EMPNAME FROM EMPLOYEE WHERE EMPID = :EMPID;&lt;br&gt;);&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;// java program ....&lt;br&gt;&lt;br&gt;import java.sql.*;&lt;br&gt;&lt;br&gt;public class MacroTest001&lt;br&gt;{&lt;br&gt;&lt;br&gt;  public static Connection establishConnection(String args[]) throws ClassNotFoundException, SQLException&lt;br&gt;  {&lt;br&gt;    Class.forName("com.ncr.teradata.TeraDriver");&lt;br&gt;&lt;br&gt;    String jdbcUrl  = "jdbc:teradata://" + args[0];&lt;br&gt;    String userId   = args[1];&lt;br&gt;    String password = args[2];&lt;br&gt;&lt;br&gt;    return DriverManager.getConnection(jdbcUrl, userId, password);&lt;br&gt;  }&lt;br&gt;&lt;br&gt;  public static void main(String args[]) throws ClassNotFoundException, SQLException&lt;br&gt;  {&lt;br&gt;    Connection con = establishConnection(args);&lt;br&gt;    PreparedStatement ps = con.prepareStatement("EXECUTE SEL_EMP_MAC(?);");&lt;br&gt;&lt;br&gt;    ps.setInt(1, 100);&lt;br&gt;    ResultSet rs = ps.executeQuery();&lt;br&gt;&lt;br&gt;    while(rs.next())&lt;br&gt;      System.out.println(rs.getString("EMPNAME"));&lt;br&gt;&lt;br&gt;  }&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;</description><pubDate>Wed, 18 Jul 2007 01:21:02 GMT</pubDate><dc:creator>joedsilva</dc:creator></item><item><title>RE: JDBC and calling a macro</title><link>http://www.teradata.com/teradataforum/Topic8197-11-1.aspx</link><description>yes, we have tried PrepareStatement.execute(); using "call" and "execute"  - but with execute/exec the DB complains&lt;br&gt;about wrong syntax...&lt;br&gt;&lt;br&gt;Perhaps calling macros is not supported ?&lt;br&gt;</description><pubDate>Tue, 17 Jul 2007 13:11:02 GMT</pubDate><dc:creator>Rainer Kopp</dc:creator></item><item><title>RE: JDBC and calling a macro</title><link>http://www.teradata.com/teradataforum/Topic8197-11-1.aspx</link><description>I haven't tried, but I think this can be accomplished via&lt;br&gt;&lt;br&gt;[Statement/PreparedStatement].[execute() / executeQuery()] ;</description><pubDate>Tue, 17 Jul 2007 00:01:49 GMT</pubDate><dc:creator>joedsilva</dc:creator></item><item><title>JDBC and calling a macro</title><link>http://www.teradata.com/teradataforum/Topic8197-11-1.aspx</link><description>Hello,&lt;br&gt;&lt;br&gt;It's easy to call a teradata procedure with the teradata JDBC driver.&lt;br&gt;&lt;br&gt;But is it possible to call a macro in JDBC too?&lt;br&gt;&lt;br&gt;I found no documentation of this nice feature...&lt;br&gt;&lt;br&gt;Greetings &lt;br&gt;Rainer Kopp</description><pubDate>Mon, 16 Jul 2007 13:01:36 GMT</pubDate><dc:creator>Rainer Kopp</dc:creator></item></channel></rss>