473,320 Members | 1,817 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,320 software developers and data experts.

function usage in dynamic SQL

I am using dynamic SQL in my Procedure that has one parameter named
Dep_ID varchar(50).
Inside procedure, I need one dynamic SQL to fulfill the same function
like:
select first_name || ','||last_name from employee where dep_id in
(Dep_id)

How to express || in dynamic sql? Or can I use concat function and how
to use it in dynamic sql ? I got error by using CONCAT(p1,p2).

Thanks a million for any help!

Nov 12 '05 #1
3 1405
li******@yahoo.ca wrote:
I am using dynamic SQL in my Procedure that has one parameter named
Dep_ID varchar(50).
Inside procedure, I need one dynamic SQL to fulfill the same function
like:
select first_name || ','||last_name from employee where dep_id in
(Dep_id)

How to express || in dynamic sql? Or can I use concat function and how
to use it in dynamic sql ? I got error by using CONCAT(p1,p2).

Thanks a million for any help!

I go out on a lib here and supect that you rproblem is really teh ','....
Try this:

-- note the 2 single quotes to escape '
SET stmttxt = 'SELECT first_name || '','' || last_name from employee
where dep_id in (' || Dep_id -- I assume this is a local variable?
|| ')';
PREPARE stmt FROM stmttxt;

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
But, I'd like to put firstname and last name with ',' in one column.

that is:

select first_name || ',' || last_name as full_name from employee where
dep_id in
(Dep_id)
Sorry for not clear.

Nov 12 '05 #3
li******@yahoo.ca wrote:
But, I'd like to put firstname and last name with ',' in one column.

Yes, you want: Names like: 'Rielau, Serge' as a result. Check my
proposal and you should be pleasantly surprised ....

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4

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

Similar topics

12
by: Surya Kiran | last post by:
Hi all, I've written a function template. say template <class T> fn (T var) { ... } Is there any way, from within the function, can we check what type of argument we've passed on to the...
9
by: christopher diggins | last post by:
I would like to survey how widespread the usage of smart pointers in C++ code is today. Any anecdotal experience about the frequency of usage of smart pointer for dynamic allocation in your own...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
35
by: michael.casey | last post by:
The purpose of this post is to obtain the communities opinion of the usefulness, efficiency, and most importantly the correctness of this small piece of code. I thank everyone in advance for your...
5
by: Grant Mills | last post by:
Is there anyway to reduce the amount of memory a VB.net program allocates? Just a simple windows form, with one button and a label, and all the button does is change the text in the label (it's...
2
by: Jack | last post by:
I have a chunk of code that loads a few dozen function pointers into global variables. I'm concerned with unused memory consumption. What if the client only needs to use one or two functions? Then...
6
by: smmk25 | last post by:
Before I state the problem, I just want to let the readers know, I am knew to C++\CLI and interop so please forgive any newbie questions. I have a huge C library which I want to be able to use in...
7
by: WaterWalk | last post by:
Hello. I thought I understood member function pointers, but in fact I don't. Consider the following example: class Base { public: virtual ~Base() {} }; class Derived : public Base {
11
by: Tinkertim | last post by:
Hello, I've written a function similar to strdup(), except that realloc() is used and the # of characters written is returned instead of returning a cast value of memcpy(). I made this to use...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.