Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> 答复: how to confirm the context has been in

答复: how to confirm the context has been in

From: liujd <liujd_at_cti.ac.cn>
Date: Wed, 26 Mar 2003 01:44:00 -0800
Message-ID: <F001.00572EAD.20030326014400@fatcity.com>


Thank you for your answer.
I run the program that I set error in it previousely Then I debug it and find the error code is -2134

Now I find a weird thing.
When I connect the database and then disconnect . After disconnection, The function getGroupInfo() can handle the error well in the first time .when I run function getGroupInfo() once again. It can't handle the error, and hange.
The core sentences is following :

	EXEC SQL WHENEVER SQLERROR DO handleError("error");
 	EXEC SQL CONTEXT USE :ctx[contextId];
 	EXEC SQL WHENEVER NOT FOUND DO handleError("not select row!");
 	
 	EXEC SQL SELECT logId,accessId,description
INTO :newLoginId,:newAccessId,:newDescription
 		FROM groupInfo WHERE groupid=:newGroupId;

Can you tell me why ?
Thanks!          

-----邮件原件-----
发件人: root_at_fatcity.com [mailto:root_at_fatcity.com] 代表 Stephane Faroult 发送时间: 2003年3月26日 16:19
收件人: Multiple recipients of list ORACLE-L 主题: RE: how to confirm the context has been initialized .

>----- ------- Original Message ------- -----
>From: "liujd" <liujd_at_cti.ac.cn>
>To: Multiple recipients of list ORACLE-L
><ORACLE-L_at_fatcity.com>
>Sent: Tue, 25 Mar 2003 22:53:44
>
>i write two function .
>one is login function as login(char * password,int
>contextId).this
>function initialize the context environment .and
>login database.
>two is getGroupInfo(char * groupName,int
>contextId); this function is as
>his name to get one group information.And refer to
>ctx[contextId] in the
>login function initial
>the sql_context variable is declared in the *.h as
>following
>EXEC SQL BEGIN DECLARE SECTION;
> sql_context ctx[20];
>EXEC SQL END DECLARE SECTION;
>Now ,my question is in the function two(
>getGroupInfo() ) ,how to judge
>the ctx[contextId] has been initialized before used
>it?
>
>thanks in advance!
>

static char global_init = 0;

             /* Initialized at compile-time */

login(..)
{
 /* do stuff */
 global_init = 1;
}

getGroupInfo()
{
 if (!global_init)

    {

     fprintf(stderr, "Not logged on, get lost\n");
     exit(1);

    }
 /* Now you're safe */
}

And reset global_init to 0 in the logoff function.

Regards,

Stephane Faroult
Oriole

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Stephane Faroult
  INET: sfaroult_at_oriolecorp.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: liujd
  INET: liujd_at_cti.ac.cn

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Mar 26 2003 - 03:44:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US