![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, I am working with BCI from Unidata to connect to a MSSQL database. Everything seems to be fine except, when I insert a row into a table with identity column, I am not able to retrieve the new id. I tried using the Transact SQL function 'Select scope_identity() as lastaID' for instance, but the result set brings back no data. Any help would be greatly appreciated. This insert statement is working, I can see the new data there no problem, just can get the new id back to my Unidata Basic program. Here's what the code says: SQLSTMT = "INSERT INTO contact (salutation, first_name, middle_name, last_name, name_qualifier, prof_suffix, title, contact_function, customer_id) values ('":CON.SALUTATION:"', '":CON.FIRSTNAME:"', '":CON.MIDDLENAME:"', '":CON.LASTNAME:"', '":CON.QUALIFIER:"', '":CON.SUFFIX:"', '":CON.TITLE:"', '":CON.FUNCTION:"',' ":CON.CUSTOMERID:"')" STATUS = SQLExecDirect(statement.env,SQLSTMT) Fn = "SQLExecDirect" ENVTYPE = "Statement" GOSUB CHECK.STATUS SQLSTMT = "SELECT scope_identity() as lastID" STATUS = SQLExecDirect(statement.env,SQLSTMT) Fn = "SQLExecDirect" ENVTYPE = "Statement" GOSUB CHECK.STATUS STATUS = SQLBindCol(statement.env, 1, SQL.B.NUMBER, CON.ID) STATUS = SQLFetch(statement.env) STATUS = SQLFreeStmt(statement.env, SQL.CLOSE) Thanks in advance Baker |
#3
| |||
| |||
|
|
Hi all, I am working with BCI from Unidata to connect to a MSSQL database. Everything seems to be fine except, when I insert a row into a table with identity column, I am not able to retrieve the new id. I tried using the Transact SQL function 'Select scope_identity() as lastaID' for instance, but the result set brings back no data. Any help would be greatly appreciated. This insert statement is working, I can see the new data there no problem, just can get the new id back to my Unidata Basic program. Here's what the code says: SQLSTMT = "INSERT INTO contact (salutation, first_name, middle_name, last_name, name_qualifier, prof_suffix, title, contact_function, customer_id) values ('":CON.SALUTATION:"', '":CON.FIRSTNAME:"', '":CON.MIDDLENAME:"', '":CON.LASTNAME:"', '":CON.QUALIFIER:"', '":CON.SUFFIX:"', '":CON.TITLE:"', '":CON.FUNCTION:"',' ":CON.CUSTOMERID:"')" STATUS = SQLExecDirect(statement.env,SQLSTMT) Fn = "SQLExecDirect" ENVTYPE = "Statement" GOSUB CHECK.STATUS SQLSTMT = "SELECT scope_identity() as lastID" STATUS = SQLExecDirect(statement.env,SQLSTMT) Fn = "SQLExecDirect" ENVTYPE = "Statement" GOSUB CHECK.STATUS STATUS = SQLBindCol(statement.env, 1, SQL.B.NUMBER, CON.ID) STATUS = SQLFetch(statement.env) STATUS = SQLFreeStmt(statement.env, SQL.CLOSE) Thanks in advance Baker |
#4
| |||
| |||
|
|
Hi all, I am working with BCI from Unidata to connect to a MSSQL database. Everything seems to be fine except, when I insert a row into a table with identity column, I am not able to retrieve the new id. I tried using the Transact SQL function 'Select scope_identity() as lastaID' for instance, but the result set brings back no data. Any help would be greatly appreciated. This insert statement is working, I can see the new data there no problem, just can get the new id back to my Unidata Basic program. Here's what the code says: SQLSTMT = "INSERT INTO contact (salutation, first_name, middle_name, last_name, name_qualifier, prof_suffix, title, contact_function, customer_id) values ('":CON.SALUTATION:"', '":CON.FIRSTNAME:"', '":CON.MIDDLENAME:"', '":CON.LASTNAME:"', '":CON.QUALIFIER:"', '":CON.SUFFIX:"', '":CON.TITLE:"', '":CON.FUNCTION:"',' ":CON.CUSTOMERID:"')" STATUS = SQLExecDirect(statement.env,SQLSTMT) Fn = "SQLExecDirect" ENVTYPE = "Statement" GOSUB CHECK.STATUS SQLSTMT = "SELECT scope_identity() as lastID" STATUS = SQLExecDirect(statement.env,SQLSTMT) Fn = "SQLExecDirect" ENVTYPE = "Statement" GOSUB CHECK.STATUS STATUS = SQLBindCol(statement.env, 1, SQL.B.NUMBER, CON.ID) STATUS = SQLFetch(statement.env) STATUS = SQLFreeStmt(statement.env, SQL.CLOSE) |
![]() |
| Thread Tools | |
| Display Modes | |
| |