Subject "Unsupported Column Type"???
Author jmartine3
I'm attempting to create a stored procedure. I've already tested the
SP with DSQL (using IB_SQL, formatted with different whitespace), and
it works fine.

However, when I try to create it in my code (to add it to the
database), I get the following exception:

Unsupported Column Type: 0

Here is my code (Note: ScratchQuery2 is a TIBOQuery):

ScratchQuery2->Close();
ScratchQuery2->SQL->Clear();
ScratchQuery2->SQL->Add("create procedure PREDICT_COST_1 (BARCODE
VarChar(25))");
ScratchQuery2->SQL->Add("returns (THE_COST Double Precision) as ");
ScratchQuery2->SQL->Add("DECLARE VARIABLE TEMP_COST Double Precision;");
ScratchQuery2->SQL->Add("BEGIN");
ScratchQuery2->SQL->Add("select first 1 itemcost from orderitems A
inner join orders B on A.orderid = B.orderid");
ScratchQuery2->SQL->Add("where A.itembarcode = :BARCODE and
A.itemqtyordered > A.itemqtyreceived");
ScratchQuery2->SQL->Add("and A.itemcost > 0 order by B.orderdate into
:TEMP_COST;");
ScratchQuery2->SQL->Add("if (TEMP_COST is null) then");
ScratchQuery2->SQL->Add("BEGIN");
ScratchQuery2->SQL->Add("select first 1 A.vpcost from vendorproducts A
inner join products B");
ScratchQuery2->SQL->Add("on A.VPUPC = B.PRODBARCODE and A.VPVENDOR =
B.PRODSOURCE");
ScratchQuery2->SQL->Add("where B.prodbarcode = :BARCODE and A.vpcost >
0 into :TEMP_COST;");
ScratchQuery2->SQL->Add("if (TEMP_COST is null) then");
ScratchQuery2->SQL->Add("BEGIN");
ScratchQuery2->SQL->Add("select first 1 vpcost from vendorproducts");
ScratchQuery2->SQL->Add("where vpupc = :BARCODE and vpcost > 0 into
:TEMP_COST;");
ScratchQuery2->SQL->Add("END");
ScratchQuery2->SQL->Add("END");
ScratchQuery2->SQL->Add("THE_COST = TEMP_COST;");
ScratchQuery2->SQL->Add("END");
ScratchQuery2->ExecSQL();

The exception is occurring at the call to ExecSQL. I use this same
code to do other metadata changes. Is there something different about
stored procedures?

What am I doing wrong???

Is the problem with my C++ code, or with the SP? As I said, I've
already tested this SP. Are SP's picky about whitespace and formatting?

-Joe