Migrating from TSQL Need Help? printing multiple columns in Stored procedur
I need to create a Stored Procedure which returns set of columns not all
(for eg FirstName, LastName, Dept_Id) from emloyee table based on certain conditions.
In TSQL, it is very simple to create such stored procedures which return full recordset(or subset).
I tried creating explicit cursors but I can print only one record at a time. I dnt want concatenation of columns. I want seperate columns in ouput. How to achieve this.?
Code : (But i can only concatenate and print results, what i want is diffrent columns)
declare
f_name employees.first_name%type;
l_name employees.last_name%type;
cursor c is
select first_name,last_name
from employees;
begin
open c;
loop
fetch c into f_name,l_name;
exit when c%notfound;
DBMS_OUTPUT.PUT_LINE (f_name||' '||l_name);
end loop;
close c;
end;
Another very informative article on ref cursors:
PL/SQL 101 : Understanding Ref Cursors
Similar Messages
-
How do i print multiple columns on 1 page in numbers
I think I am over thinking this but I have confused myself. I am using Numbers to create a spreadsheet of family names with their corresponding number. I would like to print multiple columns of names on one page to save paper but I can't figure how to do it. Will someone please help me???
Hi BestMommy,
Here is one way. Don't mess with your database. Create a new table for printing.
Database with a Header Row (named Table 1 as an example) might look like this:
Name
1
Name 1
2
Name 2
3
Name 3
4
Name 4
5
Name 5
6
Name 6
7
Name 7
8
Name 8
9
Name 9
10
Name 10
11
Name 11
12
Name 12
13
Name 13
14
Name 14
15
Name 15
New table for printing:
Name
Name
1
Name 1
8
Name 8
2
Name 2
9
Name 9
3
Name 3
10
Name 10
4
Name 4
11
Name 11
5
Name 5
12
Name 12
6
Name 6
13
Name 13
7
Name 7
14
Name 14
Formula in A2
=Table 1::A2
Formula in B2
=Table 1::B2
Formula in C2
=Table 1::A9
Formula in D2
=Table 1::B9
So it loops back from the bottom of a page to start a new column.
I made this example small for the pics, but obviously you could have more rows and columns per page.
Having created your table for printing, select it, Cut, add a new sheet and Paste. Print just that sheet.
Have a look at 'More Like This' at the bottom of this page. Trying to format page to print table in two columns Jerry suggests using Pages instead of Numbers.
Regards,
Ian.
Edit: Having created your table for printing, select it, Cut, add a new sheet and Paste. Print just that sheet. Ian. -
Need coding support for Accessing MYSQL stored procedure from java
Hi every one,
I need coding support for accessing Mysql stored procedure from java and JSP.
Please help me
pranavYou'd better have a recent version of MySQL, because earlier ones didn't support stored procs.
If your MySQL and driver support stored procs, maybe you just need a JDBC stored proc tutorial.
% -
Help on writing pl/sql stored procedure to accept input in xml format
Hi All,
I need to write a pl.sql stored procedure which would be getting the input as an xml.
The requirement is that xml data recieved in below fashion needs to be inserted to 3 different tables.
The tags under the root node directly needs to be inserted into Table1
The tags under the first element of the root node needs to be inserted into Table2
Can anybody help me on how to write a stored procedure which could take up the below xml as input and insert the data received into 3 different tables.
Any sample code.pointers to achieve this could be of great help.
The structure of the xml would be as follows:
<AssemblyProduct>
<AssemblyHeader>
<Name></Name>
<AssemblyId></AssemblyId>
<ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
<ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
<ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
</AssemblyHeader>
<AssemblyHeader>
<Name></Name>
<AssemblyId></AssemblyId>
</AssemblyHeader>
<AssemblyHeader></AssemblyHeader>
<ApplicationId></ApplicationId>
<ApplicationName></ApplicationName>
<ApplicationValidFrom></ApplicationValidFrom>
<ApplicationValidTo></ApplicationValidTo>
</AssemblyProduct>Well you could write your procedure to accept a parameter of XMLTYPE datatype and then use that value in a query inside the procedure to break the data up as required using something like XMLTABLE e.g.
-- Nested repeating groups example:
WITH t as (select XMLTYPE('
<RECSET>
<REC>
<COUNTRY>1</COUNTRY>
<POINT>1800</POINT>
<USER_INFO>
<USER_ID>1</USER_ID>
<TARGET>28</TARGET>
<STATE>6</STATE>
<TASK>12</TASK>
</USER_INFO>
<USER_INFO>
<USER_ID>5</USER_ID>
<TARGET>19</TARGET>
<STATE>1</STATE>
<TASK>90</TASK>
</USER_INFO>
</REC>
<REC>
<COUNTRY>2</COUNTRY>
<POINT>2400</POINT>
<USER_INFO>
<USER_ID>3</USER_ID>
<TARGET>14</TARGET>
<STATE>7</STATE>
<TASK>5</TASK>
</USER_INFO>
</REC>
</RECSET>') as xml from dual)
-- END OF TEST DATA
select x.country, x.point, y.user_id, y.target, y.state, y.task
from t
,XMLTABLE('/RECSET/REC'
PASSING t.xml
COLUMNS country NUMBER PATH '/REC/COUNTRY'
,point NUMBER PATH '/REC/POINT'
,user_info XMLTYPE PATH '/REC/*'
) x
,XMLTABLE('/USER_INFO'
PASSING x.user_info
COLUMNS user_id NUMBER PATH '/USER_INFO/USER_ID'
,target NUMBER PATH '/USER_INFO/TARGET'
,state NUMBER PATH '/USER_INFO/STATE'
,task NUMBER PATH '/USER_INFO/TASK'
) y
COUNTRY POINT USER_ID TARGET STATE TASK
1 1800 1 28 6 12
1 1800 5 19 1 90
2 2400 3 14 7 5And then you can extract and insert whatever parts you want into whatever tables as part of the procedure. -
Need Help Printing Text Messages From E71
I need to print some saved text messages that are on my e71 but cannot ge **bleep** to hook up to my bluetooth printer it just never finds it. Is there another way to print these messages fromt he phone i really need them
connect to pc and use ovi suite
If i have helped at all a click on the white star below would be nice thanks.
Now using the Lumia 1520 -
Need helping printing to networked printers.
I need help setting up network printers that have a code on them for each individual. There is no place to put a code so the printer will know who is printing what. I have installed 3 printers and they will not print, they just go to a paused mode and when you hit resume in reverts back to pause because it is looking for a code. I have tried it another way but it asks for a user name and password and all we have are codes. The workplace is using a windows based server and the copiers are listed as followed.
Konica biz hub c450
Sharp ar m700n
sharp mx700n
I need help to be able to print from my mac. I also have parallels running with xp installed and all the printers are installed on that side and printing fine. Hopefully someone can help me out.
Thanks in advanceHello and welcome to Apple Discussions.
In order to provide the user with the ability to input a user code, the respective printer driver would have to provide the facility. If this feature did exist on a previous version of OS X, then you may have to check the vendors web site to see if there is a driver for 10.6.
If you are not sure if the function was supported previously, then go through all the user menus for the driver. The function may be present but located in an unusual location. Or it could require an additional file (aka plugin) that could be missing from the driver installation or not compatible with 10.6.
The other thing to note is that if you have the Mac's printing via a Windows queue, you will have to provide user credentials for SMB print queues. This is typically a Windows user account - not the Mac's account details. If you don't want to create accounts for the Mac users on the Windows server, then you can use LPD rather than SMB to connect to the Windows queues. This does require UNIX Printing Services to be enabled on the server.
Pahu -
Need help - Print Menue in Acrobat Pro and Standard
Hello,
at first, i have to apologize for my bad englisch because I'm german.
I downloaded a Trial of Acrobat pro and there I hava an extended Print menue where I can choose individual Color Profiles.
There is an image attached.
But I don't really need the Acobat pro Features, because I need Acrobat only for Color Printing on my Printer. And it ist expensive.
So my Question to you is: Is this extended Print menue also in Acobat 9 Standard?
There is no Trial, so that I hope, that someone can help me.
Can I also set this settings in Acrobat 9 Standard?
Thank you very much for helping me with my buying decision.
Greetings from Munich
SebastianThe Advanced Print menu in 9 Standard does not have all of the options that are in your screen shot.
Checked with a coworker who has 9 Standard, and the options are much more limited. (I have 8 Pro).
Bad news is you would need 9 Pro.
Saw this the other day; sorry for the slow answer, good luck. -
Help! Multiple Column Output
Hi everyone. I'm hoping someone can help me work through this
problem I'm having outputting data to multiple columns. I'm
creating a photo gallery and I would like my table to look
something like this: empty td, td with photo, empty td, td with
photo, new row below those td's with a caption for the photo. I've
taken tutorials online, but none of them explain how to have
additional rows, or additional columns. Thanks in advance for any
help!straffenp wrote:
> Hi everyone. I'm hoping someone can help me work through
this problem I'm
> having outputting data to multiple columns. I'm creating
a photo gallery and I
> would like my table to look something like this: empty
td, td with photo, empty
> td, td with photo, new row below those td's with a
caption for the photo. I've
> taken tutorials online, but none of them explain how to
have additional rows,
> or additional columns. Thanks in advance for any help!
>
It is all a matter of figuring out what you want to output
for each
iteration and developing your logic accordingly. The tricky
part I see
with your requirement is that you will need to create two
loops through
each row of output you want, the first loop to create the top
row and
the second loop to create the bottom. -
I have written some code that prints any file that can be opened using JAI and the ImageIO Tools. The code works good for me but I have some special cases where I am having some difficulty. Some files I need to print are TIFF files with many pages. Some are compressed using Fax Group 4 encoding and others are compressed using OLD jpeg-in-tiff. I can read and print the files just fine, but it takes about 2 seconds to print each page. Also the spooling data for 88 pages is 900 MB in size. Printing the same files using IrfanView takes <1 seconds and the spool file is much smaller (equivalent to the size of the uncompressed tiff) The speed and size issues are problems for me because I am working on a print web service. My code to render each page is below. So far I have tried rendering hints and such to increase speed, but I think the problem is that when I read the image it takes up a lot of space in memory.
Here is the overall requirements for what I am doing: A use will request that the server print a set of files (mixed image formats, restricted to TIFF, JPEG, and GIF) be printed to specific printer as a single print job. They can specify copies and collation only. The service will open each file in order and send its data to the printer. I have created a custom class that implements the Printable interface to handle the multiple files. The class below is created for each file and handles the printing of the image file.
I am using JDK 1.4.2 and WebSphere. I am stuck with these options b/c I have to use some IBM API's (IBM Content Manager 8.3) that are not compatible with 1.5 or higher.
Is there any way to speed up my code. Possibly load the image differently?
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.FileImageInputStream;
import javax.imageio.stream.ImageInputStream;
public class ImagePrinter2 implements Printable
public static final int PAPER_SIZE_LETTER = 0;
public static final int PAPER_SIZE_LEGAL = 1;
private final ImageReader reader;
private final int _pageCount;
private final File imageFile;
private int _pageOffset;
public ImagePrinter2(File imageFile) throws IOException
this.imageFile = imageFile;
ImageInputStream fis = new FileImageInputStream(this.imageFile);
reader = (ImageReader) ImageIO.getImageReaders(fis).next();
reader.setInput(fis);
_pageCount = reader.getNumImages(true);
public int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
throws java.awt.print.PrinterException
BufferedImage image = null;
int currentPage = pageIndex - getPageOffset(); //pageIndex is for the overall job, I need the page in this file
int imgWidth = 0, imgHeight = 0;
int drawX = 0, drawY = 0;
double scaleRatio = 1;
try
image = reader.read(currentPage);
imgWidth = image.getWidth();
imgHeight = image.getHeight();
catch (IndexOutOfBoundsException e)
return NO_SUCH_PAGE;
catch (IOException e)
throw new PrinterException(e.getLocalizedMessage());
if (imgWidth > imgHeight)
pf.setOrientation(PageFormat.LANDSCAPE);
else
pf.setOrientation(PageFormat.PORTRAIT);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
g2.translate(pf.getImageableX(), pf.getImageableY());
g2.setClip(0, 0, (int) pf.getImageableWidth(), (int) pf.getImageableHeight());
scaleRatio =
(double) ((imgWidth > imgHeight)
? (pf.getImageableWidth() / imgWidth)
: (pf.getImageableHeight() / imgHeight));
//check the scale ratio to make sure that we will not write something off the page
if ((imgWidth * scaleRatio) > pf.getImageableWidth())
scaleRatio = (pf.getImageableWidth() / imgWidth);
else if ((imgHeight * scaleRatio) > pf.getImageableHeight())
scaleRatio = (pf.getImageableHeight() / imgHeight);
//center image
if (scaleRatio < 1)
drawX = (int) ((pf.getImageableWidth() - (imgWidth * scaleRatio)) / 2);
drawY = (int) ((pf.getImageableHeight() - (imgHeight * scaleRatio)) / 2);
else
drawX = (int) (pf.getImageableWidth() - imgWidth) / 2;
drawY = (int) (pf.getImageableHeight() - imgHeight) / 2;
AffineTransform at = AffineTransform.getTranslateInstance(drawX, drawY);
if (scaleRatio < 1)
at.scale(scaleRatio, scaleRatio);
g2.drawRenderedImage(image, at);
g2.dispose();
image = null;
return PAGE_EXISTS;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since version XXX
* @return
public int getPageCount()
return _pageCount;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since version XXX
* @return
public int getPageOffset()
return _pageOffset;
* <br><br>
* Created By: TSO1207 - John Loyd
* @since version XXX
* @param i
protected void setPageOffset(int i)
_pageOffset = i;
* Release the reader resources
* <br><br>
* Created By: TSO1207 - John Loyd
* @since version XXX
public void destroy()
try
((ImageInputStream) reader.getInput()).close();
catch (Exception e)
reader.reset();
reader.dispose();
* Helps release memory used when printing (seems to be a 1.4.2 thing)
* <br><br>
* Created By: TSO1207 - John Loyd
* @since version XXX
public void reset() throws FileNotFoundException, IOException
try
((ImageInputStream) reader.getInput()).close();
catch (Exception e)
reader.reset();
ImageInputStream fis = new FileImageInputStream(imageFile);
reader.setInput(fis);
}I found a couple of issues. One was related to code the other to IBM. AS for the code I found an article about drawing scaled images here: http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html which was quite useful. My updated code is below. The second issues is that the JRE I am using is the IBM Websphere 5.1 JRE which pretty much sicks. I tested using a Sun statndard 1.4.2 JRE and the print was 5 times faster. Now I am looking to find a way around that issue, but it is not a questions for this form.
public int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
throws java.awt.print.PrinterException
BufferedImage image = null;
int currentPage = pageIndex - getPageOffset(); //pageIndex is for the overall job, I need the page in this file
int imgWidth = 0, imgHeight = 0;
int drawX = 0, drawY = 0;
double scaleRatio = 1;
try
image = reader.read(currentPage);
imgWidth = image.getWidth();
imgHeight = image.getHeight();
catch (IndexOutOfBoundsException e)
return NO_SUCH_PAGE;
catch (IOException e)
throw new PrinterException(e.getLocalizedMessage());
if (imgWidth > imgHeight)
pf.setOrientation(PageFormat.LANDSCAPE);
else
pf.setOrientation(PageFormat.PORTRAIT);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
g2.translate(pf.getImageableX(), pf.getImageableY());
g2.setClip(0, 0, (int) pf.getImageableWidth(), (int) pf.getImageableHeight());
scaleRatio =
(double) ((imgWidth > imgHeight)
? (pf.getImageableWidth() / imgWidth)
: (pf.getImageableHeight() / imgHeight));
//check the scale ratio to make sure that we will not write something off the page
if ((imgWidth * scaleRatio) > pf.getImageableWidth())
scaleRatio = (pf.getImageableWidth() / imgWidth);
else if ((imgHeight * scaleRatio) > pf.getImageableHeight())
scaleRatio = (pf.getImageableHeight() / imgHeight);
//find the scaled width and height
int scaledWidth = imgWidth, scaledHeight=imgHeight;
//center image
if (scaleRatio < 1)
drawX = (int) ((pf.getImageableWidth() - (imgWidth * scaleRatio)) / 2);
drawY = (int) ((pf.getImageableHeight() - (imgHeight * scaleRatio)) / 2);
//new code to set the scale
scaledWidth = (int)(scaledWidth * scaleRatio);
scaledHeight = (int)(scaledHeight * scaleRatio);
else
drawX = (int) (pf.getImageableWidth() - imgWidth) / 2;
drawY = (int) (pf.getImageableHeight() - imgHeight) / 2;
/*don't need transform
/*AffineTransform at = AffineTransform.getTranslateInstance(drawX, drawY);
if (scaleRatio < 1)
at.scale(scaleRatio, scaleRatio);
g2.drawRenderedImage(image, at);*/
//use scale instance of draw image
g2.drawImage(image, drawX, drawY, scaleWidth, scaleHeight, null);
g2.dispose();
image = null;
return PAGE_EXISTS;
}Edited by: jloyd01 on Mar 7, 2008 1:35 PM -
I have all my images stored in Aperture. When I try to print (output/print image), I get a nice print dialogue box. I do not seem to have the option to print multiple images on a single page. With XP, there was a 'print wizard' that would allow me to choose a paper size, and then fill that paper with images (ex. 3 x 4x6 on a 8x10). I would also use MS Digital Imaging Suite to print multiple images on a single paper.
I am somewhat new to the Mac experience, maybe I'm not looking in the right place.
Please help me with thisWhile I am not familiar with Aperture, the print dialog box for Preview should be quite similar. If you have the full options showing, by clicking on the expansion triangle near the top right, the option to print N-up will be at the bottom of the dialog box. In order to do that, you need to have more than one photo selected for printing., of course. Then you should be able to adjust the layout and size of your photos.
-
Need help with complex column creation command
Hello, all
I need help with a complex column creation command and SQL anywhere help is not sufficient for it.
Here is the situation:
I need to write a generic DDL "alter table" command, which can add/modify columns without knowing in advance if they already exist in the destination table.
Is there a command, which looks like:
alter table "table1" add (on existing modify) column1 <datatype> <default> ?
Thank you,
ArcadyHi.
I don't think this is supported in alter table command. But you can code that inside an if statement which queries systables & syscolumns. Your code should be something like that:
if (select count(*) from sysobjects, syscolumns where sysobjects.id = syscolumns.id and sysobjects.name = 'some_table' and syscolumns.name = 'some_column') < 1
begin
alter table some_table add some_column numeric(12) not null
end
This is an example..
Andreas. -
I need help printing with HP laserjet 2200 and OS 10.6
I need help setting up my HP laserjet 2200 and OS 10.6 -- I've downloaded and installed all the software and still can't print.
Hey jeo1951,
If you haven't already, try running through the recommended steps in the following article:
Mac 101: Printing (Mac OS X v10.6)
http://support.apple.com/kb/HT3771
It should help you set up your printer.
Welcome to Apple Support Communities!
All the best,
Delgadoh -
How to insert from one table to another (multiple columns to single column)
I want to insert data from table1 into table2 and the data looks in 3 columns as below
Table1
RepNm ObjNm DbNm
123 abc def
456 def xyz
789 123 456
and the data in table2 should be display as
Table 2
ObjNm
123
456
789
abc
def
xyz
the dupes should get eliminated and only the distinct values should be inserted into a single column in table2 from multiple columns in table1How do you want to handle nulls? If there is a null in any value of a column, do you want to insert it?
Then,
WITH T
AS (SELECT LEVEL colnum
FROM DUAL
CONNECT BY LEVEL <= 3)
SELECT DECODE (colnum, 1, RepNm, 2, ObjNm, 3, DbNm) as ObjNm
FROM table1, T;if you dont want to insert nulls then,
WITH T
AS (SELECT LEVEL colnum
FROM DUAL
CONNECT BY LEVEL <= 3)
SELECT DECODE (colnum, 1, RepNm, 2, ObjNm, 3, DbNm) AS ObjNm
FROM table1, T
WHERE DECODE (colnum, 1, RepNm, 2, ObjNm, 3, DbNm) = DECODE (colnum, 1, RepNm, 2, ObjNm, 3, DbNm)G. -
Uploading from iPhone - need help
When I attempt to upload a photo from my iPhone to my Web Gallery, I get the following error message on the iPhone:
"None of your .Mac accounts have been configured for posting from mobile devices. You must first enable this feature on the .Mac website"
Any idea how I "enable this feature" as I can't seem to find it anywhere on my .Mac homepage or account info, etc.
Thanks.It's STILL driving me nuts.
Why can't Apple just make it 'Apple-like?' Where is a set of instructions on how to do this?
This is a new far-out concept they're adding here, I want to use it like a Flickr set amongst my iPhone totin' friends, so we can all just send some fun photos up in the cloud, and look at it. This is clearly something we all seem to need help with for the set-up...
AND YET...
Simple question that my iPhone prompts me to ask: Where do I tell my .Mac account that I want my Web Gallery to work with my iPhone?
No sign of it on my 'homepage' on .mac, no explaination in iPhoto 08 prefs or help, no explaination ANYWHERE. Searching is NOT helpful - very poor 'help' page on this topic.
It's not working for me, and I had this button activated on my iPhone yesterday, and an iPhoto Web Gallery for the last 4 hours...
It's just not very clear, Apple. Get it together, please. The only mention of this on my .mac "logged-in" screen is on a descriptive ad for iLife 08 and .Mac.
Well, give me the respect of noticing I've already bought it all. -
Hi Friends,
Anybody can give some idea or suggestion how to print multiple copies of an invoice for the same output type.
Regards
rajuHi
In this case you need to change the program, here you can know the message type and so you can decide how many times a document has to be printed:
DATA: COPIES TYPE I.
IF NAST-KSCHL = .....
ELSE.
ENDDO.
DO COPIES TIMES.
> PRINT THE DOCUMENT
ENDDO.
Max
Maybe you are looking for
-
Is there any way I can move my email and sub accounts over to my verizon business accounts?
-
hi I Have Windows server 2008 R2 and Install Active Directory Install and configuration for windows server 2008 PDC (Primary Domain Controller) and BDC (Additionall Domain Controller) Error A security Package specific Error Occurrred. would you
-
I've just discovered that a piece of my code is modifying a collection that's being iterated over through a for-each statement. My question is: Bug, or Feature? List<Integer> xs = new ArrayList<Integer>(); for (int i=0; i<10; i++)
-
Since recent update came through my app store icon has changed and no longer works. The message that comes up reads - "App store quit unexpectedly" - and has rows of coding messages below it. One message states "Application Specific Information: abor
-
Hi, I have another query in pricing, If a condition type is not populated in a transaction but is present in a pricing procedure,what are the possible reasons for it , and how it can be rectified. The condition record for the particular condition ty