|
-
June 3rd, 1999, 08:49 AM
#1
SQL Stored Procedures
All I want to do is hard code two parameters to a stored procedure. I have tried
{call MyProc ('StringParam') , 56}
{call MyProc 'StringParam' , 56}
{call MyProc ('StringParam') , (56)}
{call MyProc 'StringParam' , 56}
{call MyProc 'StringParam' 56}
{call MyProc ('StringParam') (56)}
and nothing works - I get 'syntax error or access violation when opening the record set. Hard coding a single parameter stored procedure works a treat :-
{call MyProc ('StringParam')}
Please help. Could you also mail me back on [email protected] as I am still waiting my login password to this forum. Thanks.
-
June 7th, 1999, 10:29 AM
#2
Re: SQL Stored Procedures
Try to format parameters like you would do with printf function
int i=56;
ExecuteSQL({call MyProc("MyString %d",i});
-
June 7th, 1999, 07:50 PM
#3
Re: SQL Stored Procedures
Hi,
I am not sure about the format of the parameters in your codes, while it is possible to send parameters into a stored procedure using SQL API.
Hope this will help.
SQLRETURN retcode;
TIMESTAMP_STRUCT dsDynamicCurDate;
SQLINTEGER
siIntRet;
SQLINTEGER
cbDynamicCurDate = 0,
cbIntRet = 0;
retcode = SQLPrepare(g_hstmt, (SQLCHAR*)
"{call ? := guanj.PkgMorrowPlan.Plan2Dynamic( ? )}",
SQL_NTS);
if (retcode == SQL_SUCCESS)
{
SQLBindParameter(g_hstmt, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG,
SQL_INTEGER, 0, 0, &siIntRet, 0, &cbIntRet);
SQLBindParameter(g_hstmt, 2, SQL_PARAM_INPUT, SQL_C_TIMESTAMP,
SQL_TIMESTAMP, 0, 0, &dsDynamicCurDate, 0, &cbDynamicCurDate);
COleDateTime dateTest = COleDateTime::GetCurrentTime();
dsDynamicCurDate.year = dateTest.GetYear();
dsDynamicCurDate.month = dateTest.GetMonth();
dsDynamicCurDate.hour = dateTest.GetHour();
dsDynamicCurDate.day = dateTest.GetDay();
dsDynamicCurDate.minute = dateTest.GetMinute();
dsDynamicCurDate.second = 0;
dsDynamicCurDate.fraction = 0;
retcode = SQLExecute(g_hstmt);
if (retcode != SQL_SUCCESS)
AfxMessageBox("Failed");
}
-
June 8th, 1999, 12:32 PM
#4
Re: SQL Stored Procedures
If you are working with SQL Server and MFC CDatabase classes try this:
db.ExecuteSQL("EXEC YourProc 'stringarg', intarg");
with "EXEC..."
you should be able to finish it up with a call identical to the ones you type in iSQL.
Software Engineer @ Interlinq Corp / Servicing Section
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|