How to call a procedure with refcursor from another plsql unit
example I created a pkg with the a procedure that returns a REFCURSOR.
Now I need to call this procedure from another pkg and use the refcursor values in other pkg.
Help please.......
PROCEDURE CustomerSite_Get (p_Registry IN VARCHAR2,
p_CustomerNumber IN VARCHAR2, p_Cursor IN OUT t_cursor);
PROCEDURE CustomerSite_Get (p_Registry IN VARCHAR2,
p_CustomerNumber IN VARCHAR2, p_Cursor IN OUT t_cursor)
IS
-- 0903: Include BillToName
BEGIN
OPEN p_Cursor FOR
SELECT S.LOCATION CustomerSite, S.SITE_USE_ID CustomerSiteID, C.CUSTOMER_NAME BillToName
FROM RA_CUSTOMERS C,
RA_ADDRESSES A,
RA_SITE_USES S,
UWA_REGISTRY R,
UWA_REGISTRY_BILL_TO B
WHERE C.CUSTOMER_ID = A.CUSTOMER_ID
AND A.ADDRESS_ID = S.ADDRESS_ID
AND S.SITE_USE_ID = B.SITE_USE_ID
AND R.REGISTRY_ID = B.REGISTRY_ID
AND B.TRIP_BILLING != 'N'
AND R.DELETE_FLAG != 'Y'
AND R.Registry = p_Registry
AND R.CUSTOMER_NUM = p_CustomerNumber
ORDER BY S.LOCATION;
END CustomerSite_Get;
thanks,
Anitha.
Edited by: user521218 on May 6, 2009 1:24 PM
Hi Anitha,
try this,
-- PKG_A
Procedure CustomerSite_Get( p_Registry IN Varchar2
, p_CustomerNumber IN Varchar2
, p_Cursor IN OUT t_cursor) Is
Begin
PKG_B.CustomerSite_Get( p_Registry
, p_CustomerNumber
, p_Cursor );
End;
-- PKG_B
Procedure CustomerSite_Get(p_Registry IN Varchar2
,p_CustomerNumber IN Varchar2
,p_Cursor IN OUT t_cursor) Is
Begin
Open p_Cursor For
SELECT S.LOCATION CustomerSite
,S.SITE_USE_ID CustomerSiteID
,C.CUSTOMER_NAME BillToName
FROM RA_CUSTOMERS C
,RA_ADDRESSES A
,RA_SITE_USES S
,UWA_REGISTRY R
,UWA_REGISTRY_BILL_TO B
WHERE C.CUSTOMER_ID = A.CUSTOMER_ID
AND A.ADDRESS_ID = S.ADDRESS_ID
AND S.SITE_USE_ID = B.SITE_USE_ID
AND R.REGISTRY_ID = B.REGISTRY_ID
AND B.TRIP_BILLING != 'N'
AND R.DELETE_FLAG != 'Y'
AND R.Registry = p_Registry
AND R.CUSTOMER_NUM = p_CustomerNumber
Order BY S.LOCATION;
End CustomerSite_Get;regards,
Christian Balz
Similar Messages
-
Calling a procedure (with refcursor) from another procedure
I have a procedure that returns refcursor (it's used by a Java application).
I am able to run the proc via SQLPlus like below:
var a refcursor;
exec MY_PKG.get_content_prc(:a);
print a;
I would like to use/call this proc from another procedure and I am not able to, since arg is refcursor.
create or replace procedure p
is
v refcursor;
begin
MY_PKG.get_content_prc(:v);
end;
Error I get is:
SQL> show err
Errors for PROCEDURE P2:
LINE/COL ERROR
4/3 PL/SQL: Item ignored
4/7 PLS-00201: identifier 'CURSOR' must be declared
6/5 PL/SQL: Statement ignored
6/57 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
Hope someone can direct me.
RegardsBecause you are not using the right syntax.
You need to do something like this
LOOP
/* Fetch from cursor variable. */
FETCH emp_cv INTO emp_rec;
EXIT WHEN emp_cv%NOTFOUND; -- exit when last row is fetched
-- process data record
END LOOP;This is from the PL/SQL User's Guide and Reference.
I would recommend reading this fine manual, it is faster than guessing. -
How to call sql procedure with parameter from java
Hello,
i am trying to call one sql procedure with two parameters from java.
the first parameter is In parameter, the second is OUT.
the return value of this java method should be this second parameter value.
the following is my java code:
protected String getNextRunNumber() {
String runnumber=null;
String sql = "{call APIX.FNC_SST_EXPORT.GET_NEXT_RUNNUMBER (?,?)}";
CallableStatement state = null;
try{
Connection con= getDatabaseConnection();
state = con.prepareCall(sql);
state.setString(1, m_appKeyExport);
state.registerOutParameter(2,Types.NUMERIC,0);
state.execute();
ResultSet resultR = (ResultSet)state.getObject(2);
while (resultR.next()) {
runnumber=resultR.getBigDecimal(1).toString();
catch (SQLException e){System.out.println("You can not get the export next run number properly");}
return runnumber;
i got error message like:
java.lang.ClassCastException: java.math.BigDecimal
As far as i knew, if the parameter is number or decimal, we should give also the paramer scale to the method: state.registerOutParameter(), but i still get this error message.
Please help me to solve this problem.
Thanks a lot.state.execute();
i try to use debug to find the problem, in this line, i saw
OracleCallableStatement(OraclePreparedStatement).execute() line: 642 [local variables unavailable]
is this the problem? -
How to call a Asynchronous bpel process from a PLSQL procedure?
How to call a Asynchronous bpel process from a PLSQL procedure?
Hi,
You could do something smart and technical very spiffy with soap-stacks in the database and/or dbms_ws/dbms_http. But I allways find AQ with AQ-adapter the simplest. Let Pl/sql enqueue a message on an aq-queue and subscribe an aq-adapter process on it. That can call your async-bpel process. If you want to get answer back in pl/sql, let the aq-adapter process enqueue a response message on another queue or on the same queue with another consumer name. Give it a correlation-id that you provided in the payload of your request message. Your pl/sql process can then do a dequeue on that correlation-id. It will sit and wait until a message with that correlation id is enqueued on the queue.
Regards,
Martien -
How to call java function with parameter from javascript in adf mobile?
how to call java function with parameter from javascript in adf mobile?
The ADF Mobile Container Utilities API may be used from JavaScript or Java.
Application Container APIs - 11g Release 2 (11.1.2.4.0) -
How to call stored procedure with multiple parameters in an HTML expression
Hi, Guys:
Can you show me an example to call stored procedure with multiple parameters in an HTML expression? I need to rewrite a procedure to display multiple pictures of one person stored in database by clicking button.
The orginal HTML expression is :
<img src="#OWNER#.dl_sor_image?p_offender_id=#OFFENDER_ID#" width="75" height="75">which calls a procedure as:
procedure dl_sor_image (p_offender_id IN NUMBER)now I rewrite it as:
PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number)could anyone tell me the format for the html expression to pass multiple parameters?
Thanks a lot.
SamHi:
Thanks for your help! Your question is what I am trying hard now. Current procedure can only display one picture per person, however, I am supposed to write a new procedure which displays multiple pictures for one person. When user click a button on report, APEX should call this procedure and returns next picture of the same person. The table is SOR_image. However, I rewrite the HTML expression as follows to test to display the second image.
<img src="#OWNER#.Sor_Display_Current_Image?p_n_Offender_id=#OFFENDER_ID#&p_n_image_Count=2" width="75" height="75"> The procedure code is complied OK as follows:
create or replace
PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number) AS
v_mime_type VARCHAR2(48);
v_length NUMBER;
v_name VARCHAR2(2000);
v_image BLOB;
v_counter number:=0;
cursor cur_All_Images_of_Offender is
SELECT 'IMAGE/JPEG' mime_type, dbms_lob.getlength(image) as image_length, image
FROM sor_image
WHERE offender_id = p_n_Offender_id;
rec_Image_of_Offender cur_All_Images_of_Offender%ROWTYPE;
BEGIN
open cur_All_Images_of_Offender;
loop
fetch cur_All_Images_of_Offender into rec_Image_of_Offender;
v_counter:=v_counter+1;
if (v_counter=p_n_image_Count) then
owa_util.mime_header(nvl(rec_Image_of_Offender.mime_type, 'application/octet'), FALSE);
htp.p('Content-length: '||rec_Image_of_Offender.image_length);
owa_util.http_header_close;
wpg_docload.download_file (rec_Image_of_Offender.image);
end if;
exit when ((cur_All_Images_of_Offender%NOTFOUND) or (v_counter>=p_n_image_Count));
end loop;
close cur_All_Images_of_Offender;
END Sor_Display_Current_Image; The procedure just open a cursor to fetch the images belong to the same person, and use wpg_docload.download_file function to display the image specified. But it never works. It is strange because even I use exactly same code as before but change procedure name, Oracle APEX cannot display an image. Is this due to anything such as make file configuration in APEX?
Thanks
Sam -
Calling Stored Procedure with parameters from a C program
Hello, I need to call a PL/SQL stored procedure from a C program.
Something like this sample program provided by Oracle -
main()
int i;
EXEC SQL BEGIN DECLARE SECTION;
*/* Define type for null-terminated strings. */*
EXEC SQL TYPE asciz IS STRING(20);
asciz username[20];
asciz password[20];
int dept_no; / which department to query */*
char emp_name[10][21];
char job[10][21];
EXEC SQL VAR emp_name is STRING (21);
EXEC SQL VAR job is STRING (21);
float salary[10];
int done_flag;
int array_size;
int num_ret; / number of rows returned */*
int SQLCODE;
EXEC SQL END DECLARE SECTION;
*/* Connect to Oracle. */*
strcpy(username, "SCOTT");
strcpy(password, "TIGER");
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf("Enter department number: ");
scanf("%d", &dept_no);
fflush(stdin);
*/* Set the array size. */*
array_size = 10;
done_flag = 0;
num_ret = 0;
*/* Array fetch loop - ends when NOT FOUND becomes true. */*
EXEC SQL EXECUTE
BEGIN personnel.get_employees
*(:dept_no, :array_size, :num_ret, :done_flag,*
*:emp_name, :job, :salary);*
END;
END-EXEC;
The question is - how is the Stored procedure get_employees declared ? Or more specifically, how is the salary parameter declared in get_employees ? Any help is highly appreciated.Hope following will help
NOTE: Not tested
Calling a stored procedure
This program connects to ORACLE using the SCOTT/TIGER
account. The program declares several host arrays, then
calls a PL/SQL stored procedure (GET_EMPLOYEES in the
CALLDEMO package) that fills the table OUT parameters. The
PL/SQL procedure returns up to ASIZE values.
It keeps calling GET_EMPLOYEES, getting ASIZE arrays
each time, and printing the values, until all rows have been
retrieved. GET_EMPLOYEES sets the done_flag to indicate "no
more data."
#include <stdio.h>
#include <string.h>
EXEC SQL INCLUDE sqlca.h;
typedef char asciz[20];
typedef char vc2_arr[11];
EXEC SQL BEGIN DECLARE SECTION;
/* User-defined type for null-terminated strings */
EXEC SQL TYPE asciz IS STRING(20) REFERENCE;
/* User-defined type for a VARCHAR array element. */
EXEC SQL TYPE vc2_arr IS VARCHAR2(11) REFERENCE;
asciz username;
asciz password;
int dept_no; /* which department to query? */
vc2_arr emp_name[10]; /* array of returned names */
vc2_arr job[10];
float salary[10];
int done_flag;
int array_size;
int num_ret; /* number of rows returned */
EXEC SQL END DECLARE SECTION;
long SQLCODE;
void print_rows(); /* produces program output */
void sql_error(); /* handles unrecoverable errors */
main()
int i;
char temp_buf[32];
/* Connect to ORACLE. */
EXEC SQL WHENEVER SQLERROR DO sql_error();
strcpy(username, "scott");
strcpy(password, "tiger");
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf("\nConnected to ORACLE as user: %s\n\n", username);
printf("Enter department number: ");
gets(temp_buf);
dept_no = atoi(temp_buf);/* Print column headers. */
printf("\n\n");
printf("%-10.10s%-10.10s%s\n", "Employee", "Job", "Salary");
printf("%-10.10s%-10.10s%s\n", "--------", "---", "------");
/* Set the array size. */
array_size = 10;
done_flag = 0;
num_ret = 0;
/* Array fetch loop.
* The loop continues until the OUT parameter done_flag is set.
* Pass in the department number, and the array size--
* get names, jobs, and salaries back.
for (;;)
EXEC SQL EXECUTE
BEGIN calldemo.get_employees
(:dept_no, :array_size, :num_ret, :done_flag,
:emp_name, :job, :salary);
END;
END-EXEC;
print_rows(num_ret);
if (done_flag)
break;
/* Disconnect from the database. */
EXEC SQL COMMIT WORK RELEASE;
exit(0);
void
print_rows(n)
int n;
int i;
if (n == 0)
printf("No rows retrieved.\n");
return;
for (i = 0; i < n; i++)
printf("%10.10s%10.10s%6.2f\n",
emp_name, job[i], salary[i]);
/* Handle errors. Exit on any error. */
void
sql_error()
char msg[512];
int buf_len, msg_len;
EXEC SQL WHENEVER SQLERROR CONTINUE;
buf_len = sizeof(msg);
sqlglm(msg, &buf_len, &msg_len);
printf("\nORACLE error detected:");
printf("\n%.*s \n", msg_len, msg);
EXEC SQL ROLLBACK WORK RELEASE;
exit(1);
Remember, the datatype of each actual parameter must be convertible to the datatype of its corresponding formal parameter. Also, before a stored procedure is exited, all OUT formal parameters must be assigned values. Otherwise, the values of corresponding actual parameters are indeterminate.
SQLCHECK=SEMANTICS is required when using an anonymous PL/SQL block. -
How to call a procedure with SYS_REFCURSOR OUT parameter
Hi,
Using Oracle 11g R2.
I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
create or replace procedure testprocedure (result OUT sys_refcursor)
as
begin
open result for
select 1 from dual
union all
select 2 from dual;
end;
I'd like to call this procedure similar to the way a query is called and executed. Like this
select * from testprocedure
I've seen plenty of examples on the web which show how it is possible to loop through results of a sys_refcursor inside of an anonymous block and display the results using dbms_output.putline, but this isn't the method I am looking for.I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
No - you can only use schema object types (SQL) in SQL queries and only then if you call a function.
The function can return a SQL collection type or it can be a PIPELINED function whose return value is a SQL collection type. Either way your query will use the TABLE function and be of the form:
select * from TABLE(testfunction);
This is sample code for a PIPELINED function based on the SCOTT.EMP table. The function takes a department number parameter and returns the EMP rows for that department:
-- type to match emp record
create or replace type emp_scalar_type as object
(EMPNO NUMBER(4) ,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7, 2),
COMM NUMBER(7, 2),
DEPTNO NUMBER(2)
-- table of emp records
create or replace type emp_table_type as table of emp_scalar_type
-- pipelined function
create or replace function get_emp( p_deptno in number )
return emp_table_type
PIPELINED
as
TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
emp_cv EmpCurTyp;
l_rec emp%rowtype;
begin
open emp_cv for select * from emp where deptno = p_deptno;
loop
fetch emp_cv into l_rec;
exit when (emp_cv%notfound);
pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
end loop;
return;
end;
select * from table(get_emp(20)) -
How to call a procedure with two arguments
Hi,
I have a procedure with two arguments, ie. myprocedure(p1 in number,p2 in number) to display a blob image.
how can I call out this blob image in url.
I tried http://127.0.0.1:7777/pls/apex/SCHEMA.myprocedure?p1=1&p2=2 , but it don't work..
Thanks
vincentVincent,
As long as you have been granted the ability to execute the procedure and there are no spaces in the url and you have not misspelled the parameter names then this looks right.
Here is a link to a procedure to download a file which takes two parameters.
http://mywebsite.com/pls/htmldev/schema.package.function.download_file?p_session_id=1221970786026206&p_seq_id=724
Cheers,
Tyson Jouglet -
Create stored procedure with table from another schema throws PLS-00201
Oracle 10g. I'm new to procedures, so maybe I'm missing something obvious.
Schema owner ABC has table T2001_WRITEOFF. The SYSDBAs granted SIUD to Some_Update_Role, and granted that role to developer user IJK. User IJK then created a private synonym T2001_WRITEOFF for ABC.T2001_WRITEOFF. This worked with normal SQL DML commands.
When I try to create a simple procedure as follows, it throws PLS-00201 identifier 'T2001_WRITEOFF' must be declared, and points to the 2nd line.
create or replace procedure woof1(
fooname in T2001_WRITEOFF.territory%TYPE, <=== error points here
bardesc IN T2001_WRITEOFF.ind_batch_submit%TYPE) IS
BEGIN
INSERT into T2001_WRITEOFF
VALUES ( fooname, bardesc);
END woof1;
What am I doing wrong?
Thanks
JimRHi,
The reason I've heard has to do with knowing when a procedure becomes invalid due to privileges being revoked. Any time a grant to a role is revoked, you would have to check all procedures that depended on that role to know if they were still valid. Even worse, since roles can be granted to other roles, every time a role is revoked from another role, you would have to check all procedures that depended on anything to see if they were still valid.
Oracle 11 behaves the same as earlier versions in this regard, and I don't expect this to change.
This whole thread applies only to AUTHID DEFINER stored procedures (which is the default). If you can make the procedure AUTHID CURRENT_USER, then you can run it with privileges granted through roles. Usually, however, you really want AUTHID DEFINER, and granting the necessary privileges directly to the procedure owner (or to PUBLIC) isn't too hard. -
How to call stored procedure with parameters?
I created a stored procedure in db like:
CREATE PROCEDURE dbo.MySP
@name varchar(50),
@access_date datetime
AS
BEGIN
--insert data into a table
End
Then I create pb function to call this sp like( I use pb 11.5)
datetime ll_date
ll_date =datetime(today(), now())
DECLARE mytest PROCEDURE FOR MySP @objname = :is_name, @access_date = :ll_date USING is_tran;
IF is_tran.SQLCode <> 0 THEN
MessageBox ( "Error", "DECLARE failed" )
RETURN
END IF
EXECUTE mytest;
IF ( is_tran.SQLCode <> 0 ) and ( is_tran.SQLCode <> 100 ) THEN
MessageBox ( "Error", "EXECUTE failed" )
RETURN
END IF
Then I run the app, first time to call this function without any error, but no data inserted, no thing happen.
keep in the app and call the function again, give me error declare error.
debug give me SQLCode = 100.
SP is fine, I can insert data with isql like:
exec MySP 'name', '2014-06-18'
How to figure out the problem and fix it?You didn't mention the database in question, but the first thing I would recommend is making the call via and RPCFUNC declaration on a user object to type transaction rather than embedded SQL. Embedded SQL (IMHO) should be a last resort.
See: Using Transaction Objects to call Stored Procedures -
How to call a Java Web Service from another Java package ?
Please, does anybody know a simple way to access to a JWSDP Web Service deployed under Tomcat with another java application ?
I've tried with ServiceFactory and Service class from JaxRPC API but it doesn't work ....
Thanx.What not just invoke it the same you would invoke a remote service? Create a service stub and call a service method.
Mike -
How to call view of one application from another application in SAP UI5?
Hi,
I have a main shell application. inside the shell i have called a application project using iframe.
Now from this project i have to access the view from the shell application. I tried getParent() but it returns null.
How do i access view which is not in my project and in a different project?Yeah view cannot be called independently.
Here in the above post i am just saying call the interface view.
which will call the window and first view will be called.
in the wddoinit of the first view . we will check the interface node and if a particular attribute is set.
that means call is coming from the comp B then you can fire the plug to next view.
this will take the user directly to second view.
but the flow logic then will be as per by comp A only.
means after view 2 it will go to view 3 like that as you have defined in comp A.
so you cannot use it as an independent reusable entity.
thanks
sarbjeet singh -
How to update this table with values from another table ?
Hi
I have a table "regies". I want to replace the values of the column "regies.agent" by the value of the column "regies_personnes.id"
As you see the tables have a common values column. ie regies.agent = regies_personnes.nom
Table "regies" :
Insert into "regies" (AGENT) values ('Humberdot Alain');
Insert into "regies" (AGENT) values ('Danard Patrick');
Table "regies_personnes" :
Insert into REGIES_PERSONNES (NOM,ID) values ('Humberdot Alain',1);
Insert into REGIES_PERSONNES (NOM,ID) values ('Danard Patrick',2);
Before we have this
sql>select agent from regies ;
Humberdot Alain
Danard Patrick
After the update, the result should be
sql>select agent from regies ;
1
2
Thank you for your kind answer.You will face error if you have duplicates
ORA-01427 Single row subquery returns Multiple rows.Try this way
create table regies(agent varchar2(30));
create table regies_personnes( nom varchar2(30),id number);
Insert into regies (AGENT) values ('Humberdot Alain');
Insert into regies (AGENT) values ('Danard Patrick');
Insert into REGIES_PERSONNES (NOM,ID) values ('Humberdot Alain',1);
Insert into REGIES_PERSONNES (NOM,ID) values ('Danard Patrick',2);
Insert into regies (AGENT) values ('Humberdot Alain');
Insert into regies (AGENT) values ('Danard Patrick');
Insert into REGIES_PERSONNES (NOM,ID) values ('Humberdot Alain',1);
Insert into REGIES_PERSONNES (NOM,ID) values ('Danard Patrick',2);
commit;
update regies r set agent = (select id from regies_personnes p where r.agent = p.nom
and rownum=1)
where exists (select id from regies_personnes p where r.agent = p.nom
commit -
How to execute a procedure with collection passed as parameter?
i have created the collection:
CREATE TYPE typ_Project AS OBJECT( project_no NUMBER(2), title VARCHAR2(35), cost NUMBER(7,2))
CREATE TYPE typ_ProjectList AS VARRAY (50) OF typ_Project
and a procedure:
CREATE OR REPLACE PROCEDURE add_project (
p_deptno IN NUMBER,
p_new_project IN typ_Project,
p_position IN NUMBER )
IS
v_my_projects typ_ProjectList;
BEGIN
SELECT projects INTO v_my_projects FROM department
WHERE dept_id = p_deptno FOR UPDATE OF projects;
v_my_projects.EXTEND;
FOR i IN REVERSE p_position..v_my_projects.LAST - 1 LOOP
v_my_projects(i + 1) := v_my_projects(i);
END LOOP;
v_my_projects(p_position) := p_new_project; -- add new
UPDATE department SET projects = v_my_projects
WHERE dept_id = p_deptno;
END add_project;
Now please explain how to call this procedure with collection passed as parameter . . .For example:
BEGIN
add_project(
10, -- department number
typ_Project(
99, -- project number
'New Project', -- project title
99999.99 -- project cost
), -- new project
5 -- project position
END;
/SY.
Maybe you are looking for
-
Select_list_from_query function null value
How does one remove the null value when using the select_list_query function? So if I have the following: SELECT HTMLDB_ITEM.SELECT_LIST_FROM_QUERY(3,id,'SELECT id FROM emp') FROM emp It currently adds the extra null '%' value. Where would I plug in
-
Is there a way to read file metadata in LabVIEW? If I was looking at an executable and wanted to retrieve the version number (that shows up when you look at the file's properties in windows), how would I do it in LabVIEW? S G Certified LabVIEW Archi
-
Lightroom 3 not sure which pictures are which in Library view/slideshow?
Well I've been trying out LR3 for the past week or so and have a nagging problem. Say I had an import yesterday from a birthday party, and one today from a football game. I'll import the football game pictures and then be in library mode, with the vi
-
i have to get a new computer i want to get a macbook pro non retina but i use my computer alot with school i have lots of files and picture but what should i get 4gb or 8gb
-
Printers across multiple users
This might be a simple question, but if you have a computer lab of 30 iMacs and want a set of networked printers available to all users that login to those machines, how do you do that? I can install the printers one at a time for each user via IP ad