Re: SQL and RPG



Okay, I resolved it by removing the ";" (semi-colon) at the end of the
SQL statement. Why would this make a difference?? I'm confused as to
why it would look at that. I thought that I needed a semicolon to
demarcate the end of the sql statement??

If you've followed this thread, the SQL statement is being called
within an RPG program via
C/EXEC SQL
C+ ExECUTE IMMEDIATE :STATEMENT
C/END-EXEC

Just seems weird removing the semi-colon makes it work. Now my SQL
state is 02000 and it is updating the files correctly. WEIRD. Of
course I confess I know little about this whole thing.

Thanks to all of you for your help!! Again, if anyone can explain why
I don't need the semicolon token, I'd like to know.

thanks,
ga

ga <noemail@xxxxxxxxxxxxxx> wrote:

Question,

Okay I figured out the quotes thanks to your help. This is what the
statement now looks like:

Update IMTEMP set ITMI = 'ABLE', ITP# = 'GEORGE' where ITMI = 'MAHLE'
AND ITP# = '28621NSTD';

Problem is, I am still getting a 42601 SQLSTATE code and this is not
updating the file. Do I have to be more specific or something with
the file/member??

Right now all my files have just one member so I am just saying UPDATE
IMTEMP. My files are defined in DDS but I didn't think that made any
difference.

What can I do to figure out why it's not updating the fields in my
file? I have checked to make sure the fields I want to replace are as
shown. The only think I don't have is blanks padded on the right.
For instance, ITMI in this example is 6 characters and ITP# is 18
characters.

I feel like I am really close with this but am too stupid to figure it
out.

Thanks in advance for any suggestions,
ga
"Hauser@xxxxxxxxxxxxxxx" <Hauser@xxxxxxxxxxxxxxx> wrote:

Hi,

If your fields are defined as character you have to put single quotes
around. A single quote in a string must always be represented by two
consequent single quotes.

For Example:
Statement = 'Update MyTable Set ' + NameField1 + ' = ''' + NewValue
+ '''';

Birgitta


ga
nospam@xxxxxxxxxxxxxxxx

ga
nospam@xxxxxxxxxxxxxxxx
.



Relevant Pages

  • Re: Escape html tags and other dangerous input
    ... The & affects the querystring. ... Single quotes can end the SQL statement allowing for a SQL ... >> injection, but that doesn't help with the ampersand, and the search page ...
    (microsoft.public.dotnet.security)
  • Re: Handling single quotes " " in data
    ... There's no reason not to store the single quotes. ... Presumably your SQL statement is something like ... (remove the extra spaces in the parameters in the Replace statement before ... > I have been storing file locations in a table in access. ...
    (microsoft.public.access.modulesdaovba)
  • executing an sql statement in perl
    ... and thetime> sysdate - 90 ... however i don't think it likes the 2 sets of single quotes. ... The below sql statement works fine directly in my sql program ...
    (comp.lang.perl.misc)
  • RE: Newline inserted?
    ... I'm assuming that those characters are part of the text. ... This way the SQL statement ends like: ... The interpreter doesn't know which ') to stop at. ... > The problem, as a couple people have already pointed out, is the semicolon. ...
    (perl.dbi.users)
  • Re: SQL string problem
    ... clean up your parameters before sending them to SQL. ... > You must "escape" any single quotes when sending SQL statements ... > Just pass your SQL statement through this function when opening your ... >> Here is the full SQL statement that is assigned to the strSQL ...
    (microsoft.public.excel.programming)