Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Calling Stored-Procedure from SQC File

2 posts in General Discussion Last posting was on 2003-10-25 08:37:52.0Z
M. Ravari Posted on 2003-10-24 20:24:07.0Z
From: "M. Ravari" <majid@lablogics.com>
Newsgroups: ianywhere.public.general
Subject: Calling Stored-Procedure from SQC File
Lines: 79
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: adsl-67-127-109-33.dsl.irvnca.pacbell.net
X-Original-NNTP-Posting-Host: adsl-67-127-109-33.dsl.irvnca.pacbell.net
Message-ID: <3f998a67$1@forums-1-dub>
Date: 24 Oct 2003 13:24:07 -0700
X-Trace: forums-1-dub 1067027047 67.127.109.33 (24 Oct 2003 13:24:07 -0700)
X-Original-Trace: 24 Oct 2003 13:24:07 -0700, adsl-67-127-109-33.dsl.irvnca.pacbell.net
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:1906
Article PK: 4152

Hi there,

I'm trying to call a stored procedure from Visual C++ in an sqc file. I'm
using the following code:

int FAR PASCAL InvoiceBreakDown(long invid)
{
q_ivid = invid;
EXEC SQL call sp_InvoiceBreakDown(:q_invid);
}

Once I run this I get a -187 error, where the same instruction works fine if
I run it in dbisqlc.

Is this not a correct way of calling a stored procedure?

Thanks,

M. Ravari


p.s. The sqlpp generated the following:

int FAR PASCAL InvoiceBreakDown(long invid)
{
//HANDLE nConnectionHandle;

//nConnectionHandle = SQLCONNECT('labworks.db')
//? SQLEXEC(nConnectionHandle, 'use pubs')
//? SQLEXEC(nConnectionHandle, 'execute sp_invoicebreakdown')
//BROWSE

q_invid = invid;
/* EXEC SQL call sp_InvoiceBreakDown(:q_invid); */
{
a_sql_statement_number __SQLV_fincsql_182 = 0;

{
dbpp_prepare_describe( (sqlcaptr), SQLNULL,
_sql_ptrtypechk_(__SQL_ProgName,char), &__SQLV_fincsql_182,
__SQLV_fincsql_183, (SQLDA _fd_ *)0, (SQLDA _fd_ *)0, 2, 0 );
#ifdef __SQLCODE
SQLCODE = __SQLCODE;
#endif
#ifdef __SQLSTATE
strncpy(SQLSTATE,__SQLSTATE,6);
#endif
}
{
((SQLDA *)&__SQLV_fincsql_184)->sqlvar[0].sqldata = (void _sqldafar
*)(&(q_invid));
dbpp_execute_into( (sqlcaptr), SQLNULL,
_sql_ptrtypechk_(__SQL_ProgName,char), &__SQLV_fincsql_182, ((SQLDA
*)&__SQLV_fincsql_184), (SQLDA _fd_ *)0 );
#ifdef __SQLCODE
SQLCODE = __SQLCODE;
#endif
#ifdef __SQLSTATE
strncpy(SQLSTATE,__SQLSTATE,6);
#endif
}
}


if (SQLCODE < 0)
return (SQLCODE) ;

return (DBOK) ;

// q_invid = invid;
// EXEC SQL EXEC sp_invoicebreakdown WHERE invoiceid = :q_invid

// if (SQLCODE < 0)
// return (SQLCODE) ;
// return(DBOK);
}


Nick Elson Posted on 2003-10-25 08:37:52.0Z
From: "Nick Elson" <no_spam_nicelson@sybase.com>
Newsgroups: ianywhere.public.general
References: <3f998a67$1@forums-1-dub>
Subject: Re: Calling Stored-Procedure from SQC File
Lines: 101
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: vpn-concord-018.sybase.com
X-Original-NNTP-Posting-Host: vpn-concord-018.sybase.com
Message-ID: <3f9a3660$1@forums-1-dub>
Date: 25 Oct 2003 01:37:52 -0700
X-Trace: forums-1-dub 1067071072 158.159.8.18 (25 Oct 2003 01:37:52 -0700)
X-Original-Trace: 25 Oct 2003 01:37:52 -0700, vpn-concord-018.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:1907
Article PK: 4157

all you need to know about this is that -187 is telling you
that stored procedure is returning a result set.

DBISQL automatically sets up the cursor handling for
that for you [all the details are hidden].

In E/SQL you need to use the

EXEC SQL DECLARE CURSOR . . . FOR statement
and
EXEC SQL OPEN CURSOR . . .

statements and then explicitly fetch that result set.
If the result set is variable you may even need to switch
to Dynamic SQL as well.

"M. Ravari" <majid@lablogics.com> wrote in message
news:3f998a67$1@forums-1-dub...
> Hi there,
>
> I'm trying to call a stored procedure from Visual C++ in an sqc file. I'm
> using the following code:
>
> int FAR PASCAL InvoiceBreakDown(long invid)
> {
> q_ivid = invid;
> EXEC SQL call sp_InvoiceBreakDown(:q_invid);
> }
>
> Once I run this I get a -187 error, where the same instruction works fine
if
> I run it in dbisqlc.
>
> Is this not a correct way of calling a stored procedure?
>
> Thanks,
>
> M. Ravari
>
>
> p.s. The sqlpp generated the following:
>
> int FAR PASCAL InvoiceBreakDown(long invid)
> {
> //HANDLE nConnectionHandle;
>
> //nConnectionHandle = SQLCONNECT('labworks.db')
> //? SQLEXEC(nConnectionHandle, 'use pubs')
> //? SQLEXEC(nConnectionHandle, 'execute sp_invoicebreakdown')
> //BROWSE
>
> q_invid = invid;
> /* EXEC SQL call sp_InvoiceBreakDown(:q_invid); */
> {
> a_sql_statement_number __SQLV_fincsql_182 = 0;
>
> {
> dbpp_prepare_describe( (sqlcaptr), SQLNULL,
> _sql_ptrtypechk_(__SQL_ProgName,char), &__SQLV_fincsql_182,
> __SQLV_fincsql_183, (SQLDA _fd_ *)0, (SQLDA _fd_ *)0, 2, 0 );
> #ifdef __SQLCODE
> SQLCODE = __SQLCODE;
> #endif
> #ifdef __SQLSTATE
> strncpy(SQLSTATE,__SQLSTATE,6);
> #endif
> }
> {
> ((SQLDA *)&__SQLV_fincsql_184)->sqlvar[0].sqldata = (void _sqldafar
> *)(&(q_invid));
> dbpp_execute_into( (sqlcaptr), SQLNULL,
> _sql_ptrtypechk_(__SQL_ProgName,char), &__SQLV_fincsql_182, ((SQLDA
> *)&__SQLV_fincsql_184), (SQLDA _fd_ *)0 );
> #ifdef __SQLCODE
> SQLCODE = __SQLCODE;
> #endif
> #ifdef __SQLSTATE
> strncpy(SQLSTATE,__SQLSTATE,6);
> #endif
> }
> }
>
>
> if (SQLCODE < 0)
> return (SQLCODE) ;
>
> return (DBOK) ;
>
> // q_invid = invid;
> // EXEC SQL EXEC sp_invoicebreakdown WHERE invoiceid = :q_invid
>
> // if (SQLCODE < 0)
> // return (SQLCODE) ;
> // return(DBOK);
> }
>
>
>