Re-setting NLS_LANG from C++/OCI app

Re-setting NLS_LANG from C++/OCI app

Post by Pat Web » Fri, 30 May 1997 04:00:00



Hello, If this is posted to the wrong oracle group, please let me know so
that I may re-post.

I am running against OCI 7.3.

Here are the steps that I am following:

        1) Get my client's locale information
        2) putenv(NLS_LANG=appropriate string);
        3) olog()
        4) oopen()
        5) dutifully do my client's bidding
        6) oclose()
        7) ologof()
        8) wait for a new client to connect to me.
        9) if a new client connects, return to step 1.

Here's what's happening.  The initial pass works perfectly.  But if a
subsequent client is running with different locale information that
mandates a different NLS_LANG setting connects, the NLS_LANG variable
is apparently not being re-read by Oracle.  I make this assumption because
I continue to get the data returned to me in the format that was proper
for the initial setting of NLS_LANG.

My initial assumption that going to the lengths of calling ologof() prior
to the re-setting of NLS_LANG would be sufficient was obviously in error.

One possible solution that was suggested to me was to submit an "ALTER
SESSION" command after the resetting of NLS_LANG.  This either isn't the
answer or I didn't submit the proper ALTER SESSION command.

So, I guess my questions are:

Can this even be done?  or is this an Oracle bug/deficiency?

If the answer is "Yes, this can be done", where in the world in the
oracle documention should I have been able to find this info?

And/or

Does anyone know where in the documentation I can find a complete
listing of ALTER SESSION options and parameters?

Thanks for any help or advice!
--

Information Advantage, Inc.             (612) 820-3864
7401 Metro Blvd, Suite 500
Edina, MN 55439

 
 
 

Re-setting NLS_LANG from C++/OCI app

Post by Maurice Bauha » Sat, 31 May 1997 04:00:00


Pat, check out Oracle7(tm) SQL Language Quick Reference (Oracle Book file
in the documentation CD /ORACLE/DOC/SERVER/72/SVSQL.OBD pp. 34-35) and
Oracle7 ServerSQL Language Reference Manual (Oracle Book file in the
documentation CD /ORACLE/DOC/SERVER/70/SVSLR.OBD)

Maurice Bauhahn (neophyte)



>Does anyone know where in the documentation I can find a complete
>listing of ALTER SESSION options and parameters?

>Thanks for any help or advice!
>--



 
 
 

1. OCI 8 - Simple Question - New to Oracle OCI C++ Programming

Here is my problem:

I have a sequence I need to read from an table on an V8 server.  I need to
do this a lot (say up to 500 times).  I am currently using the ODBC
CRecordset class of MFC which was working, but now every now and then it
pops up and says it can't read a memory location.  Unfortunately, I trace it
to MFC code so I'm stuck.

I started delving into OCI and simply want to get the next sequence number
for starters.  Here is what I have written so far having looked at the OCI
manual and examples.

----------------------------------------------------------------------------
-----------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oci.h>

void checkerr(OCIError *errhp, sword status);

void main(void)
{
 int status;

 static text *username = (text*)"myUser";
 static text *password = (text*)"myPass123";
 static text *dbName   = (text*)"myDB";

 static OCIEnv  *ociEnv;
 static OCIError  *ociError;
 static OCISvcCtx *ociServer;
 static OCIStmt  *ociStatement;
 static OCIDefine *ociDef;

 sword pKey;

 // Initialize the OCI system and set the environment handle
 OCIInitialize(OCI_DEFAULT, NULL, NULL, NULL, NULL);
 OCIEnvInit((OCIEnv**)&ociEnv, OCI_DEFAULT, NULL, NULL);

 // Allocate the ERROR and SERVER handles
 OCIHandleAlloc(ociEnv, (void**)&ociError, OCI_HTYPE_ERROR, NULL, NULL);
 OCIHandleAlloc(ociEnv, (void**)&ociServer, OCI_HTYPE_SVCCTX, NULL, NULL);

 // Allocate the STATEMENT handle
 OCIHandleAlloc(ociEnv, (void**)&ociStatement, OCI_HTYPE_STMT, NULL, NULL);

 // Logon to the server
 status = OCILogon(ociEnv, ociError, (OCISvcCtx**)ociServer, username,
strlen((char*)username), password, strlen((char*)password), dbName,
strlen((char*)dbName));

 // Prepare and execute an SQL statment
 checkerr(ociError, (status = OCIStmtPrepare(ociStatement, ociError,
(unsigned char*)"SELECT BIL.ITRANDTLPKEY.NEXTVAL PKEY FROM DUAL", 46,
OCI_V8_SYNTAX, OCI_DEFAULT)));
 checkerr(ociError, (status = OCIStmtExecute(ociServer, ociStatement,
ociError, 1, 0, NULL, NULL, OCI_DEFAULT)));
----------------------------------------------------------------------------
-------

The OCIStmtExecute command returns a -2 which is OCI_INVALID_HANDLE.
Since all previous functions return 0 (no errors), I assume it is my
ociStatement handle.
What have I missed?  I want to connect, query, return the result (and I
realize I need an OCIDefineByPos(..) call to map the PKEY column I aliased),
and print the number to the screen.

OCI Manual says I can define after the execute and still be ok.  I've tried
defining before and after and always the OCIStmtExecute returns
OCI_INVALID_HANDLE.

Help please?!?!  Are there better places to ask this question?  Otherwise, I
need a nudge.
RDB

P.S. - I briefly perused the mailing list and found nothing of relevence.
Thank you in advance.

2. Pl/SQL Line numbers

3. Problem with Reports when NLS_LANG set

4. NYC Area - INGRES Developers - Full Time Position for Several Developers

5. Setting NLS_LANG on W2000

6. Using PreparedStatement w/ Oracle

7. How to set NLS_LANG of a database?

8. HELP:Setting the NLS_LANG env parameter

9. Setting NLS_LANG env. variable

10. 2 nls_lang settings on 1 client

11. Question setting languaje (NLS_LANG)

12. Change NLS_LANG Character Set (NT Oracle)