Forum: Building VoltDB Applications

Post: Param order in insert proc

Param order in insert proc
bodie
Jan 20, 2012
I'm trying to set up an sample app to do inserts and selects. The table has 14 columns. Column 1 and 5 are integers and the rest are varchar. My insert proc keeps failing to compile telling me I have a parameter type mismatch. I removed the proc from project.xml and looked at the default insert that got created. It shows the int columns as params 1 and 9! What's going on? Shouldn't I be able to specify the order of the columns in my SQL statement? This is what the insert looks like:

import org.voltdb.*;

@ProcInfo(
partitionInfo = "devices.ID: 2",
singlePartition = true
)

public class Insert extends VoltProcedure
{
public final SQLStmt sql = new SQLStmt("INSERT INTO devices (ID, NAME, DESCRIPTION, DEVICE_TYPE, NUM_DRIVES, BUSINESS_UNIT, CATEGORY, DEVICE_STATE, EXTERNAL_IP_ADDRESS, INTERNAL_IP_ADDRESS, MAC_ADDRESS, SERIAL_NUMBER, SERVICE_TAG_NUMBER, TAG_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
public VoltTable[] run(int ID, String NAME< String DESCRIPTION, String DEVICE_TYPE, int NUM_DRIVES, String BUSINESS_UNIT, String CATEGORY, String DEVICE_STATE, String EXTERNAL_IP_ADDRESS, String INTERNAL_IP_ADDRESS, String MAC_ADDRESS, String SERIAL_NUMBER, String SERVICE_TAG_NUMBER, String TAG_ID) throws VoltAbortException
{
voltQueueSQL(sql, ID< NAME, DESCRIPTION, DEVICE_TYPE, NUM_DRIVES, BUSINESS_UNIT, CATEGORY, DEVICE_STATE, EXTERNAL_IP_ADDRESS, INTERNAL_IP_ADDRESS, MAC_ADDRESS, SERIAL_NUMBER, SERVICE_TAG_NUMBER, TAG_ID);
voltExecuteSQL();
return null;
}
}
and the error looks like this:
ERROR 13:09:03,378 [main] COMPILER: [Insert.class]: Mismatch between partition column and partition parameter for procedure Insert
Partition column is type VoltType.INTEGER and partition parameter is type VoltType.STRING

Just for completeness, here is the ddl:

CREATE TABLE devices
(
ID INTEGER NOT NULL,
name VARCHAR(100),
description VARCHAR(100),
device_type VARCHAR(100),
num_drives INTEGER,
business_unit VARCHAR(100),
category VARCHAR(100),
device_state VARCHAR(100),
external_ip_address VARCHAR(15),
internal_ip_address VARCHAR(15),
mac_address VARCHAR(100),
serial_number VARCHAR(100),
service_tag_number VARCHAR(100),
tag_id VARCHAR(100),
PRIMARY KEY (ID)
)
PartitionInfo doesn't match
ajgent
Jan 20, 2012
Hi,

You can put the columns in whatever order you choose in the SQL. But it is not the SQL that VoltDB is complaining about.

In your @ProcInfo you specify that this is a single-partition procedure and the partitioning value is "devices.ID: 2". This means ID is the partitioning column and the value to use to find the right partition is the third argument to the run method. (The specification of the argument is zero-based, so "2" means the third argument.)

If you change your @ProcInfo to specify column 1 instead of 3, I believe this will eliminate the error. Like so:

@ProcInfo( partitionInfo = "devices.ID: 0",
singlePartition = true )


--Andrew