Multiple SQL For (AS/400)

5 pts.
Tags:
AS/400 and SQL
SQL Server administration
For (AS/400) I need to create a source member with multiple sentences of sql: i.e. update aa.... update bb.... update cc.... , and then run these source member with runsqlstm. Is it possible? which is the character to separate between sentences? Thanks in advance
ASKED: July 24, 2008  7:42 PM
UPDATED: October 18, 2011  10:53 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Semicolon is the character for separating SQL sentences:

Update file1 set field1=value1; Update file2 set field2=value2

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Gilly400
    Hi, This is no problem to do with RUNSQLSTM. Remember to end each statement with the semi-colon (;) and this should work fine. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • PutzGrilla
    Hi Gilbert, I have a file with 10 records like
    fieldone
    x1
    x2
    x3
    x4
    x5
    x6
    y10
    y11
    y12
    y13
    
    
    How can i Execute a RUNSQLSTM for this example:
    
    Update file1 set fieldtwo = 'changed' where fieldone = 'x1'  or
    Update file1 set fieldtwo = 'changed' where fieldone = 'x2'  or
    Update file1 set fieldtwo = 'changed' where fieldone = 'x3'  or
    Update file1 set fieldtwo = 'changed' where fieldone = 'x4'  or
    Update file1 set fieldtwo = 'changed' where fieldone = 'x5'  or
    Update file1 set fieldtwo = 'changed' where fieldone = 'x6' 
    
    Thanks.
    
    760 pointsBadges:
    report
  • TomLiotta
    It's not clear what you are looking for. Do you have two tables? The first table seems to have a column named fieldone, and another table seems to be named file1 with a column named fieldtwo. Or is there only one table that has both columns? If there are two tables and both tables have a column like fieldone, it seems like you want a basic subselect in your WHERE clause. But we'd need to know a little more about what columns are available. Tom
    125,585 pointsBadges:
    report
  • PutzGrilla
    Sorry Friends...
    
    I have only one table called FILE1 and have two fields fieldone and fieldtwo. and I run a CL with a only sentence            RUNSQLSTM  SRCFILE(MYLIB/QCLSRC) SRCMBR(PROGRAM1) + 
                            COMMIT(*NONE)                               
    
    IF the fieldone have x1,x2...x6 I Update the field fieldtwo with "changed".
    
    760 pointsBadges:
    report
  • TomLiotta
    Then you possibly want something like this:
    Update file1 set fieldtwo = ‘changed’ where fieldone in( 'x1', ‘x2′, 'x3', 'x4', 'x5', 'x6' )
    The IN() expression can be a list or it can be a subselect. You might use a subselect if you had the values stored in a second table. Since you only have one table and you have a small, fixed list of values, you can put the list right in the expression. BTW, when you use the {code} button, you can type your entire question, then select just the piece that is code and then click the {code} button. Alternatively, you can click {code} at the beginning of a piece of code and again at the end of the piece of code. The first method puts both beginning and ending tags at the same time. The second method does one tag at a time, but it's easy to forget to click it a second time. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following