473,509 Members | 8,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to set variable using dynamic sql

If I have the line following in a stored proc...
set rowCount = (select count(*) from t2);

what is the equivalent way to set rowCount variable using dynamic sql...
...
set sqlStmt = 'select count(*) from t2';
EXECUTE IMMEDIATE sqlStmt;
...

Thanks, Bill
Nov 12 '05 #1
1 9319
Bill Smith wrote:
If I have the line following in a stored proc...
set rowCount = (select count(*) from t2);

what is the equivalent way to set rowCount variable using dynamic sql...
..
set sqlStmt = 'select count(*) from t2';
EXECUTE IMMEDIATE sqlStmt;
..

Thanks, Bill

The next statement can be:

GET DIAGNOSTICS rowCount = ROW_COUNT;

or you can instead do:

DECLARE v_stmt STATEMENT;
DECLARE c1 CURSOR FOR v_stmt;
....
PREPARE v_stmt FROM sqlStmt;
OPEN c1;
FETCH c1 INTO rowCount;
--
Rob Wilson
ro********@ameritech.net.invalid (remove .invalid)
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
463
by: Bill Smith | last post by:
If I have the line following in a stored proc... set rowCount = (select count(*) from t2); what is the equivalent way to set rowCount variable using dynamic sql... ... set sqlStmt = 'select...
6
28582
by: Brian Haynes | last post by:
I've read all the posts in this forum that I can find that look related to this issue and I have only found 1 solution that I consider to be a bit of a hack. What I want to do is assign a value to...
10
2227
by: Blaxer | last post by:
There is probably a really easy way to do this, so please forgive me but I would like to set the value of a variable from a variable, an example would be... function Calculate_Something(ByVal...
7
9807
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
0
1848
by: sarakumarsg | last post by:
Hai, i would like to use dynamic sql for update records in the DB@ db. Means, the value to be updated will be send as concatenated string. Then based on the concatnation value i need to...
3
4635
benchpolo
by: benchpolo | last post by:
I wrote a funtion in VBA OutputTo an excel file using dynamic filename. Table: contact Filename format: contact_10292007.xls Code: Function outfile() Dim stbl As String stbl =...
0
976
by: David | last post by:
Hi all, Developing in VS 2005, VB.NET An application I am working with currently has everything in one page, but will really be suited to being modular, hence the idea of using dynamic user...
3
8564
by: SnehaAgrawal | last post by:
Hi I want to check if a particular table exists or not in my DB.But that I have to check using dynamic sql.Can anyone provide me with the syntax
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.