Datatype of columns in a table
How do I get the data type of a column without using data dictionary?
Is there any generic construct to find the datatype which will work for SQL Server and Oracle?
How do I get the data type of a column without using data dictionary?You can't.
Is there any generic construct to find the datatype which will work for SQL Server and Oracle? None that I'm aware of.
Cheers, APCE
Similar Messages
-
Modifying datatype of columns across multiple tables
Hi,
I have a requirement where-in I have to modify the datatypes of columns across multiple tables. Is there any direct way to do this? I mean does oracle has any function or in-built functionality to achieve this.
Example;
Table1 -> col1 datatype needs to be changed to varchar2(10)
Table2 -> col2 datatype needs to be changed to varchar2(30)
Table3 -> col3 datatype needs to be changed to number.
and so on....
Do we have such functionality?
Thanks,
IshanHi Aman,
Seeing the replies, I think I was unclear in the requirements. But I guess you understood it fully, but still I would like to restate my question once again, just to be 100% sure.
What I actually want is that in one shot, I would be able to modify columns of multible tables.
eg, table1-> col1 changed to varchar2(20);
table2->col2 changed to varchar2(10)
table3-> col3 changed to number;
I know how to do it individually, but just wanted to check, if only one command can modify the datatypes of multiple tables/.
If not, I have already written half the script, but just for knowledge sake wanted to check if some feature is available in oracle for that.
Regards,
Ishan -
To check whether there is any size mismatch between columns of two tables
Hi,
Here i got two tables T and M where i am going to migrate data from T to M. But before migrating i need to check whether all the data in source table fits into destination table columns. The datatypes of all columns in source table T is of Varchar2 only as it is a temp table.
Ex :- Table 'T' (Source table) with columns
T_Lat Varchar2(50);
T_Amt Varchar2(50);
T_Cat Varchar2(50);
T_Vat Varchar2(50);
Now I have another table 'M'(Destination Table) with columns
M_Lat Varchar2(50);
M_Amt varchar2(25);
M_Cat date;
M_Vat number;
Now my task is I have to do a prevalidation of the data in 'T' that whether all the data in those columns will suit for the destination table columns respectively (to check whether there is any size mismatch). This check should be done dynamically.
For suppose, in T_Amt(source column of T table) if text is abt 50 characters, it cant fit M_Amt(destination column of M table). In this case it should throw an error indicating that destination column size is less for the source column.
Note:- There is no unique mapping column for these two tables and there are about 400 columns in the source table to be validate
I think it can be done using arrays or plsql tables.
Can any one help in this regard.>
Now my task is I have to do a prevalidation of the data in 'T' that whether all the data in those columns will suit for the destination table columns respectively (to check whether there is any size mismatch). This check should be done dynamically.
>
Just because the source table T_Amt column is defined as 50 doesn't mean any of the data is really that long. So the data itself needs to be checked. That is just what a simple query can do.
See my answer in this thread Posted: Jul 25, 2012 1:14 PM
Re: Help in Execute Immediate - Invalid relational Operator
Here is the modified sample query and results for a query of a clone of the EMP table with some modified data
select count(*) cnt,
-- job column
sum(case when job is null then 1 else 0 end) job_nul,
sum(case when job = 'SALESMAN' then 1 else 0 end) job_salesman,
min(length(job)) job_minlength, max(length(job)) job_maxlength,
min(job) job_min, max(job) job_max,
-- hiredate colulmn
sum(case when hiredate is null then 1 else 0 end) hiredate_nul,
min(hiredate) hiredate_min,
max(hiredate) hiredate_max
from emp1
CNT JOB_NUL JOB_SALESMAN JOB_MINLENGTH JOB_MAXLENGTH JOB_MIN JOB_MAX HIREDATE_NUL HIREDATE_MIN HIREDATE_MAX
14 2 4 5 9 ANALYST SALESMAN 0 9/28/0001 12/3/9999With one query and ONE pass thru the table I was able to get the COUNTs, the MIN and MAX values for each column and the MIN and MAX lengths of the VARCHAR2 columns.
There are 14 total records, 2 where JOB is null, 4 where the JOB is SALESMAN. The MIN length of the JOB data is 5 and the MAX is 9.
Look at the date values. The results tell me I have some problem data.
The length data tells me if I try to put the JOB data into another table I need to define the length as at least 9 or it won't fit.
For your use case you might find that all of the data in the T_Lat column is shorter than 26 and will actually fit into the M_Lat target table column. -
Hi all,
A table can hold maximum how many columns in oracle 9i?
also
For a table in oracle 9i, how many compostite key can be created?
Thanks.
GowriShankar.Nextract from Oracle 9i Documentation<br>
<br>
<b>column</b><br>
Specify the name of a column of the table.<br>
If you also specify AS subquery, then you can omit column and datatype unless you are creating an index-organized table. If you specify AS subquery when creating an index-organized table, then you must specify column, and you must omit datatype.<br>
<b>The absolute maximum number of columns in a table is 1000.</b> However, when you create an object table (or a relational table with columns of object, nested table, varray, or REF type), Oracle maps the columns of the user-defined types to relational columns, creating in effect "hidden columns" that count toward the 1000-column limit.<br><br>
<b>Restrictions on Primary Key Constraints</b><br>
* A table or view can have only one primary key.<br>
* None of the columns in the primary key can have datatype LOB, LONG, LONG RAW, VARRAY, NESTED TABLE, OBJECT, BFILE, or REF, or TIMESTAMP WITH TIME ZONE. However, the primary key can contain a column of TIMESTAMP WITH LOCAL TIME ZONE.<br>
* The size of the primary key cannot exceed approximately one database block.<br>
<b>* A composite primary key cannot have more than 32 columns.</b><br>
* You cannot designate the same column or combination of columns as both a primary key and a unique key.<br>
* You cannot specify a primary key when creating a subtable or a subview in an inheritance hierarchy. The primary key can be specified only for the top-level (root) table or view.<br> -
How to retrieve the data type of a column of a table?
Hi,
I want to retrieve the data type of a column of a table. At the moment I am querying "OCI_ATTR_DATA_TYPE" attribute but it is returning SQLT_CHR for both varchar2 and nvarchar2 data type columns. I need to distinguish between these two data types columns separately. Is there any API through which I could get the exact data type of a column i.e. "nvarchar2"?
Thanks in advance.
HashimHi,
This is the Oracle C++ Call Interface (OCCI) forum - I'm not sure if you are using OCCI or OCI (Oracle Call Interface - the C interface) since you reference "OCI_ATTR_DATA_TYPE" which is more of an OCI focus than OCCI.
In any case, you might take a look at "OCI_ATTR_CHARSET_FORM" which takes the following values:
#define SQLCS_IMPLICIT 1 /* for CHAR, VARCHAR2, CLOB w/o a specified set */
#define SQLCS_NCHAR 2 /* for NCHAR, NCHAR VARYING, NCLOB */So, if you have a datatype of SQLT_CHR and OCI_ATTR_CHARSET_FORM is SQLCS_IMPLICIT then you have a varchar2 if it is SQLCS_NCHAR then you have an nvarchar2.
If you are using OCCI and not OCI then take a look at MetaData::ATTR_DATA_TYPE and MetaData::ATTR_CHARSET_FORM which expose OCI_ATTR_DATA_TYPE and OCI_ATTR_CHARSET_FORM respectively.
Perhaps that will get you what you want.
Regards,
Mark -
How do i find out what is the data type of a column of a Table in oracle or SQL?
a) What if i want to find out the Datatype of a specific column in the Table.
b) How do i find the Column Datatypes?
Can anyone please help me. I am new to oracle and Trying to Learn some stuffHi,
How about doing
SQL> desc <table_name>
SQL> desc emp
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 NUMBER(2) -
Upload file to a column on a table
Hello
I have a form with 5 items:
- ID - hidden
- Company - select list
- Product - select list
- date-created - hidden
- user-created - hidden
- file - file browser.
What i need is to upload a file (pdf) and save all the information (file + data in items) to table portal_gar_cvo.
How can i do this? I've tried to implement some solutions i read but wasn't successful...
Also, on table portal_gar_cvo, besides id, company, product, date-created and user_created, which datatype should column "file" have?
I thank in advance all the replies!Hi,
You should check out the APEX's document on [How to Upload and Download Files in an Application|http://download.oracle.com/docs/cd/E14373_01/appdev.32/e13363/up_dn_files.htm#CJAHDJDA] . It contains all needed information. It also includes a section to store document in a custom table (your own table - portal_gar_cvo).
The data type of "file" column is BLOB.
Ittichai
Edited by: ittichai on Mar 23, 2009 11:37 AM -
The column in the table do not match an existing primary key
I've got two tables tbl_Workshop and tbl_Material
tbl_Workshop has columns workshopID, workshopTitle, materialID
tbl_Material has materialID, name, workshopTitle
when I'm trying to create a relationship between the workshopTitle of tbl1 and tbl2, it gives me an error that says the column in the table do not match an existing primary key.
What could be the reason for this error and how to overcome it.
ps. The datatypes and names of both the table's column match.Have you created primary key on workshopTitle column in tbl_Workshop
You can add foreign key relationship from tbl_Material.workshopTitle
to tbl_Workshop.workshopTitle
only if latter is a primary key of the table.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Append new column to internal table
Hi all,
i have an internal table that was generated based on an ddic structure - now i want to add a column to that table. how can i do that ?
thank you!
clemensHi to all, thank you for your help! here is the code that i have:
REPORT *************_4 .
TYPE-POOLS : abap.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.
TYPE-POOLS: slis.
TABLES: dd03l, dd04t.
TYPES:
BEGIN OF ty_table_struct,
fieldname TYPE dd03l-fieldname, " Tabellenname
ddtext TYPE dd04t-ddtext, " Kurztext
checkbox,
END OF ty_table_struct.
DATA:t_fieldcat TYPE slis_t_fieldcat_alv,
w_fieldcat TYPE slis_fieldcat_main.
DATA:
gt_table_struct TYPE TABLE OF ty_table_struct.
DATA: v_repid TYPE sy-repid.
DATA:
dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat,
l_tab_fields TYPE STANDARD TABLE OF ty_table_struct,
w_tab_fields LIKE LINE OF l_tab_fields.
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(28) v_1 FOR FIELD p_table.
PARAMETERS p_table TYPE dd03l-tabname OBLIGATORY VALUE CHECK.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
v_1 = 'Tabelle für Dublettenprüfung'.
v_repid = sy-repid.
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
PERFORM get_structure.
PERFORM create_dynamic_itab.
PERFORM get_data.
PERFORM write_out.
*& Form get_structure
FORM get_structure.
DATA : idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.
DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
* Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
LOOP AT idetails INTO xdetails.
READ TABLE l_tab_fields INTO w_tab_fields
WITH KEY fieldname = xdetails-name.
IF sy-subrc = 0.
CLEAR xfc.
xfc-fieldname = xdetails-name.
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDIF.
ENDLOOP.
ENDFORM. "get_structure
*& Form create_dynamic_itab
* text
FORM create_dynamic_itab.
* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
* Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM. "create_dynamic_itab
*& Form get_data
* text
FORM get_data.
* Select Data from table.
SELECT (l_tab_fields) INTO CORRESPONDING FIELDS OF TABLE <dyn_table>
FROM (p_table).
ENDFORM. "get_data
*& Form write_out
* text
FORM write_out.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = v_repid
i_structure_name = p_table
CHANGING
ct_fieldcat = t_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* Show only fields that are needed
LOOP AT t_fieldcat INTO w_fieldcat.
READ TABLE l_tab_fields INTO w_tab_fields
WITH KEY fieldname = w_fieldcat-fieldname.
IF sy-subrc <> 0.
DELETE t_fieldcat.
ENDIF.
ENDLOOP.
w_fieldcat-tabname = '<dyn_table>'.
w_fieldcat-fieldname = 'NETPR'.
w_fieldcat-seltext_m = 'Net Price'.
w_fieldcat-outputlen = 15.
w_fieldcat-col_pos = 10.
* w_fieldcat-do_sum = 'X'. "Display column total
w_fieldcat-datatype = 'CURR'.
append w_fieldcat to t_fieldcat.
* Write out data from table.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = t_fieldcat
I_BYPASSING_BUFFER = 'X'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "write_out
*& Form f_read_data
* text
FORM f_read_data.
SELECT * FROM ( dd03l
INNER JOIN dd04t
ON dd03l~rollname = dd04t~rollname
AND dd04t~ddlanguage = syst-langu
AND dd04t~as4local = 'A' ) INTO CORRESPONDING FIELDS OF
TABLE
gt_table_struct WHERE dd03l~tabname = p_table .
ENDFORM. " F_READ_DATA
* Form f_display_data
FORM f_display_data.
* Macro definition
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
ls_fieldcat-rollname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
TYPE-POOLS: slis. " ALV Global types
DATA:
l_exit,
ls_private TYPE slis_data_caller_exit,
ls_field TYPE ty_table_struct,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
* Build the field catalog
m_fieldcat 'FIELDNAME' 'ty_table_struct' 'FIELDNAME'.
m_fieldcat 'DDTEXT' 'ty_table_struct' 'DDTEXT'.
* Optimize column width
ls_private-columnopt = 'X'.
* Display data in a popup
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_selection = 'X'
i_zebra = 'X'
it_fieldcat = lt_fieldcat
i_tabname = 'gt_table_struct'
i_checkbox_fieldname = 'CHECKBOX'
is_private = ls_private
IMPORTING
e_exit = l_exit
TABLES
t_outtab = gt_table_struct.
CHECK l_exit = space.
* write selected columns to the internal table for inclusion
* into fieldcat
LOOP AT gt_table_struct INTO ls_field WHERE checkbox = 'X'.
APPEND ls_field-fieldname TO l_tab_fields.
ENDLOOP.
ENDFORM.
What
i want it to do is, have the alvgrid displaying the fields from t_fieldcat, plus some fields ( that should be appended to the internal table before, i think ? ). What went wrong ?
Clemens -
ORA-22856: cannot add columns to object tables
Oracle 9i
==========
I tried to alter a table using a simple script.
ALTER TABLE tablename ADD col VARCHAR(50);
And it gave me the error: -
ORA-22856: cannot add columns to object tables
Can someone give me some direction on how to resolve this? The script executes fine on a test env.
Thanks in advanceThanks for replying...
exit Null? Type
BUS NUMBER
REP VARCHAR2(60)
COS NUMBER
REP VARCHAR2(50)
ACC NUMBER
ADJ VARCHAR2(2000)
BAS NUMBER
BIL VARCHAR2(360)
BIL VARCHAR2(50)
BIL VARCHAR2(3)
BIL VARCHAR2(50)
BLP VARCHAR2(240)
BLP NUMBER
BOO DATE
COM NUMBER
COM NUMBER
COM NUMBER(15)
COM NUMBER(15)
COM VARCHAR2(4000)
COM VARCHAR2(30)
CUR NUMBER
CUS VARCHAR2(240)
DEA VARCHAR2(240)
EVE VARCHAR2(240)
HEA VARCHAR2(240)
HEA VARCHAR2(240)
HEA VARCHAR2(240)
HEA VARCHAR2(240)
INC VARCHAR2(30)
INV DATE
MAN VARCHAR2(360)
ORD NUMBER
ORD VARCHAR2(240)
PAY VARCHAR2(240)
PAY NUMBER
HEL NUMBER
PEO VARCHAR2(150)
PER NUMBER
PER VARCHAR2(30)
PER NUMBER(15)
PRO VARCHAR2(240)
PRO VARCHAR2(240)
QUA NUMBER(15)
QUO NUMBER
QUO DATE
QUO DATE
QUO VARCHAR2(80)
RED VARCHAR2(240)
REP VARCHAR2(360)
REP VARCHAR2(30)
REP VARCHAR2(30)
REP VARCHAR2(150)
REP VARCHAR2(3)
REP VARCHAR2(150)
REP VARCHAR2(50)
ROL VARCHAR2(60)
SHI VARCHAR2(360)
SPL VARCHAR2(240)
STA DATE
TER DATE
TOT VARCHAR2(240)
TRX NUMBER
TRX VARCHAR2(240)
TRX VARCHAR2(20)
TRX VARCHAR2(30)
WAI VARCHAR2(240)
YEA NUMBER
MAN VARCHAR2(30)
BUF NUMBER
BUF VARCHAR2(60)
EMC NUMBER
EMC VARCHAR2(60)
INT NUMBER
INT VARCHAR2(60)
SUP NUMBER
SUP VARCHAR2(60)
BRM NUMBER
BRM VARCHAR2(60)
SUP NUMBER
SUP VARCHAR2(60)
REP NUMBER
REP VARCHAR2(60)
DIV NUMBER
DIV VARCHAR2(60)
SUP NUMBER
SUP VARCHAR2(60)
REG NUMBER
REG VARCHAR2(60)
SUP NUMBER
SUP VARCHAR2(60)
ARE NUMBER
ARE VARCHAR2(60)
DIS NUMBER
DIS VARCHAR2(60)
ROL VARCHAR2(240)
ACC NUMBER
BON NUMBER
COM VARCHAR2(240)
COM VARCHAR2(240)
REP NUMBER
BIL NUMBER
BAS NUMBER
TOT NUMBER
TOT NUMBER
OVE NUMBER
BLP NUMBER
QUO VARCHAR2(30)
FN_ NUMBER
FN_ VARCHAR2(10)
SAL NUMBER
RES NUMBER
CRE NUMBER
MAN VARCHAR2(100)
PER NUMBER
PLA NUMBER
PLA NUMBER
REV VARCHAR2(30)
REP VARCHAR2(150)
OU_ NUMBER
OU_ NUMBER
EXC VARCHAR2(1)
MAN NUMBER
INV NUMBER
REP NUMBER
UPL VARCHAR2(1)
COM NUMBER
SEQ NUMBER
QUO NUMBER
PRO VARCHAR2(10)
PRO NUMBER
PRO NUMBER
BI_ NUMBER
CUR NUMBER
YTD NUMBER
PAY NUMBER
PAY DATE
PAY VARCHAR2(1000)
PAY VARCHAR2(80)
PAI VARCHAR2(1)
HOL VARCHAR2(1)
SRP NUMBER
WAI VARCHAR2(1)
WAI VARCHAR2(1)
GBK VARCHAR2(10)
TRX DATE
PAY NUMBER(15)
FIX NUMBER
TER DATE
ADJ VARCHAR2(240)
PAY NUMBER
PRO DATE
OIC DATE
OIC NUMBER
OIC VARCHAR2(30)
OIC NUMBER
HEL NUMBER
COM NUMBER
TRA NUMBER
HDR VARCHAR2(30)
LIN VARCHAR2(30)
LIN DATE
SRC DATE
EM_ DATE
EM_ DATE
ORD VARCHAR2(30)
REP VARCHAR2(150)
BIL VARCHAR2(300)
PER VARCHAR2(240)
Excuse the incomplete column names. All datatypes are basic ones and there are no constraints defined on any of the columns (dw env). The table is partitioned. -
SQL*Loader-418: Bad datafile datatype for column XMLDOC
Hi,
I am trying to load a xml document into a xmltype column in a table using SQL*Loader and I receive this error:
SQL*Loader-418: Bad datafile datatype for column XMLDOC
My ctl is:
LOAD DATA INFILE 'marginalpdbc_xml_20030529.xml'
APPEND INTO TABLE PRUEBA_CARGA
( XMLDOC LOBFILE (CONSTANT 'marginalpdbc_xml_20030529.xml')
TERMINATED BY EOF,
NOMBFICH CONSTANT 'marginalpdbc_xml_20030529.xml' )
And the table is:
create table prueba_carga (NOMBFICH VARCHAR2(200),xmldoc xmltype);
What is wrong with my ctl?
I am using SQL*Loader: Release 9.2.0.1.0 and Oracle9i Enterprise Edition Release 9.2.0.1.0
Thanks in advance.Looks like there is data which takes > 8 digits for the 'DTE_ADDED' column.
Plz check that first.
Can you provide a couple of lines of data for sampling ??? -
Checkbox column in a table problem in getting and setting boolean values
hi Im a newbie in jdeveloper oracle 10g. can anyone help me with jdeveloper adf swing?
I have a table, one of its column is a checkbox that retrieves its value from an oracle database. Oracle doesnt have a boolean datatype. In java, when a column in jtable has a boolean datatype the column automatically becomes checkbox.
I dont know how to manipulate the select and deselect of checkbox.
please met me know.
thanks.Hi thanks for the response, i already do that but im having problem with my view (user interface) it seems that its not working.
i have his code in my view -> Pa.java
jTableCheckClearing.setModel((TableModel)panelBinding.bindUIControl("CheckClearingView",
jTableCheckClearing));
ABSIJTableWrapper.adjustColumnPreferredWidths(jTableCheckClearing);
TableColumnModel colModel = jTableCheckClearing.getColumnModel();
colModel.getColumn(0).setHeaderValue(new String("Type"));
colModel.getColumn(1).setHeaderValue(new String("Description"));
colModel.getColumn(2).setCellRenderer(new ABSINumberRenderer());
colModel.getColumn(3).setHeaderValue(new String("Status"));
colModel.getColumn(4).setHeaderValue(new String("Default"));
How can i see the new column that i added in the view? -
How to loop through columns of a table?
Hi, guys
Is there a way to loop through each column of a table? If there is a way, then how?
I have a table with columns of different datatypes , and I want to set default values for each column with a loop but don't know how to make it happen.
For example,
Table: Employees
declare
rec Employees%ROWTYPE;
begin
for col in rec.empno .. rec.location loop
if col = rec.empno then -- set default value for column empno;
end loop;
end;
/Sorry, I am a newbie to PL/SQL. Please help!
Thanks in advance.
Edited by: HappyJay on 2010/05/11 10:36Hi,
You can query the data dictionary views all_tab_columns (or user_tab_columns) to get the names of all the columns in a particular table.
Here's an easy way (but not a very efficient way) to loop through them:
SET SERVEROUTPUT ON
BEGIN
FOR c IN ( SELECT column_name
FROM all_tab_columns
WHERE owner = 'SCOTT' -- Remember ot use UPPER CASE inside quotes
AND table_name = 'EMP'
LOOP
dbms_output.put_line (c.column_name || ' = column_name inside loop');
END LOOP;
END;
/I'm confused about what you want to do, though.
Do you want the PL/SQL code to write and/or execute an ALTER TABLE command for each column? -
Hi my name is vishal
For past 10 days i have been breaking my head on how to make column headers in table appear bold while datas in table appear regular from c# windows forms with sql server2008 using iTextSharp.
Given below is my code in c# on how i export datas from different tables in sql server to PDF report using iTextSharp:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.Diagnostics;
using System.IO;
namespace DRRS_CSharp
public partial class frmPDF : Form
public frmPDF()
InitializeComponent();
private void button1_Click(object sender, EventArgs e)
Document doc = new Document(PageSize.A4.Rotate());
var writer = PdfWriter.GetInstance(doc, new FileStream("AssignedDialyzer.pdf", FileMode.Create));
doc.SetMargins(50, 50, 50, 50);
doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width, iTextSharp.text.PageSize.LETTER.Height));
doc.Open();
PdfPTable table = new PdfPTable(6);
table.TotalWidth =530f;
table.LockedWidth = true;
PdfPCell cell = new PdfPCell(new Phrase("Institute/Hospital:AIIMS,NEW DELHI", FontFactory.GetFont("Arial", 14, iTextSharp.text.Font.BOLD, BaseColor.BLACK)));
cell.Colspan = 6;
cell.HorizontalAlignment = 0;
table.AddCell(cell);
Paragraph para=new Paragraph("DCS Clinical Record-Assigned Dialyzer",FontFactory.GetFont("Arial",16,iTextSharp.text.Font.BOLD,BaseColor.BLACK));
para.Alignment = Element.ALIGN_CENTER;
iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance("logo5.png");
png.ScaleToFit(105f, 105f);
png.Alignment = Element.ALIGN_RIGHT;
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=DRRS;Integrated Security=true");
SqlCommand cmd = new SqlCommand("Select d.dialyserID,r.errorCode,r.dialysis_date,pn.patient_first_name,pn.patient_last_name,d.manufacturer,d.dialyzer_size,r.start_date,r.end_date,d.packed_volume,r.bundle_vol,r.disinfectant,t.Technician_first_name,t.Technician_last_name from dialyser d,patient_name pn,reprocessor r,Techniciandetail t where pn.patient_id=d.patient_id and r.dialyzer_id=d.dialyserID and t.technician_id=r.technician_id and d.deleted_status=0 and d.closed_status=0 and pn.status=1 and r.errorCode<106 and r.reprocessor_id in (Select max(reprocessor_id) from reprocessor where dialyzer_id=d.dialyserID) order by pn.patient_first_name,pn.patient_last_name", conn);
conn.Open();
SqlDataReader dr;
dr = cmd.ExecuteReader();
table.AddCell("Reprocessing Date");
table.AddCell("Patient Name");
table.AddCell("Dialyzer(Manufacturer,Size)");
table.AddCell("No.of Reuse");
table.AddCell("Verification");
table.AddCell("DialyzerID");
while (dr.Read())
table.AddCell(dr[2].ToString());
table.AddCell(dr[3].ToString() +"_"+ dr[4].ToString());
table.AddCell(dr[5].ToString() + "-" + dr[6].ToString());
table.AddCell("@count".ToString());
table.AddCell(dr[12].ToString() + "-" + dr[13].ToString());
table.AddCell(dr[0].ToString());
dr.Close();
table.SpacingBefore = 15f;
doc.Add(para);
doc.Add(png);
doc.Add(table);
doc.Close();
System.Diagnostics.Process.Start("AssignedDialyzer.pdf");
if (MessageBox.Show("Do you want to save changes to AssignedDialyzer.pdf before closing?", "DRRS", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) == DialogResult.Yes)
var writer2 = PdfWriter.GetInstance(doc, new FileStream("AssignedDialyzer.pdf", FileMode.Create));
else if (MessageBox.Show("Do you want to save changes to AssignedDialyzer.pdf before closing?", "DRRS", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation) == DialogResult.No)
this.Close();
The above code executes well with no problem at all!
As you can see the file to which i create and save and open my pdf report is
AssignedDialyzer.pdf.
The column headers of table in pdf report from c# windows forms using iTextSharp are
"Reprocessing Date","Patient Name","Dialyzer(Manufacturer,Size)","No.of Reuse","Verification" and
"DialyzerID".
However the problem i am facing is after execution and opening of document is my
column headers in table in pdf report from
c# and datas in it all appear in bold.
I have browsed through net regarding to solve this problem but with no success.
What i want is my pdf report from c# should be similar to following format which i was able to accomplish in vb6,adodb with MS access using iTextSharp.:
Given below is report which i have achieved from vb6,adodb with MS access using iTextSharp
I know that there has to be another way to solve my problem.I have browsed many articles in net regarding exporting sql datas to above format but with no success!
Is there is any another way to solve to my problem on exporting sql datas from c# windows forms using iTextSharp to above format given in the picture/image above?!
If so Then Can anyone tell me what modifications must i do in my c# code given above so that my pdf report from c# windows forms using iTextSharp will look similar to image/picture(pdf report) which i was able to accomplish from
vb6,adodb with ms access using iTextSharp?
I have approached Sound Forge.Net for help but with no success.
I hope anyone/someone truly understands what i am trying to ask!
I know i have to do lot of modifications in my c# code to achieve this level of perfection but i dont know how to do it.
Can anyone help me please! Any help/guidance in solving this problem would be greatly appreciated.
I hope i get a reply in terms of solving this problem.
vishalHi,
About iTextSharp component issue , I think this case is off-topic in here.
I suggest you consulting to compenent provider.
http://sourceforge.net/projects/itextsharp/
Regards,
Marvin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Dynamically Hiding Column in a Table View in VC Model
How to dynamacally hide the columns in a table view in a VC model. Through the expression in Control Property, Form element/field or table view as a whole can be made hidden, however, the individual column can not seem to be hidden.
I am using VC server version 700.8.0.1.
Any help would be much appreciated.
Kind Regards
SanjoyIn this scenario, if the source is SAP BI, you can use the webapi commands. If not, you would have to have 2 separate tables in different layers and you can show and hide those layers or UI elements...
Maybe you are looking for
-
How damaged is my macbook pro?
I have a mid 2010 Macbook pro with Snow Leopard... I was using some rubbing alcohol to clean my keyboard and it quit working. It just makes the error noise whenever I try to tap a key. If I boot it up using the shift,alt and apple key method I can ge
-
Regarding the function module.
hi, iam using a function module in my program GET_PRINT_PARAMETERS the program is going to dump. iam not understood why it is going to dump. please provide me the solution for this issue thanks in advance
-
Never got the text message or email
Hello ronin7- Thank you for clarifying that the promotion you are referencing is in regards to the Mover's Coupon. I'm sorry to hear you did not receive the activation code to your Mover's Coupon in a text message or email. I would like to look furth
-
hello, I have coded a mathematical c++ solver that take input data in json file , and I want to execute it on cloud within a client application. Is these steps right? 1- create an azure service that hos my solver. 2- Create a client application that
-
SB Live! 5.1 Digital Install Probl
I can't get drivers for my Sound Blaster Li've! 5. (SB0060) S/N: IS006035673203056 WindowsXP detects the card because it installs its own drivers... (Creative AudioPCI (E37, E373)(WDM)) And I know I don't have that by physically looking at the card.