Free SQL examples for V5R2

15 pts.
Tags:
AS/400 SQL
AS400 V5R2
V5R2
where can I find Free SQL examples for V5R2

Software/Hardware used:
AS400 V5R2

Answer Wiki

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

Here is a link to the IBM V5R2 Reference manual

http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/db2/rbafzmst.pdf

==
I tried 5 times to put this in as a discussuon task.
Let’s see if it will stay when I put it here.
==
Looks like it could be your format
Here is a sample of RPG code with SQL in it

// ===========================
// openCursor
// ===========================
begsr openCursor;
/end-free

c/exec sql
c+ declare c1 scroll cursor for
c+ select distinct CuNo
c+ from StmtListDb
c/end-exec

c/exec sql
c+ open c1
c/end-exec

/free
endsr;
// ============================================
// readCursor
// ============================================
begsr readCursor;
// sql read next from cursor into variables

/end-free
c/exec sql
c+ fetch next from c1
c+ into :vCuNum
c/end-exec
/free

endsr;
// ==================
// closeCursor
// ==================
begsr closeCursor;
/end-free
c/exec sql
c+ close c1
c/end-exec
/free
endsr;

Discuss This Question: 2  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
  • Bob1652
    I am having trouble getting easy statements to compile here are my errors 54 /free 55 EXEC SQL DECLARE C1 CURSOR FOR ======> aaa *RNF5347 30 a 002100 An assignment operator is expected with the EVAL operation. 56 (SELECT 57 IBMREQD 58 FROM sysibm/sysdummy1) 59 60 eval *inLR = *ON ; 61 62 /end-free * * * * * E N D O F S O U R C E * * * * * 5722WDS V5R2M0 020719 RN IBM ILE RPG PPCO2011/PPFMXXXI NJW A d d i t i o n a l D i a g n o s t i c M e s s a g e s Msg id Sv Number Seq Message text *RNF7030 30 55 002100 The name or indicator EXEC is not defined. *RNF7030 30 55 002100 The name or indicator SQL is not defined.
    15 pointsBadges:
    report
  • CharlieBrowne
    Looks like it could be your format Here is a sample of RPG code with SQL in it // =========================== // openCursor // =========================== begsr openCursor; /end-free c/exec sql c+ declare c1 scroll cursor for c+ select distinct CuNo c+ from StmtListDb c/end-exec c/exec sql c+ open c1 c/end-exec /free endsr; // ============================================ // readCursor // ============================================ begsr readCursor; // sql read next from cursor into variables /end-free c/exec sql c+ fetch next from c1 c+ into :vCuNum c/end-exec /free endsr; // ================== // closeCursor // ================== begsr closeCursor; /end-free c/exec sql c+ close c1 c/end-exec /free endsr;
    41,380 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