473,667 Members | 2,548 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 9329
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********@amer itech.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 count(*) from t2'; EXECUTE IMMEDIATE sqlStmt; ... Thanks, Bill
6
28599
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 an enum variable using an int. What I am using right now is something like this: public enum MyEnum { value1, value2, value3
10
2246
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 multiplyer as integer, ByVal variable as ___?) variable = 5 * multiplyer end function What I would like this function to do is take the name of the incoming variable and assign a calculated value to it. Any help would be greatly appreciated, TIA!!
7
9825
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
0
1869
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 retrieve the records into cursor..then update the set.. how can i do that.. say for example, i would like to update the salary for all the employees in my company. I have different grade of employee. In my User interface(.net )i can view all the...
3
4655
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 = "Contact" DoCmd.OutputTo acOutputTable, stbl, acFormatXLS, "c:\temp\contact_" & Now() & ".xls"
0
982
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 controls. When the page gets submitted, the submit button is on the page rather than
3
8603
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
8457
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8883
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8788
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8563
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7390
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6203
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4200
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.