How to write a procedure with the table name as an argument
I'm very new to Oracle, usually developing in SQL server.
I would like to write a procedure that accepts a table name and then does a
SELECT * FROM [table name] order by CollectionDate.
In SQL I would build up a varchar variable and then execute it.
Thanks
I often wonder why so many people new to Oracle want to do this as a first step, when most people who know what they are doing try and avoid it.
SQL> create or replace function f (p_tab varchar2)
2 return sys_refcursor as
3 c sys_refcursor;
4 begin
5 open c for
6 'select * from ' || p_tab || ' order by hiredate';
7 return c;
8 end;
9 /
Function created.
SQL> var c refcursor
SQL> exec :c := f('emp')
PL/SQL procedure successfully completed.
SQL> print c
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 12/17/1980 800 20
7499 ALLEN SALESMAN 7698 02/20/1981 1600 300 30
7521 WARD SALESMAN 7698 02/22/1981 1250 500 30
7566 JONES MANAGER 7839 04/02/1981 2975 20
7698 BLAKE MANAGER 7839 05/01/1981 2850 30
7782 CLARK MANAGER 7839 06/09/1981 2450 10
7844 TURNER SALESMAN 7698 09/08/1981 1500 0 30
7654 MARTIN SALESMAN 7698 09/28/1981 1250 1400 30
7839 KING PRESIDENT 11/17/1981 5000 10
7900 JAMES CLERK 7698 12/03/1981 950 30
7902 FORD ANALYST 7566 12/03/1981 3000 20
7934 MILLER CLERK 7782 01/23/1982 1300 10
7788 SCOTT ANALYST 7566 12/09/1982 3000 20
7876 ADAMS CLERK 7788 01/12/1983 1100 20
14 rows selected.
SQL>Note if you pass in a value to be used in the where clause like deptno, you should not use this technique, but use bind variables intead like this -
Wrote file afiedt.sql
1 create or replace function f (p_tab varchar2, p_deptno number)
2 return sys_refcursor as
3 c sys_refcursor;
4 begin
5 open c for
6 'select * from ' || p_tab
7 || ' where deptno = :p_deptno order by hiredate'
8 using p_deptno;
9 return c;
10* end;
SQL> /
Function created.
SQL> exec :c := f('emp', 10)
PL/SQL procedure successfully completed.
SQL> print c
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 CLARK MANAGER 7839 06/09/1981 2450 10
7839 KING PRESIDENT 11/17/1981 5000 10
7934 MILLER CLERK 7782 01/23/1982 1300 10
SQL>
Similar Messages
-
PL/SQL Procedures with the same name
Hi,
I have some PL/SQL procedures with the same name but different arguments.
If I try to catalog the second or third ALBPM always catalogs the first and I don't want to use this. ALBPM only catalogs the first one.
ALBPM Studio Logs:
Introspecci?n en curso...
Agregando procedimiento 'ADM_SGI.UGDIASINOI'
Agregando procedimiento 'ADM_SGI.UGDIASINOI'
Agregando procedimiento 'ADM_SGI.UGDIASINOI'
[Advertencia] No se puede agregar procedimiento 'UGDIASINOI'. Motivo: Duplicar nombre del componente (M?dulo DatabaseRoot.ADM_SGI - Componente UGDIASINOI)..
[Advertencia] No se puede agregar procedimiento 'UGDIASINOI'. Motivo: Duplicar nombre del componente (M?dulo DatabaseRoot.ADM_SGI - Componente UGDIASINOI)..
Analizando componentes
Any solution or idea??
Thanks!I need to retrive data from PL/SQL stored procedures. I am using the DynamicSQL component (2nd workaround) to retrive data from PL/SQL stored procedures. <br><br>
I am having some problems.<br><br>
This is the code I am running in Fuego Studio 5.5 SP 11 Build #71108:<br><br>
dynamicSQL as Fuego.Sql.DynamicSQL<br>
iterator as Iterator(Any[Any])<br>
sentence as String<br>
implname as String<br><br>
dynamicSQL = Fuego.Sql.DynamicSQL()<br>
implname = "conexionORBPAU"<br>
sentence = "var result REFCURSOR; " + <br>
"exec :result_cursor := pkg_audbpm_bpaasig_indicador.prgetsingle(9999);";<br>
iterator = executeQuery(DynamicSQL, sentence, implname, inParameters : []);<br><br>
And, this is the error:<br><br>
java.sql.SQLException: Falta el parametro IN o OUT en el indice:: 1 <br>
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)<br> at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)<br>
oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)<br>
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)<br>
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)<br>
at fuego.jdbc.FaultTolerantPreparedStatement.executeQuery(FaultTolerantPreparedStatement.java:579)<br>
at fuegoblock.sql.DynamicSQL.executeQuery(DynamicSQL.java:340)<br>
...<br><br>
This is the code of the PL/SQL in the Oracle DB:<br><br>
CREATE OR REPLACE PACKAGE PKG_AUDBPM_BPAASIG_INDICADOR IS<br>
TYPE cursor_type IS REF CURSOR;<br>
FUNCTION prGetSingle<br>
(<br>
p_ID_ASIG_INDICADOR IN NUMBER<br>
)<br>
RETURN cursor_type;<br><br>
END PKG_AUDBPM_BPAASIG_INDICADOR;<br><br>
is my code OK? Any ideas?<br><br>
Thanks in advance.<br> -
How can I merge folder with the same name so that the content does not replace the other
How can I merge folder with the same name so that the content does not replace the other?
>
That's only a good idea if the semantics of sayHello
as defined in MyInterface suggest that a
RemoteException could occur. If not, then you're
designing the interface to suit the way the
implementing classes will be written, which smells.
:-)But in practice you can't make a call which can be handled either remotely or locally without, at some point, dealing with the RemoteException.
Therefore either RemoteException must be part of the interface or (an this is probably more satisfactory) you don't use the remote interface directly, but MyInterface is implemented by a wrapper class which deals with the exception. -
How to create reports servers with the same name in two nodes in Reports
Greetings
We are migrating Oracle Application Server 10g (9.0.4) to a better hardware infrastructure with high availability. We want to provide 2 new Oracle Application Server 10g (9.0.4) in High availability and we want to avoid modify the existing forms and reports code, but the code is looking for a specific reports server name when calling reports, but I couldn't create the same reports server name in the both oas machines, I could create the reports server in only one node. I want to create a reports server with the same name in both nodes but it is not possible. I know that there is a procedure to do that in 10.1,2 (Note 437228.1, How to Create Two Reports Servers With the Same Name in the Same Subnet) but I couldn't find the equivalent procedure in 9.0.4.
Anybody kwows how to create a reports server with the same name in two nodes using 10g (9.0.4)
Thanks
Ramiro Ortiz.Hello.
I applied the patch 4092150 on my oas 9.0.4.2 and I modified my rwnetwork.conf file changing the port to 14022 by following the note "How to Create Two Reports Servers With the Same Name in the Same Subnet? [ID 437228.1]" but I am facing the same error rep-56040 "server already exists in the network".
When I run osfind command I get the following information (My reports server is senarep and I want to create it on SNMMBOGOAS10):
osfind: Found 2 agents at port 14000
HOST: SNMVBOGOAS10.sena.red
HOST: SNMVBOGOAS09.sena.red
osfind: There are no OADs running on in your domain.
osfind: There are no Object Implementations registered with OADs.
osfind: Following are the list of Implementations started manually.
HOST: SNMVBOGOAS10.sena.red
REPOSITORY ID: IDL:oracle/reports/server/EngineComm:1.0
OBJECT NAME: senarep2
REPOSITORY ID: IDL:oracle/reports/server/ServerClass:1.0
OBJECT NAME: senarep2
HOST: SNMVBOGOAS09.sena.red
REPOSITORY ID: IDL:oracle/reports/server/EngineComm:1.0
OBJECT NAME: senarep
REPOSITORY ID: IDL:oracle/reports/server/ServerClass:1.0
OBJECT NAME: senarep
Any Ideas? -
Under Firefox Options I clicked Saving Files under Downloads but the file name appears twice and an extra folder with the same name is created within the folder i.e.:
G:\Akbar's Songs\HAMARA FORUMS DOWNLOADS\HAMARA FORUMS DOWNLOADS
As you can see the folder is repeated, how can I correct this?
Also the music files I download from a site downloads as WinRar file and I need to open it. Is there an option where the files open automatically in the folder I have selected?
Many thanks for your help.The "beta" version is for testing and may be more prone to problems, so I suggest trying the regular version (9.20) even though it hasn't been updated since 2010.
-
How do you force instances with the same name on the same layer to update?
Maybe someone can tell me why flash doesn’t redraw
components’ x,y positions if they have the same instance name
and are on adjacent frames? (movieclips work fine, just not
components) If I have a button on frame 1 and a button on frame 2
both with the same instance name but different locations on the
stage, frame 2’s button doesn’t show up in the position
I placed it, it stays at the position of frame 1 but still has the
properties of frame 2’s button. The label changes and
everything. If I stick a button on a frame in between and give it a
different instance name there is no problem. I thought it might be
the style manager bug
http://www.gskinner.com/blog/archives/2007/12/cs3_component_b.html
but it didn’t seem to affect. This happens for textareas too
and probably all components although I haven’t tried them.
I’ve tried using drawNow() and validateNow() with no luck
either
http://www.adobe.com/devnet/flash/articles/creating_as3_components_pt3_05.html
Thank you!
// put this on frame 1 along with a button on the stage with
instance name: b
function doit(event) {
if (currentFrame == 1)
gotoAndStop(2);
else
gotoAndStop(1);
b.addEventListener(MouseEvent.CLICK, doit);
stop();
// put another button on frame 2 along with this code and
also make it’s instance name: b but move it so it’s not
in the same x,y coordinates as the button on frame 1
stop();
Something possibly related. I have a movieclip on a layer,
one instance with name “a” on frame 1 and one instance
with name “a” on frame 2 and it has event listeners
inside it that update something on the movieclip. Unless I put the
movieclips on separate layers the event listeners won’t reset
each frame. (example: a button with a tooltip onmouseover that you
want to change the text of from frame 1 to frame 2) You’d
think if they were on separate keyframes at least but no, they need
to be on separate layers too.
I want the movieclip to update each frame. Any ideas?instances (whether components or not) with the same name may
or may not be the same instance. it depends upon how they were
created.
for example, if you create an instance on frame 1 of your
main timeline, give it an instance name and then create a keyframe
on frame 2, the two instances will be the same.
but if you create an instance on frame 1 of your main
timeline, give it an instance name and then create a blank keyframe
on frame2 and create another, what you think is a duplicate,
instance and give it the same name, it will be a different
instance. -
How to put two files with the same name into the same folder?
How can I put two files with the same name and the same extention into the same directory?
Is this even possible?
Thanks in advance.Are you sure? I would be very surprised if that was the case.
How does the computer/filing system differentiate the files, if not by their names?
How do you tell the computer which one you want? (On the command line.) -
How do I list all of the table names in my excel database
I am writing code for an electronic sales board display in my
office. unfortunatly the datasource that is available to me is an
excel file that is updated by the sales manager every day. each
sales persons information is listed in a different tab and the tabs
name is the same as the corrosponding sales person. unfortunatly we
hire and fire many sales people every month so I need to loop
through a list of the tab names outputing the results as the table
name for my detail query for each sales rep.
anyone have this query information?Yet another creative use of Excel as something which it's
not, i.e. a database.
COM it is if your access must be real-time. -
How to open a file with the same name?
Hi, now I practicing making web pages where I put sample codes in one directory and I copy them to edit.
The probrem is, I couldn't open one file while I'm opening another file with the same name.
Is it possible to open a file with the same name in Dreamweaver?That could be a very error prone practice.
May I suggest you take advantage of DW "Snippets" feature instead.
Simply save any blocks of code you will reuse regularly as snippets,
and give each one a descriptive name you like.
Then you can simply place your cursor in code view where you wish the code,
and click insert on the selected item from the snippet panel. -
How do I call methods with the same name from different classes
I have a user class which needs to make calls to methods with the same name but to ojects of a different type.
My User class will create an object of type MyDAO or of type RemoteDAO.
The RemoteDAO class is simply a wrapper class around a MyDAO object type to allow a MyDAO object to be accessed remotely. Note the interface MyInterface which MyDAO must implement cannot throw RemoteExceptions.
Problem is I have ended up with 2 identical User classes which only differ in the type of object they make calls to, method names and functionality are identical.
Is there any way I can get around this problem?
Thanks ... J
My classes are defined as followes
interface MyInterface{
//Does not and CANNOT declare to throw any exceptions
public String sayHello();
class MyDAO implements MyInterface{
public String sayHello(){
return ("Hello from DAO");
interface RemoteDAO extends java.rmi.Remote{
public String sayHello() throws java.rmi.RemoteException;
class RemoteDAOImpl extends UnicastRemoteObject implements RemoteDAO{
MyDAO dao = new MyDAO();
public String sayHello() throws java.rmi.RemoteException{
return dao.sayHello();
class User{
//MyDAO dao = new MyDAO();
//OR
RemoteDAO dao = new RemoteDAO();
public void callDAO(){
try{
System.out.println( dao.sayHello() );
catch( Exception e ){
}>
That's only a good idea if the semantics of sayHello
as defined in MyInterface suggest that a
RemoteException could occur. If not, then you're
designing the interface to suit the way the
implementing classes will be written, which smells.
:-)But in practice you can't make a call which can be handled either remotely or locally without, at some point, dealing with the RemoteException.
Therefore either RemoteException must be part of the interface or (an this is probably more satisfactory) you don't use the remote interface directly, but MyInterface is implemented by a wrapper class which deals with the exception. -
How to print an email with the full name of the attachment ?
In Mail, when using "View as an Icon", the name of the attachment - if too long - does not appear in full. Any tip on how to have the full name appears (for archiving purpose) ? Thank you
Srinivas, Thanks for your quick reply.
This is smartform, and sending the output as pdf, except the the first page on which I have the text to be printed on the email body. In this email body text I have to display an email.
when user clicks on the email should open an outlook with the email id in the TO. Hope this helps.
Thank you,
Surya -
How to write test procedures of the following code, need someones help
ITS VERY URGENT.....PLEASE SEND ME THE REPLY ON MY EMAIL ID [email protected]
// Account.java - Data class for account files
// MODULE INDEX
// NAME CONTENTS
// Account Constructor
// Account Constructor
// getAccountNo Get account identifier
// getAccountType Get account type
// getCustNo Get customer identifier
// getBalance Get balance
// getCurCode Get currency code
// setAccountNo Set account identifier
// setAccountType Set account type
// setCustNo Set customer identifier
// setBalance Set balance
// setCurCode Set currency code
// MAINTENANCE HISTORY
// DATE PROGRAMMER AND DETAILS
// 6-5-08 TLT Original
// IMPORTATIONS
import java.util.*;
import java.lang.*;
// CLASS DECLARATIONS
public class Account
// INSTANCE DATA
private String accountNo; //Account identifier
private String accountType; //Account type
private String custNo; //Customer identifier
private double balance; //Balance
private String curCode; //Currency code
// CLASS CONSTRUCTOR
Account (
String accountNo) //Account idenfier
this.accountNo = accountNo;
Account (
String accountNo, //Account identifier
String accountType, //Account type
String custNo, //Customer identifier
double balance, //Balance
String curCode) //Currency code
this.accountNo = accountNo;
this.accountType = accountType;
this.custNo = custNo;
this.balance = balance;
this.curCode = curCode;
// Get account identifier
String getAccountNo () {
return accountNo;
// Get account type
String getAccountType () {
return accountType;
// Get customer identifier
String getCustNo () {
return custNo;
// Get balance
double getBalance () {
return balance;
// Get currency code
String getCurCode () {
return curCode;
// Set account identifier
void setAccountNo (
String accountNo)
this.accountNo = accountNo;
// Set account type
void setAccountType (
String accountType)
this.accountType = accountType;
// Set customer identifier
void setCustNo (String custNo) {
this.custNo = custNo;
// Set balance
void setBalance (double balance) {
this.balance = balance;
// Set currency code
void setCurCode (String curCode) {
this.curCode = curCode;
}123shweta wrote:
ITS VERY URGENT.....W00t? Well if its soo urgent then perhaps you should learn from this and do some planning ahead in the future so you dont find ur self in these urgent needs.
PLEASE SEND ME THE REPLY ON MY EMAIL ID [email protected]
Wat tha.., do you expect someone to just magically solve your problem for ya just like that? with an half asked question even.
Last but not least.. Why would you even need an test for an getters and setter class? -
How to find an EXIT with the Include name ?
Hi everybody
If i have an Include name (like ZXMLUU16) , how can i find the FM Exit or the program where this include is used ?
(NOTE: If i use SE38 and 'Where used' option , this
only tell me 'Include ZXMLUU16 not found in
selected search area')
Thanks
FrankI don't think there is a way to find that out, particularly if the include is not yet created. Typical with function module user exits is that, even though you see the line INCLUDE ZXMLUU16 statement in the function module code, the include itself is not created yet. Only when you double click, you will be creating it and then your 'where-used' should work.
You just have to go by a hunch based on the name itself. Unn is a typical naming convension used for function module includes. So, I will take a wild guess that this include is in a function module that is in the function group XMLU. So if you look at this program SAPLXMLU and do a 'Find' 'In main program', you will see that the statement is in EXIT_SAPLMLSP_030. -
How do you two Ipods with the same name on one computer?
I had the 2nd generation ipod touch and then I got the new one.When i put the new ipod on my itunes i used the same ipod name. I then lost the new one and wanted to use the old one. I had bought some new stuff that i wanted to download. But when i plugged it in a synced it a message came up saying: The ipod
You omitted what the message said. If yu post it them maybe we can help.
-
hii am new to oracle , can u help me how to write a procedure for the following query
Transfer Funds between Accounts:
Table: AccountMaster (AcctNo (primary key), AcctHolderName, currentBal
Data: 1, 'A', 1000
2, 'B', 3000
3, 'C', 4000
Function: getBalance (AcctNo)
Stored Proc: tranferFunds (FromAcctNo IN, ToAcctNo IN, Amt IN, result OUT)
The proc should use the function getBalance (AcctNo) to find out the current balance for account.
The proc should return a value of 1 if the transfer was successful.
It should return a value of -1 if the funds are not sufficient in the fromAccount to transfer.
Thanx ,
Raj0412I would start by asking your teacher to clarify the parts of the assignment that are not clear to you.
You may also want to read some books.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/toc.htm
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm
Maybe you are looking for
-
I see some stock in MC.9 for the material code xxxxx 18 kg. but in mmbe it does not show the stock in transit. not also in mb52 & mb5t How I can find out against what sto it is sent in stock in tranit . Data seems to be archieved. Thanks, Kiran
-
Using a camcorder to record video and an interface to capture the audio
Here is what I am trying to do: Use my camcorder to record the video and use a mic connected to an audio interface to record the audio portion of the video. Here is how my set up looks like: I have an M-Audio firewire audio interface connected to my
-
Function module for converting sap script to smartforms?
hi , wat is the name of function module for converting sap script to smartforms? regard's Deepak sharma
-
is there any way to read the pdf file to the mobile fone?
-
Importing Linked data from a PDF to make a singular PDF file.
Ok, here's my scenerio. I have a PDF Report that contains LINKS. These LINKS call out to a folder called LINKS that contains DOC, XLS and TXT files that can be retrieved when in the original PDF LINK is activated. This LINKS folder must be in the s