dotnet datatools:
Hello All, I am having an issue with a INSERT statement using the DataAdapter wizard. I am editing the INSERT and UPDATE statement that the "wizard" created. For the UPDATE statement the following modified statement works: UPDATE table SET INSTITUTION_ID = :INSTITUTION_ID, GROUP_NAME = :GROUP_NAME, PRIVS = :PRIVS, ACCESS_LEVEL = :ACCESS_LEVEL, DESCRIPTION = (SELECT FIELD_VALUE_DESC FROM table WHERE FIELD_VALUE = :PRIVS) WHERE.......... When I modify the INSERT staement with the following, the select stament within the insert statment does not work. I get an error that says: "Identifier is too long" INSERT INTO table (GROUP_NAME, INSTITUTION_ID, PRIVS, ACCESS_LEVEL, DESCRIPTION) VALUES (:group_name, :institution_id, :privs, :access_level, (SELECT field_value_desc FROM table field_value = :privs)) I have tried different syntax around the select statement but nothing works. Any ideas on the correct syntax around the select statement so the INSERT statement sees it as a signle value? Thanks in advance. --
This is the syntax I normally use when inserting from a select statement. I'm not familiar with the ":" syntax, I'm assuming they're parameter values? Apart from that, I think this should do it... INSERT INTO table(GROUP_NAME, INSTITUTION_ID, PRIVS, ACCESS_LEVEL, DESCRIPTION) (SELECT :group_name, :institution_id, :privs, :access_level, field_value_desc FROM table WERE field_value = :privs) "ksedran" <ksedran@discussions.microsoft.com> skrev i meddelandet news:07C5C81A-EB73-4A48-82E7-6961D7F04E2F@microsoft.com... [quoted text, click to view] > Hello All, > > I am having an issue with a INSERT statement using the DataAdapter wizard. > > I am editing the INSERT and UPDATE statement that the "wizard" created. > > For the UPDATE statement the following modified statement works: > > UPDATE table SET INSTITUTION_ID = :INSTITUTION_ID, GROUP_NAME = > :GROUP_NAME, > PRIVS = :PRIVS, ACCESS_LEVEL = :ACCESS_LEVEL, DESCRIPTION = (SELECT > FIELD_VALUE_DESC FROM table WHERE FIELD_VALUE = :PRIVS) WHERE.......... > > When I modify the INSERT staement with the following, the select stament > within the insert statment does not work. I get an error that says: > "Identifier is too long" > > INSERT INTO table (GROUP_NAME, INSTITUTION_ID, PRIVS, ACCESS_LEVEL, > DESCRIPTION) VALUES (:group_name, :institution_id, :privs, :access_level, > (SELECT field_value_desc FROM table field_value = :privs)) > > I have tried different syntax around the select statement but nothing > works. > > Any ideas on the correct syntax around the select statement so the INSERT > statement sees it as a signle value? > > Thanks in advance. > > -- > Kevin
Magnus, thanks for the help. The syntax does enter a value into the DESCRIPTION column, unfortunately it is the "field_value_desc FROM table WERE field_value = :privs" statement that gets entered, and not the actual value. BTW, the colon is used in front of the other variables because these are values from a datagrid. So :group_name, :institution_id, :privs, :access_level, are all columns in the datagrid. [quoted text, click to view] "Magnus" wrote: > This is the syntax I normally use when inserting from a select statement. > I'm not familiar with the ":" syntax, I'm assuming they're parameter values? > Apart from that, I think this should do it... > > INSERT INTO table(GROUP_NAME, INSTITUTION_ID, PRIVS, ACCESS_LEVEL, > DESCRIPTION) > (SELECT :group_name, :institution_id, :privs, :access_level, > field_value_desc > FROM table > WERE field_value = :privs) > > "ksedran" <ksedran@discussions.microsoft.com> skrev i meddelandet > news:07C5C81A-EB73-4A48-82E7-6961D7F04E2F@microsoft.com... > > Hello All, > > > > I am having an issue with a INSERT statement using the DataAdapter wizard. > > > > I am editing the INSERT and UPDATE statement that the "wizard" created. > > > > For the UPDATE statement the following modified statement works: > > > > UPDATE table SET INSTITUTION_ID = :INSTITUTION_ID, GROUP_NAME = > > :GROUP_NAME, > > PRIVS = :PRIVS, ACCESS_LEVEL = :ACCESS_LEVEL, DESCRIPTION = (SELECT > > FIELD_VALUE_DESC FROM table WHERE FIELD_VALUE = :PRIVS) WHERE.......... > > > > When I modify the INSERT staement with the following, the select stament > > within the insert statment does not work. I get an error that says: > > "Identifier is too long" > > > > INSERT INTO table (GROUP_NAME, INSTITUTION_ID, PRIVS, ACCESS_LEVEL, > > DESCRIPTION) VALUES (:group_name, :institution_id, :privs, :access_level, > > (SELECT field_value_desc FROM table field_value = :privs)) > > > > I have tried different syntax around the select statement but nothing > > works. > > > > Any ideas on the correct syntax around the select statement so the INSERT > > statement sees it as a signle value? > > > > Thanks in advance. > > > > -- > > Kevin > >
Magnus, I found where my error was. I still had the 'VALUES' between the INSERT INTO and SELECT Statement. Remove the VALUES, and it works. Thanks for your help, I greatly appreciate it! [quoted text, click to view] "ksedran" wrote: > Magnus, thanks for the help. The syntax does enter a value into the > DESCRIPTION column, unfortunately it is the "field_value_desc FROM table WERE > field_value = :privs" statement that gets entered, and not the actual value. > > BTW, the colon is used in front of the other variables because these are > values from a datagrid. So :group_name, :institution_id, :privs, > :access_level, are all columns in the datagrid. > > "Magnus" wrote: > > > This is the syntax I normally use when inserting from a select statement. > > I'm not familiar with the ":" syntax, I'm assuming they're parameter values? > > Apart from that, I think this should do it... > > > > INSERT INTO table(GROUP_NAME, INSTITUTION_ID, PRIVS, ACCESS_LEVEL, > > DESCRIPTION) > > (SELECT :group_name, :institution_id, :privs, :access_level, > > field_value_desc > > FROM table > > WERE field_value = :privs) > > > > "ksedran" <ksedran@discussions.microsoft.com> skrev i meddelandet > > news:07C5C81A-EB73-4A48-82E7-6961D7F04E2F@microsoft.com... > > > Hello All, > > > > > > I am having an issue with a INSERT statement using the DataAdapter wizard. > > > > > > I am editing the INSERT and UPDATE statement that the "wizard" created. > > > > > > For the UPDATE statement the following modified statement works: > > > > > > UPDATE table SET INSTITUTION_ID = :INSTITUTION_ID, GROUP_NAME = > > > :GROUP_NAME, > > > PRIVS = :PRIVS, ACCESS_LEVEL = :ACCESS_LEVEL, DESCRIPTION = (SELECT > > > FIELD_VALUE_DESC FROM table WHERE FIELD_VALUE = :PRIVS) WHERE.......... > > > > > > When I modify the INSERT staement with the following, the select stament > > > within the insert statment does not work. I get an error that says: > > > "Identifier is too long" > > > > > > INSERT INTO table (GROUP_NAME, INSTITUTION_ID, PRIVS, ACCESS_LEVEL, > > > DESCRIPTION) VALUES (:group_name, :institution_id, :privs, :access_level, > > > (SELECT field_value_desc FROM table field_value = :privs)) > > > > > > I have tried different syntax around the select statement but nothing > > > works. > > > > > > Any ideas on the correct syntax around the select statement so the INSERT > > > statement sees it as a signle value? > > > > > > Thanks in advance. > > > > > > -- > > > Kevin > > > >
Don't see what you're looking for? Try a search.
|