sql - ibm db2: insert strings into database in anonymous block -
i trying insert string data db2 table anonymous pl/sql block.
what works;
set sqlcompat plsql; begin ... set id_city = 0; set city = chr(39) || 'berlin' || chr(39); set country_id = 83; set revname = chr(39) || 'create-script' || chr(39); set revcreator = chr(39) || 'create-script' || chr(39); set statement = 'insert fk_city (id_city, city, country_id, is_europe, revname, revdate, revfirst, last_visit, revcreator ) values ( ' || id_city || ', ' || city ||', ' || country_id || ', true, ' || revname || ', current date, current date, current date, ' || revcreator || ' )'; execute immediate statement; ... end
my question : there way insert table oneliner? example:
execute immediate "insert fk_city (id_city, city, country_id, is_europe, revname, revdate, revfirst, last_visit, revcreator ) values ( 0, 'berlin', 83, true, 'create-script', current date, current date, current date, 'create-script' )";
the above statement throws error sql0107n ( name long ), seems have string delimiter ( " ) used embrace statement
in second statement execute immediate replace double quote quote @ beginning , @ end, , quotes in statement replace 2 single quotes.
execute immediate 'insert fk_city (id_city, city, country_id, is_europe, revname, revdate, revfirst, last_visit, revcreator ) values ( 0, ''berlin'', 83, ''true'', ''create-script'', current date, current date, current date, ''create-script'' )';
i'm not sure mean in current date, maybe should date time function sysdate.
Comments
Post a Comment