Prev: CLI0109E String Data Right Truncation SQLSTATE=22001
Next: Can Not Create Database - DAS Is Not Active
From: Vivek on 11 Jun 2007 09:20 Hi, i get the following error when running an embedded sql application on Suse (powerPC): SQL4903N The length of parameter "runtime_pid" of function "sqlastrt_trusted" is not valid. Iam running against DB2 V9.1 Is this a known issue ?
From: Tonkuma on 11 Jun 2007 17:08 Please shaw us your Procedure and the way to call the procedure. I suspect that the data type mismatch reside in this isuue.
From: Vivek on 12 Jun 2007 01:38 On Jun 12, 2:08 am, Tonkuma <tonk...(a)jp.ibm.com> wrote: > Please shaw us your Procedure and the way to call the procedure. > I suspect that the data type mismatch reside in this isuue. This same code works on other platforms. Also this is part of a bigger application. If i write the exact same code as a small test application it works fine. I cannot find the difference. int db2esqlConnect(const char *databaseEnv, const char *username, const char *password, ERRCB *ep) { EXEC SQL BEGIN DECLARE SECTION; char dbsql[10]; char usersql[20]; char passwdsql[20]; short numTables; EXEC SQL END DECLARE SECTION; int rc; long prev_code = 0; strcpy(dbsql, databaseEnv); memset(&sqlca, 0, sizeof(struct sqlca)); /* connect to database */ if (username && *username && password && *password) { strcpy(usersql, username); strcpy(passwdsql, password); EXEC SQL CONNECT TO :dbsql USER :usersql USING :passwdsql; } else { EXEC SQL CONNECT TO :dbsql; } if (SQLCODE == 0) { strncpy(Sversion_, sqlca.sqlerrp, 8); Sversion_[8] = '\0'; strcpy(dbname, databaseEnv); } else { return FALSE; } }
From: Knut Stolze on 26 Jun 2007 09:22
Vivek wrote: > On Jun 12, 2:08 am, Tonkuma <tonk...(a)jp.ibm.com> wrote: >> Please shaw us your Procedure and the way to call the procedure. >> I suspect that the data type mismatch reside in this isuue. > This same code works on other platforms. Also this is part of a bigger > application. If i write the exact same code as a small test > application it works fine. I cannot find the difference. > > int db2esqlConnect(const char *databaseEnv, > const char *username, > const char *password, > ERRCB *ep) > { > EXEC SQL BEGIN DECLARE SECTION; > char dbsql[10]; > char usersql[20]; > char passwdsql[20]; > short numTables; > EXEC SQL END DECLARE SECTION; > int rc; I recommend that you initialize _all_ variables at declaration. > long prev_code = 0; > > strcpy(dbsql, databaseEnv); You should use "strncpy" here to prevent buffer overflows. > memset(&sqlca, 0, sizeof(struct sqlca)); > /* connect to database */ > > if (username && *username && password && *password) { > strcpy(usersql, username); > strcpy(passwdsql, password); strncpy > EXEC SQL CONNECT TO :dbsql USER :usersql USING :passwdsql; > } > else { > EXEC SQL CONNECT TO :dbsql; > } > > if (SQLCODE == 0) { > strncpy(Sversion_, sqlca.sqlerrp, 8); What's the definition of Sversion? It does not show up above. > Sversion_[8] = '\0'; > strcpy(dbname, databaseEnv); > } > else > { > return FALSE; > } > } Other than the above comments, you haven't shown us the code of the procedure and how you invoke it - just some embedded SQL code that connects to a database. -- Knut Stolze DB2 z/OS Utilities Development IBM Germany |