Home » SQL & PL/SQL » SQL & PL/SQL » Test Data printing (merged)
Test Data printing (merged) [message #383476] Thu, 29 January 2009 00:21 Go to next message
raopapa
Messages: 10
Registered: January 2009
Junior Member
hi guys

i need a test data of each table in the user_tables in the following formart can u pl give solution

for example in a emp table i need data in the following way



EMP,EMPNO 7369
EMP,ENAME SMITH
EMP,JOB CLERK
EMP,MGR 7902
EMP,HIREDATE 12/17/1980
EMP,SAL 800
EMP,COMM
EMP,DEPTNO 20

first records of the emp data.

i made few code can u give further.

DECLARE
BEGIN
FOR i IN (SELECT table_name, column_name
FROM user_tab_columns
WHERE table_name = 'EMP')
LOOP
DBMS_OUTPUT.put_line (i.table_name || ',' || i.column_name);
END LOOP;
END;
/

how to bring first record data of the emp table.

Pl suggest

Paparao
Re: Test Data printing [message #383477 is a reply to message #383476] Thu, 29 January 2009 00:24 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>how to bring first record data of the emp table.
Rows in a table are like balls in a basket.
Which is 1st ball in the basket?????

You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
So we can help you

[Updated on: Thu, 29 January 2009 00:24]

Report message to a moderator

Re: Test Data printing [message #383479 is a reply to message #383476] Thu, 29 January 2009 00:25 Go to previous messageGo to next message
Littlefoot
Messages: 21821
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Restrict number of records with a little help of the ROWNUM pseudocolumn:
SQL> select empno, ename, job, sal
  2  from emp
  3  where rownum < 5;

     EMPNO ENAME      JOB              SAL
---------- ---------- --------- ----------
      7369 SMITH      CLERK           1600
      7499 ALLEN      SALESMAN        2400
      7521 WARD       SALESMAN        2050
      7566 JONES      MANAGER         3775

SQL>


[After seeing BlackSwan's reply]

Huh, I understood that ANY number of records (including only one record) would be OK (i.e. that ORDER BY doesn't matter): "i need a test data of each table". I might have got it wrong ...

[Updated on: Thu, 29 January 2009 00:28]

Report message to a moderator

Re: Test data print [message #383509 is a reply to message #383476] Thu, 29 January 2009 00:51 Go to previous messageGo to next message
Michel Cadot
Messages: 68704
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Use the correct "select" and you can do it.
Why are you selecting user_tab_columns view if you want the content of emp table?

Regards
Michel
Re: Test Data printing [message #383512 is a reply to message #383479] Thu, 29 January 2009 00:55 Go to previous messageGo to next message
raopapa
Messages: 10
Registered: January 2009
Junior Member
using emp give me an example....
Re: Test data print [message #383514 is a reply to message #383509] Thu, 29 January 2009 00:56 Go to previous messageGo to next message
raopapa
Messages: 10
Registered: January 2009
Junior Member
i want table name and column names also thats why i selected user_tab_columns table
Re: Test Data printing [message #383516 is a reply to message #383512] Thu, 29 January 2009 00:58 Go to previous messageGo to next message
wmgonzalbo
Messages: 98
Registered: November 2008
Member
raopapa wrote on Thu, 29 January 2009 00:55
using emp give me an example....


Yes boss...
Re: Test data print [message #383517 is a reply to message #383514] Thu, 29 January 2009 00:59 Go to previous messageGo to next message
Michel Cadot
Messages: 68704
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
T.Kyte's print_table function.

Regards
Michel
Re: Test data print [message #383524 is a reply to message #383517] Thu, 29 January 2009 01:23 Go to previous messageGo to next message
raopapa
Messages: 10
Registered: January 2009
Junior Member
using pl/sql block i need the solution
Re: Test data print [message #383527 is a reply to message #383524] Thu, 29 January 2009 01:28 Go to previous message
Michel Cadot
Messages: 68704
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Read the link I posted.
IT CONTAINS THE SOLUTION.

Regards
Michel
Previous Topic: how to get max semester and year (merged 3)
Next Topic: Cache vs Nocache of Sequences
Goto Forum:
  


Current Time: Sun Nov 03 01:57:46 CDT 2024