The following example logs on using a host variable to communicate the connection name.
EXEC SQL LOGON :logstr AS :CONNAMEV;
Lines generated by C Preprocessor2:
{ static struct { SQLInt16 LogonStrLen; char LogonStr[102]; } Sql_Stmt011; static struct { SQLInt32 RdtCType; SQLInt16 RdtVersn; SQLInt16 RdtDec; char RdtUserid[8]; SQLInt32 RdtEntty; char *RdtCA; char *RdtDAIn; char *RdtDAOut; char *RdtSql; char *RdtRtCon; SQLInt32 RdtAux1; SQLInt32 RdtAux2; char RdtLCS; char RdtComit; char RdtRelse; char RdtExt; char RdtSepBT; char RdtUCStm; char RdtCmpat; char RdtComp; SQLInt16 RdtXTotL; char RdtXFill[2]; struct { SQLInt16 RdtXLen; SQLInt16 RdtXType; SQLInt32 RdtXCode; } RdtX005; struct { SQLInt16 RdtXLen; SQLInt16 RdtXType; SQLInt16 RdtXConL; char RdtXConT[30]; } RdtX007; struct { SQLInt16 RdtXLen; SQLInt16 RdtXType; char RdtLogMech[8]; char *RdtLogData; } RdtX010; } RDTIN011 = {110,10,0,{' '},0,0,0,0,0,0,0,0,'N','B','N','Y','N','N',' ','C', 64,{' '},{8,5,255},{36,7,},{16,10,{' '},0}}; Sql_Stmt011.LogonStrLen = strlen(logstr); memcpy(Sql_Stmt011.LogonStr,logstr,strlen(logstr)); RDTIN011.RdtSql = (char *)(&Sql_Stmt011); RDTIN011.RdtX007.RdtXConL = CONNAMEV.len; memcpy(RDTIN011.RdtX007.RdtXConT,CONNAMEV.arr,CONNAMEV.len); RDTIN011.RdtCA = (char *)(&sqlca); RDTIN011.RdtRtCon = SQL_RDTRTCON; TDARDI(&RDTIN011); SQL_RDTRTCON = RDTIN011.RdtRtCon; }