473,503 Members | 12,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to assign a value to a variable

Hi,

I have the following MS-SQL Server statement that I want to convert to
ORACLE 8.1
SET @pPhone = '%' + @pPhone + '%'

In ORACLE I tried
SELECT '%' || pPhone || '%' into pPhone from dual;

Where pPhone is a parameter that is passed to the procedure.

How could I do it?

Is it a set in ORACLE?

Thanks,
Florian


Jul 19 '05 #1
6 32946
Florian Marinoiu wrote:
Hi,

I have the following MS-SQL Server statement that I want to convert to
ORACLE 8.1
SET @pPhone = '%' + @pPhone + '%'

In ORACLE I tried
SELECT '%' || pPhone || '%' into pPhone from dual;

Where pPhone is a parameter that is passed to the procedure.

How could I do it?

Is it a set in ORACLE?

Thanks,
Florian

It would be helpful to know what you expect as the result since '%' is a
wildcard in Oracle.

But to accomplish what you appear to want ...

pPhone := '%' || pPhone || '%';

And please do not cross-post. One, appropriate, group is enough.

--
Daniel Morgan
http://www.outreach.washington.edu/e...ad/oad_crs.asp
http://www.outreach.washington.edu/e...oa/aoa_crs.asp
da******@x.washington.edu
(replace 'x' with a 'u' to reply)

Jul 19 '05 #2
Hi Daniel,

thanks for your answer. Unfortunately as soon as I put this line of code in
my procedure the package's status becomes invalid.

I tried a simple test
pName := '%' || '%';
and still doesn't work.

I am using the wildcard because later in my proc I have a select and I use a
LIKE.

Thanks,
Florian

Daniel Morgan wrote:
Florian Marinoiu wrote:
Hi,

I have the following MS-SQL Server statement that I want to convert to
ORACLE 8.1
SET @pPhone = '%' + @pPhone + '%'

In ORACLE I tried
SELECT '%' || pPhone || '%' into pPhone from dual;

Where pPhone is a parameter that is passed to the procedure.

How could I do it?

Is it a set in ORACLE?

Thanks,
Florian

It would be helpful to know what you expect as the result since '%' is a
wildcard in Oracle.

But to accomplish what you appear to want ...

pPhone := '%' || pPhone || '%';

And please do not cross-post. One, appropriate, group is enough.

--
Daniel Morgan
http://www.outreach.washington.edu/e...ad/oad_crs.asp
http://www.outreach.washington.edu/e...oa/aoa_crs.asp
da******@x.washington.edu
(replace 'x' with a 'u' to reply)


Jul 19 '05 #3
Here is the code for the packages that I use

CREATE OR REPLACE PACKAGE "CDMVWEB"."TEST_PCKG"
IS
TYPE curTestSelect is ref cursor;

procedure STTESTSELECT (pPhone IN VARCHAR2 default null,
p_rc out curTestSelect);
end
;
And for the Body

CREATE OR REPLACE PACKAGE BODY "CDMVWEB"."TEST_PCKG"
AS

procedure STTESTSELECT (pPhone IN VARCHAR2 default null,
p_rc out curTestSelect)

IS

BEGIN
-- pName := '%' || pName || '%';

OPEN p_rc FOR
SELECT * FROM DUAL;

exception
when others then
raise;
END;

end TEST_PCKG;

As you can see I put the incriminated line in comments. If it stays like
this my package is valid if I uncomment it becomes invalid.

Daniel Morgan wrote:
Florian Marinoiu wrote:
Hi,

I have the following MS-SQL Server statement that I want to convert to
ORACLE 8.1
SET @pPhone = '%' + @pPhone + '%'

In ORACLE I tried
SELECT '%' || pPhone || '%' into pPhone from dual;

Where pPhone is a parameter that is passed to the procedure.

How could I do it?

Is it a set in ORACLE?

Thanks,
Florian

It would be helpful to know what you expect as the result since '%' is a
wildcard in Oracle.

But to accomplish what you appear to want ...

pPhone := '%' || pPhone || '%';

And please do not cross-post. One, appropriate, group is enough.

--
Daniel Morgan
http://www.outreach.washington.edu/e...ad/oad_crs.asp
http://www.outreach.washington.edu/e...oa/aoa_crs.asp
da******@x.washington.edu
(replace 'x' with a 'u' to reply)


Jul 19 '05 #4
Floriane Marinou wrote:

........
procedure STTESTSELECT (pPhone IN VARCHAR2 default null,
p_rc out curTestSelect)

IS

-- here you need to declare your local vars

pName VARCHAR2(100); -- place appropriate length instead of "100"
BEGIN
-- pName := '%' || pName || '%';

OPEN p_rc FOR
SELECT * FROM DUAL;

exception
when others then
raise;
END;

end TEST_PCKG;

As you can see I put the incriminated line in comments. If it stays like
this my package is valid if I uncomment it becomes invalid.


As I can see, you should look at compiler error messages more closely :)
AFAIU in your case it looked like:
PLS-00201: identifier 'PNAME' must be declared

I think this gives enough information to understand what's the problem.
--
WBR,
Andrey Vakhnin
Jul 19 '05 #5

"Florian Marinoiu" <x@x.com> wrote in message
news:3F***************@x.com...
Here is the code for the packages that I use

CREATE OR REPLACE PACKAGE "CDMVWEB"."TEST_PCKG"
IS
TYPE curTestSelect is ref cursor;

procedure STTESTSELECT (pPhone IN VARCHAR2 default null,
p_rc out curTestSelect);
end
;
And for the Body

CREATE OR REPLACE PACKAGE BODY "CDMVWEB"."TEST_PCKG"
AS

procedure STTESTSELECT (pPhone IN VARCHAR2 default null,
p_rc out curTestSelect)

IS

BEGIN
-- pName := '%' || pName || '%';

OPEN p_rc FOR
SELECT * FROM DUAL;

exception
when others then
raise;
END;

end TEST_PCKG;

As you can see I put the incriminated line in comments. If it stays like
this my package is valid if I uncomment it becomes invalid.

Florian,

I can see a couple of problems.

First the variable pName doesn't exist so you can't assign it a value.

If you really meant to use the IN parameter pPhone rather than pName then
you will find that Oracle won't allow you to change the value if an IN
parameter, only an OUT or IN OUT parameter.

Paul Dixon
Jul 19 '05 #6
The problem is you have not declared the variable pName.

Regards,
Rama Krishna.

Florian Marinoiu <x@x.com> wrote in message news:<3F***************@x.com>...
Here is the code for the packages that I use

CREATE OR REPLACE PACKAGE "CDMVWEB"."TEST_PCKG"
IS
TYPE curTestSelect is ref cursor;

procedure STTESTSELECT (pPhone IN VARCHAR2 default null,
p_rc out curTestSelect);
end
;
And for the Body

CREATE OR REPLACE PACKAGE BODY "CDMVWEB"."TEST_PCKG"
AS

procedure STTESTSELECT (pPhone IN VARCHAR2 default null,
p_rc out curTestSelect)

IS

BEGIN
-- pName := '%' || pName || '%';

OPEN p_rc FOR
SELECT * FROM DUAL;

exception
when others then
raise;
END;

end TEST_PCKG;

As you can see I put the incriminated line in comments. If it stays like
this my package is valid if I uncomment it becomes invalid.

Daniel Morgan wrote:
Florian Marinoiu wrote:
Hi,

I have the following MS-SQL Server statement that I want to convert to
ORACLE 8.1
SET @pPhone = '%' + @pPhone + '%'

In ORACLE I tried
SELECT '%' || pPhone || '%' into pPhone from dual;

Where pPhone is a parameter that is passed to the procedure.

How could I do it?

Is it a set in ORACLE?

Thanks,
Florian

It would be helpful to know what you expect as the result since '%' is a
wildcard in Oracle.

But to accomplish what you appear to want ...

pPhone := '%' || pPhone || '%';

And please do not cross-post. One, appropriate, group is enough.

--
Daniel Morgan
http://www.outreach.washington.edu/e...ad/oad_crs.asp
http://www.outreach.washington.edu/e...oa/aoa_crs.asp
da******@x.washington.edu
(replace 'x' with a 'u' to reply)

Jul 19 '05 #7

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

Similar topics

9
8367
by: Mike | last post by:
Is there any way I can use a function to create a variable and assign a value to it? I have a Perl script that returns some LDAP information: sn=Shore givenname=Mike logintime=20041008153445Z...
25
4306
by: Rim | last post by:
Hi, I have been thinking about how to overload the assign operation '='. In many cases, I wanted to provide users of my packages a natural interface to the extended built-in types I created for...
2
8318
by: Matt | last post by:
If I assign VBScript server side variable a to javascript variable x, it is fine. <% Dim a, b a = 10 %> var x = <%= a %>; alert(x); But if I do the other way around, then it has 500 error....
4
8978
by: Terry | last post by:
I have a number of input boxes used to display totals based on selected items for each row in a table. There are more than a few rows that are identical, except for the form field name. I have...
4
12540
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; ...
2
6227
by: Jim McGivney | last post by:
In asp 2.0 I am trying to insert a row using a detailsview control connected to an accessDataSource. I get the error message below. I am having trouble identifing which data field is causing the...
6
2247
by: david | last post by:
I try to use "for" loop to retrieve and assign values in web form. The code is in the following. But it can not be compiled. What I want to do is: txtQ1.Text =...
2
3391
by: Mirovk | last post by:
Hi, I have a session variable wich value arrives from a previous .asp but in my actual page I need to modify it based upon a selected value from a radio button. I will try to figure out for...
6
4078
by: Don Lancaster | last post by:
I need to progrmatically do this inside a loop this.fh03.value = fixFloat (Harms, numPoints) ; with the numbers changing per an index. If I try curHvals = "03" ; // (derived from...
2
3137
by: Birky | last post by:
Assign the output of a select to a variable? I am unable to find a way to assign the results of an SQL statement to a variable. I know how to assign the SQL statement to a variable but again no...
0
7296
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,...
0
7364
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
7017
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
7470
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
5604
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
3186
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
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
751
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.