473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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 9300
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
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
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
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
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
0
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
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
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
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...
0
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.