i want to append the string which is present in the stored pocedure to SQL query
CREATE OR REPLACE FUNCTION sample(fid varchar,ioffset int)
RETURNS SETOF totaltype AS $$
DECLARE
s totaltype %ROWTYPE;
SQL_Tx_Type VARCHAR(4000);
SQL_User_Count VARCHAR(4000);
BEGIN
tempapp:='a.key==b.key';
for s in
select * from tbl_text1 a,tbl_test2 b where a.id==b.id and (want to append string tempapp here);
loop
return next s;
end loop;
end
$$ LANGUAGE 'plpgsql';
can you help me regarding this..............its urgent
Regards
Shree
9 21848 rski 700
Expert 512MB
i want to append the string which is present in the stored pocedure to SQL query
CREATE OR REPLACE FUNCTION sample(fid varchar,ioffset int)
RETURNS SETOF totaltype AS $$
DECLARE
s totaltype %ROWTYPE;
SQL_Tx_Type VARCHAR(4000);
SQL_User_Count VARCHAR(4000);
BEGIN
tempapp:='a.key==b.key';
for s in
select * from tbl_text1 a,tbl_test2 b where a.id==b.id and (want to append string tempapp here);
loop
return next s;
end loop;
end
$$ LANGUAGE 'plpgsql';
can you help me regarding this..............its urgent
Regards
Shree
Do it with execute
EXECUTE 'select * from tbl_text1 a,tbl_test2 b where a.id==b.id and '||tempapp;
I'm not sure if it works without EXECUTE
Do it with execute
EXECUTE 'select * from tbl_text1 a,tbl_test2 b where a.id==b.id and '||tempapp;
I'm not sure if it works without EXECUTE
i didnt get result...but i have found an alternative way.....i have taken remaining query in a string variable and appended tht variable as u told...now its working...thanks.....
i have got another problem....want to take first parameter in a string variable and append that string in the execute query....its like follow---------
CREATE OR REPLACE FUNCTION sample(fid varchar,ioffset int)
RETURNS SETOF totaltype AS $$
DECLARE
s totaltype %ROWTYPE;
SQL_Tx_Type VARCHAR(4000);
SQL_User_Count VARCHAR(4000);
BEGIN
tempapp:='a.key==$1'; (its showing error here)
squery:='select * from tbl_text1 a,tbl_test2 b where '
for s in
execute squery || tempapp
loop
return next s;
end loop;
end
$$ LANGUAGE 'plpgsql';
$1 value is not taking inside execute statement....can u help me out regarding this problem...its urgent
Regards
Shree
rski 700
Expert 512MB
i didnt get result...but i have found an alternative way.....i have taken remaining query in a string variable and appended tht variable as u told...now its working...thanks.....
i have got another problem....want to take first parameter in a string variable and append that string in the execute query....its like follow---------
CREATE OR REPLACE FUNCTION sample(fid varchar,ioffset int)
RETURNS SETOF totaltype AS $$
DECLARE
s totaltype %ROWTYPE;
SQL_Tx_Type VARCHAR(4000);
SQL_User_Count VARCHAR(4000);
BEGIN
tempapp:='a.key==$1'; (its showing error here)
squery:='select * from tbl_text1 a,tbl_test2 b where '
for s in
execute squery || tempapp
loop
return next s;
end loop;
end
$$ LANGUAGE 'plpgsql';
$1 value is not taking inside execute statement....can u help me out regarding this problem...its urgent
Regards
Shree
maybe like this
tempapp:='a.key=='||$1
doesn't it work ?
If no what is the error message
maybe like this
tempapp:='a.key=='||$1
doesn't it work ?
If no what is the error message
hey,thanks....i have got the result..... :)
got one more problem------------------
i have declared a string variable with some value,i want to check whether that string ends with "and" ....
how to do it in stored procedure----its like this
CREATE OR REPLACE FUNCTION test()
RETURNS varchar AS $$
DECLARE
samp varchar(400)
wr varchar;
index1 int;
begin
wr:='';
samp:=' (select * from tbl_usertable where a.ecpclaim_carrier_id ILIKE
''PAPER'' and '
IF (samp.endsWith(''and'')) then
index1:=samp.lastIndexOf(''and'');
samp:=samp.replace(index,length(samp),'''');
end if;
IF (samp IS NULL) then
samp:=samp || wr;
end if;
return
end
$$ LANGUAGE 'plpgsql';
its showing error in "endsWith" and "lastIndexOf", so what are the functions we have to use in stored procedure of postgre for the functions "endsWith" and "lastIndexOf"???????
help me out plz.........
Regards
Shree
rski 700
Expert 512MB
hey,thanks....i have got the result..... :)
got one more problem------------------
i have declared a string variable with some value,i want to check whether that string ends with "and" ....
how to do it in stored procedure----its like this
CREATE OR REPLACE FUNCTION test()
RETURNS varchar AS $$
DECLARE
samp varchar(400)
wr varchar;
index1 int;
begin
wr:='';
samp:=' (select * from tbl_usertable where a.ecpclaim_carrier_id ILIKE
''PAPER'' and '
IF (samp.endsWith(''and'')) then
index1:=samp.lastIndexOf(''and'');
samp:=samp.replace(index,length(samp),'''');
end if;
IF (samp IS NULL) then
samp:=samp || wr;
end if;
return
end
$$ LANGUAGE 'plpgsql';
its showing error in "endsWith" and "lastIndexOf", so what are the functions we have to use in stored procedure of postgre for the functions "endsWith" and "lastIndexOf"???????
help me out plz.........
Regards
Shree
I think position() function might help, but for more info see here http://www.postgresql.org/docs/8.2/i...ns-string.html
I think position() function might help, but for more info see here http://www.postgresql.org/docs/8.2/i...ns-string.html
ya,got the result..thanks a lot.......
got one more issue.....
how to check case for a string in stored procedure....
i want to use equalsIgnoreCase().....i thinks this string function is not available in postgreSQL....so how can i check case for string here......give me the syntax plz
Regards
Shree
rski 700
Expert 512MB
ya,got the result..thanks a lot.......
got one more issue.....
how to check case for a string in stored procedure....
i want to use equalsIgnoreCase().....i thinks this string function is not available in postgreSQL....so how can i check case for string here......give me the syntax plz
Regards
Shree
I'm not suer if understand whatvyou want, but if you want to compare strings without case senstitive ins SQL queries you can use ILIKE operator, or you can user upper() or lower() functions.
I'm not suer if understand whatvyou want, but if you want to compare strings without case senstitive ins SQL queries you can use ILIKE operator, or you can user upper() or lower() functions.
Acually,i want to check the condition like this.......
if((sReceiverType IS NOT NULL) AND (sReceiverType='paper')) then
-----------some statement here---------
end if;
if input of "sReceiverType" is 'PAPER' then this condition will be false...
so,i want to ingnore case.......
which is like this in java class-------
sReceiverType.equalsIgnoreCase("paper");
so,what string function we have to use to do the same.....???????
thanks and Regards
Shree
rski 700
Expert 512MB
Acually,i want to check the condition like this.......
if((sReceiverType IS NOT NULL) AND (sReceiverType='paper')) then
-----------some statement here---------
end if;
if input of "sReceiverType" is 'PAPER' then this condition will be false...
so,i want to ingnore case.......
which is like this in java class-------
sReceiverType.equalsIgnoreCase("paper");
so,what string function we have to use to do the same.....???????
thanks and Regards
Shree
Maybe like this (it's the simples solution)
if((sReceiverType IS NOT NULL) AND ( lower(sReceiverType)='paper')) then
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mmm, Pie |
last post by:
I never ever thought about this, but recently I made a query in access so I
can make a customer mailing list based on relational information and it was
so easy to make the query and join tables and...
|
by: Satvic |
last post by:
Hi all,
Sorry for HTML, there is a lot of code & comments
I tried to create a stored procedure from 3 queries .. to reduce # of times DB gets access from 1 asp page. The result procedure only...
|
by: Mike N. |
last post by:
Hello:
I am new to T-SQL programing, and relativly new to SQL statements in
general, although I have a good understanding of database theory. I'm a
little confused as to the fundamental...
|
by: WGW |
last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost!
everything I need. Maybe not efficiently, but usefully. However, I have
a problem -- a complex query problem...
I can...
|
by: Anton.Nikiforov |
last post by:
Hello everybody!
Does someone know how to build hierarchical queries to the postgresql?
I have a table with tree in it (id, parent)
and need to find a way from any point of the tree to any...
|
by: Zlatko |
last post by:
A question concerning Access Project with SQL Server:
I use a stored procedure that is calling several other stored procedure
which update or append values in several tables. All of them are...
|
by: rooster575 |
last post by:
Im running a querystring in vb.net and it seems as though SQL server decides
on the order in which to run the 3 queries in the string.. Is this possible?
I would think that SQL server starts with...
|
by: audleman |
last post by:
I have an ASP form on my website where a visitor enters information. On
submit, the form calls a stored procedure stores in a MS SQL 2000
database. The stored procedure works most of the time, but...
|
by: enginious |
last post by:
Hi,
I'm sure I'm asking a very easy question, but I am currently in the process of migrating from MS SQL to PostgreSQL and I am facing a few issues, which I would appreciate your help/advice on :...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |