Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8022999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:25:57+00:00 2026-06-04T22:25:57+00:00

QL> desc newemp Name Null? Type —————————————– ——– —————————- EMPNO NOT NULL NUMBER(4) ENAME

  • 0
    QL> desc newemp
    Name                                      Null?    Type
    ----------------------------------------- -------- ----------------------------
    EMPNO                                     NOT NULL NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                    NOT NULL NUMBER(2)

declare
    empsfile utl_file.file_type;
    cursor empscur is
    select * from newemp;
    begin
    empsfile := utl_file.fopen('DIPRJDIR','EMPS.TXT','W');
    for rec in empscur
    loop
    --utl_file.put_line(empsfile,rec.EMPNO||rec.ENAME||rec.JOB||rec.MGR||rec.HIREDATE||rec.SAL||rec.COMM||rec.DEPTNO);
    utl_file.put_line(empsfile,lpad(rec.EMPNO,4,'0')||Rpad(rec.ENAME,10,' ')||Rpad(rec.JOB,9,' ')||Rpad(rec.MGR,4,'0')||Rpad(rec.HIREDATE,10,' ')||lpad(rec.SAL,9,'0')||Lpad(rec.COMM,9,'0')||Lpad(rec.DEPTNO,2,'0'));

    end loop;
    UTL_FILE.FCLOSE(empsfile );
    EXCEPTION
     WHEN OTHERS THEN
       DBMS_OUTPUT.PUT_LINE( 'ERROR -->' ||  SQLERRM);
    END;
    /

I had written a program executing porperly but now my boss is telling pading should be done according to the datatype value for example empno number (4) than padding should be done by 4.But in the above mention code i had manually written the value. Now my boss is telling me i should dynamically assign value while padding for example
(rec.SAL,9,’0′) in this 9 values should be taken directly from table.So the if boss has alter the table than also above code should work and we dont have to write the code again.

pleqse help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:26:00+00:00Added an answer on June 4, 2026 at 10:26 pm

    Hmm, empno/deptno, I remember those. Not quite sure what you (or your boss/teacher) is looking for, but I think she’s talking about:

    select column_name || ','
    from all_tab_columns
    where table_name = 'SOME_TABLE'
    and owner = 'SOME_OWNER'
    order by column_id;
    

    You can then copy/paste into your code, which is helpful for a table with 100 columns for example. You can of course modify for your specific needs, maybe (untested):

    select
      case
        when data_type = 'NUMBER' then
            'lpad(rec.' || column_name || ',4,''0'') ||'
        when data_type = 'VARCHAR2' then
            'rpad(rec.' || column_name || ',10,'' '') ||'
        when data_type = 'DATE' then
            'rpad(to_char(rec.' || column_name || ',''MM/DD/YYYY''),10,'' '') ||'
        else
            'rpad(rec.' || column_name || ',10,'' '') ||'
      end val
    from all_tab_columns
    where table_name = 'SOME_TABLE'
    and owner = 'SOME_OWNER'
    order by column_id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SQL> desc FLIGHTS; Name Null? Type ----------------------------------------- -------- ---------------------------- FLNO NUMBER(38) FROM VARCHAR2(64) TO
mysql> desc oldtable; +---------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default
Why can I not get Desc order for total_time_driven_at_this_trip? SELECT DISTINCT (`name`), MAX( `total_time_driven_at_this_trip`
My models: Item: name desc Type: name Value: item.ForeignKey(Item) type.ForeignKey(Type) val.CharField # varchar or
I have two tables: mysql> desc myps3t_gameusertrophyinfo; +-----------+--------------+------+-----+---------+----------------+ | Field | Type | Null
mysql> desc persondb; +--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default
mysql> desc oldtable; +---------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default
I have the table Tb ID | Name | Desc ------------------------- 1 | Sample
var val = $(#desc).val(); // input box var val2 = $(#type).val(); // select box
How can I order DESC by a field, but list the NULL values first?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.