Can you show an example of what you exactly mean?
In static SQL you have to define a hostvariable in the D-Specs. Then you can populate it with whatever and then include the host variable in your cursor definition or SELECT .... into Statement.
With dynamic SQL you create the whole string (including) the value in the host variable, prepare the string and then execute it or delclare a cursor with the prepared SELECT statement, open the cursor loop through the cursor and delete it again. In the FETCH statement you may receive the values in Host variables (definded before in the D-specs).
You could also use parameter markers instead of the host variables in the string, but then you have to assosicate the parameter markers with host variables in either the EXECUTE or OPEN Statement depending on whether you work with a cursor or not!
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
Modernization – Education – Consulting on IBM i
IBM Champion since 2020
"Shoot for the moon, even if you miss, you'll land among the stars." (Les Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them and keeping them!"
"Train people well enough so they can leave, treat them well enough so they don't want to. " (Richard Branson)
"Learning is experience … everything else is only information!" (Albert Einstein)
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Dave
Sent: Monday, 9 October 2023 15:26
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Embedded SQL host variables
OK I’m on 7.3 now and I still don’t know how to define a host variable without hard coding it.
Any advice ?
Thanks
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.
As an Amazon Associate we earn from qualifying purchases.