2

i am getting this error below when trying to bindparam with exec proc statement. if i replace the exec proc statement with select statement, the command works. am i missing something here ?

sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', '[42000] [FreeTDS][SQL Server]The untyped variable ? is allowed only in in a WHERE clause or the SET clause of an UPDATE statement or the VALUES list of an INSERT statement\n (7332) (SQLPrepare)') 'exec TEST_proc @a=?, @b=?, @c=?, @d=?, @e=?, @f=?, @g=?, @h=?, @cptyAcronym=?, @i=?, @statusString=?' ('ABC', 'CBML', None, 'TI26615414X225', 'DEC', 'EFF', datetime.datetime(2012, 12, 3, 0, 0), datetime.datetime(2012, 12, 3, 0, 0), 'RAA', 'NYC', None)

this is the command i am using

t = text('exec TEST_proc %s' % param_string, bindparams = [a, b, c, d, e, f, g, h, i, j, statusString])

resultProxy = engine.execute(t)

1 Answers1

1

Some of the inner workings of Sybase can explain why this will not work.

For any statement preparation where there is an expected repeated call (that is, the statement includes the '?' placeholder) Sybase will actually turn the entire statement into a stored procedure.

When it creates the "on-the-fly" stored procedure, it uses systables and syscolumns to go look up the required data types for the DECLAREs on each of the positional parameters. When you try to do this against a Stored Procedure, there is no such rapid lookup (the overhead of asking Sybase to parameterize the stored procedure you are calling would defeat the speed advantage [if there is any] of using '?' placeholders).

In any case, you can't call a stored procedure from a temporary stored procedure. Use something else to generate the parameters you want, and do a full prepare/execute every time.