출처 : http://yatoyato.tistory.com

vb :: 비주얼베이직이란?

 Visual Basic의 "Visual"이란 사용자로 하여금 Windows프로그램을 쉽게 이해하고, 쉽게 사용할 수 있도록 그래픽 인터페이스(GUI)사용하는 방법을 말한다. 인터페이스란 사용자가 시스템을 원활히 사용할 수 있도록 시스템과 사용자간에 제공되는 환경을 말하며, 사용자 인터페이스는 주로 입출력 장치와 대화형 언어체계를 포함한다. 즉, 인터페이스의 모양과 위치를 작성하는 데 있어 수많은 코드를 작성하는 것보다, 간단하게 미리 만들어져 있는 개체를 마우스의 드래그(drag)와 드롭(drop)기능을 사용하여 스크린위에 배치시키면 된다.
 "Basic"이란 전산의 역사상 프로그래머들에 의해 다른 언어보다 더 많이 사용된 BASIC(Beginners All-Purpose Symbolic Instruction Code)언어를 말한다. Visual Basic은 원래의 BASIC언어에서 발전하여 지금은 수백개의 문, 함수, 키워드를 가지고 있고, 그 중 많은 부분이 Windows GUI와 직접 관련되어 있다. 초보자들은 키워드 몇 개만 배우면 유용한 응용프로그램을 만들 수 있으며, 프로그래머들은 다른 Windows프로그래밍언어를 사용하여 이룰 수 있는 모든 것을 할 수 있다.

#VB응용프로그램 개발 단계
Visual Basic에서 응용프로그램을 작성하기위해 다음의 세가지 주요단계가 필요하다.

- 1단계 인터페이스 만들기
사용자와 컴퓨터간에 상호정보를 주고받기위한 기초작업을 하는 단계이다.
인터페이스는 응용프로그램 개발의 첫 단계로, 폼은 인터페이스의 기초가 된다. 집짓는 것에 비유하자면 폼은 집터가 될 것이고, 도구상자에 있는 컨트롤들은 각종 건축자재에 해당할 것이다. 컨트롤을 폼에 추가시키는 것은 프래임같은 개체를 컨테이너안에 그룹화시킬 필요가 있을 때 사용한다.

- 2단계 속성설정
각 개체에 대해 이름을 지정해 주거나 색깔, 모양, 개체위치, 개체크기등의 속성을 설정해주는 단계이다.
두번째 단계로 개체에 속성을 부여한다. 이것도 인간이 집을 만들때, 용도에 맞게 방의 크기도 정하고, 또한 방의 위치도 생각할 것이다.
그리고 난 다음 집을 짓고, 명패를 달고, 색깔도 칠하는 등 여러가지 부속작업을 하는 것에 비유할 수 있다.  이러한 속성을 설정하기 위해 비주얼베이직은 속성창이라는 것을 제공하고 있다. 속성창은 폼뿐만 아니라 폼 내에 있는 모든 컨트롤의 속성을 설정할 수 있도록 속성목록을 제공하고 있다.
폼뿐만 아니라 모든 컨트롤에 이름을 굳이 다시 부여하지 않아도 되지만, 이렇게하면 혼동되기 쉽다. 예를 들어, 하나의 프로젝트에 10개의 폼이 존재한다고 가정하자. 비주얼베이직은 폼 추가 순서대로 폼의 이름을 form1, form2, form3 ... 이런 식으로 부여하게 된다. 이 중 form3가 하는 일이 네트워크의 로그인 폼이라고 하자. 비주얼베이직의 특징중의 하나가 개체의 재활용이다. 즉 기존에 있던 프로젝트뿐만 아니라 폼, 모둘 등은 언제든지 필요하다면 다시 불러 쓸 수 있다는 것이다. 이러한 특징을 이용해 다른 프로젝트에서 네트워크 로그인 역할을 하는 기존의 폼을 쓰기 위해 하드디스크에서 찾을 것이다. 그러한 폼의 이름이 form1.frm, form2.frm ... 식으로 되어있다면 찾기 힘들 것이다.
그러나, 만약 form3대신 frmLogin이라고 이름을 부여했다면, 앞의 접두어 frm때문에 다른 개체와 확연히 구분될 뿐만 아니라 이름에 의미가 있기때문에 쉽게 찾아 사용할 수 있다. 이러한 이유때문에 개체종류를 나타내는 접두어를 의미있는 이름과 사용하는 것이 나중에 좋다.

- 3단계 코드쓰기
개체에 이벤트가 발생하면 수행해야 할 일을 적어두는 단계이다.
속성설정만으로 완전히 어플리케이션이 될 수는 없다. 모든 어플리케이션의 생명은 바로 코드작성에 있다. [코드창]은 비주얼베이직 코드를 작성할 수 있는 곳으로 코드는 언어문장, 상수, 선언문으로 구성되어 있다.
비주얼베이직에 있는 모든 코드는 프로시저(Procedure)라고하는 작은 단위로 이루어진다. 하나의 이벤트 프로시저(Event Procedure)에는 어떤 사건 발생시 수행하는 코드를 포함하게 된다.

Posted by 나비:D
:
출처 :http://cafe.naver.com/2007jsp.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=580

-- 먼저 로그인을 합니다.

% sqlplus /as sysdba

-- 오라클 시작 및 종료

SQL>startup restrict;    open까지 실행하고 일반사용자는 사용할 수 없음
SQL>startup force;       자동종료후 다시시작
SQL>startup nomount;
SQL>alter database mount;
SQL>alter database open;

-- 간단하게 하고 싶다!!!!
SQL>startup
SQL>shutdown abort

-- 디비에 뭐가 있나??

SQL>select * from v$database;

SQL>select * from all_users; 현재 생성된 사용자
SQL>select * from v$sga;

SQL>show sga   메모리 사용보기
SQL>show parameter;
SQL>select * from dba_users;

-- 사용자 생성, 변경, 삭제
%sqlplus system/manager
SQL>create user 사용자indetified by 암호
     2>default tablespace system  ( <- 별로 안좋은 설정. tablespace 만들고 한다. )
     3>temporary tablespace temp

     4>quota 1M on system;

변경
SQL>alter user 사용자 identified by 암호;

삭제
SQL>drop user 사용자 cascade; (가지고 있는 모든객체화 함께 삭제)

권한과 룰
create session, table, index, view, sequence, cluster
drop  " 
alter  "

grant [시스템권한] to [사용자명] with admin option;


보통은 사용자 추가후...

grant resource, connect to 사용자;  로 사용한다고 하더라

-- 전체테이블보기
select table_name from dba_tables

--제약조건 확인
SQL>select * from user_constrainsts where table_name='EMP';

-- 각테이블의 컬럼내용보기
SQL>desc [table_name];

-- 똑같은 구조의 테이블작성
SQL>create table emp_temp as select * from emp;

-- user 테이블스페이스

테이블스페이스 생성
SQL>create tablespace insa datafile '/disk2/oracle/insa_01.dbf'(절대경로/파일이름) size 1M;

테이블스페이스 크기추가
SQL>alter tablespace insa add datafile '/disk2/oracle/insa_02.dbf' size 1M;

데이터 파일 크기 변경
SQL>alter tablespace insa datafile '/disk2/oracle/insa_01.dbf' resize 3M;

데이터 파일 자동변경
SQL>alter tablespace insta datafile '/disk2/oracle/insa_02.dbf'
     2>autoextend on next 1M maxsize 10M;

테이블 스페이스삭제
SQL>drop tablespace insa including contents;
SQL>exit 한후에 디렉토리의 화일을 직접삭제...

-- 기본테이블스페이스
SQL>create user gracian identified by gracian1234 default tablespace system;

현재 기본테이블스페이스확인
SQL>select username, default_tablespace from dba_users;

 로컬리 테이블스페이스
SQL>create tablespace account datafile '/disk1/oracle/account_01.dbf' size 1M
     2>extent management local uniform size 50k;

Posted by 나비:D
:
CLOB을 VARCHAR로 변환
dbms_lob.substr을 사용한다.

dbms_lob.substr( clob_column, for_how_many_bytes, from_which_byte );

select dbms_lob.substr( x, 4000, 1 ) from T;

PLSQL에서는 long형 변수에 할당하여 변환할 수 있다.


declare
    my_var long;
begin
    for x in ( select X from t )
    loop
       my_var := dbms_lob.substr( x.X, 32000, 1 );
       ....
Posted by 나비:D
:
출처 : http://gipsi.egloos.com/968963
Oracle Package 사용법-VB
CREATE OR REPLACE PACKAGE pk_test AS
TYPE t_cur IS REF CURSOR RETURN test%ROWTYPE;
PROCEDURE sp_test(v_cur OUT t_cur);
END pk_test;
/

CREATE OR REPLACE PACKAGE BODY pk_test AS
PROCEDURE sp_test(v_cur OUT t_cur) IS
BEGIN
OPEN v_cur FOR SELECT * FROM test;
END sp_test;
END pk_test;
/



Set Spcmd = New ADODB.Command
Spcmd.ActiveConnection = cnn
Spcmd.CommandType = adCmdStoredProc
Spcmd.CommandText = "pk_test.sp_test" '패키지명.프로시져명
Spcmd.Parameters(0).Direction = adParamOutput '받는 파라미터명
Set rst = Spcmd.Execute



* 다른 방법
-- 패키지머리 생성(정의)
CREATE OR REPLACE PACKAGE pk_test AS
TYPE t_cur IS REF CURSOR; --리턴받을 변수에 타입선언
PROCEDURE sp_test(i_table in varchar2,v_cur OUT t_cur); --수행할 프로시져 선언
END pk_test;
/

-- 패키지몸체 생성
CREATE OR REPLACE PACKAGE BODY pk_test AS
PROCEDURE sp_test(i_table in varchar2,v_cur OUT t_cur) IS
BEGIN
OPEN v_cur FOR 'SELECT * FROM '||i_table; --다이내믹 커서사용
END sp_test;
END pk_test;
/


VB사용시 예제>>
Private cnn As ADODB.Connection
Private rst As New ADODB.Recordset

Set Spcmd = New ADODB.Command '새 객체 생성
Spcmd.ActiveConnection = cnn '연결
Spcmd.CommandType = adCmdStoredProc '프로시져형태
Spcmd.CommandText = "pk_test.sp_test" '패키지프로시져명
Spcmd.Parameters.Append Spcmd.CreateParameter("i_table", adVarChar,
adParamInput, 10, "emp") '입력파라미터
Spcmd.Parameters(1).Direction = adParamOutput '출력파라미터
Set rst = Spcmd.Execute '수행
Posted by 나비:D
:
출처 : http://www.planetsourcecode.com/URLSEO/vb/Discussion/AskAProShowPost!asp/lngTopicId!33566/TopicCategory!XML_XSL+Questions/Flag!2/lngWId!1/blnURLSEO!true/Posting.htm

This isn't a question but a solution I found something that is worth a share here at this forum.

It had been a tedious job to handle CLOB data returned from Oracle 8i Stored Procedure into VB6 \ Visual Basic 6 using Microsoft ODBC. The support provided for handling CLOB is ONLY for SQL QUERIES where you fire to SELECT\INSERT\DELETE\UPDATE a CLOB COLUMN from a table, but NOBODY has really bothered about a RETURN VARIABLE as CLOB from ORACLE STORED PROCEDURE. Search on internet but it's useless.

I had this particular Stored Proc that was accepting a Key and depending on that Key, it would FETCH Data, and Make an XML string. This XML would extend upto 40-50K characters which is really large for VARCHAR2 \ LONG datatype to single handedly manage in oracle. Hence I had to use CLOB, but in VB (ADO 2.8) there was no associated DATATYPE or data-structre support that would accept this return value from my stored proc. (adVariant was most perfect but that is useless too)

.... (Poor Me I would bang my head against PC monitor that would show me sites providing help on CLOB Table, Oracle ODBC for CLOB or even CLOB JDBC support in JAVA but they would make me more helpless)

This is what I was doing

# Oracle Code


PROCEDURE GetXML
(temp IN NUMBER,
OutputXML OUT CLOB)
IS
--.....Variable Declaration
BEGIN
OutputXML :=EMPTY_CLOB();
DBMS_LOB.CREATETEMPORARY(OutputXML,TRUE);

stCurrentXMLNode := ''; --Load XML Denotion
--Code to get data, make XML and store into CLOB variable goes here....
DBMS_LOB.WRITEAPPEND(OutputXML, LENGTH(stCurrentXMLNode),stCurrentXMLNode); --Finally complete Loading Data in OUTPUT CLOB
COMMIT;
END GetXML;

But VB 6 was not supporting this OUT CLOB parameter OutputXML and would throw Microsoft ODBC inconsistent Datatype or Access Violation Error for every datatype I tried (VB adDataypes)

Then what I did is divided this collected CLOB in distinct ARRAY (Table) of VARCHAR2 variables of some fixed size(say 4000) Using this code

CREATE OR REPLACE PACKAGE BODY MYPACKEGE
AS
TYPE tblXML IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER; --VRACHAR2 ARRAY Table

PROCEDURE GetXML
(temp IN NUMBER,
OutputXML OUT tblXML)
IS
--.....Variable Declaration
BEGIN
OutputXML :=EMPTY_CLOB();
DBMS_LOB.CREATETEMPORARY(OutputXML,TRUE);

stCurrentXMLNode := ''; --Load XML Denotion
--Code to get data, make XML and store into CLOB variable goes here....
DBMS_LOB.WRITEAPPEND(OutputXML, LENGTH(stCurrentXMLNode),stCurrentXMLNode); --Finally complete Loading Data in OUTPUT CLOB

--********************************************************---
output_var := ' '; -- NonEmpty String
offset_var := 0; -- Offset To start chopping with
amount_var := 4000; -- Fixed SIze Varchar2

nCount := 0;
WHILE output_var <> ''
LOOP
DBMS_LOB.READ(OutputXML,amount_var,offset_var,output_var);
--Load character Chunk 'output_var' Cut from previous statement into Array element
OutputXML(nCount) := output_var;
nCount := nCount + 1;
offset_var:= amount_var + offset_var + 1;
END LOOP;
--********************************************************---
COMMIT;
END GetXML;
End MYPACKAGE;

Now use following VB 6 code to load this into a Recordset, then loope thru recordset and load it into a String (max size 65K characters) or variant(max size 2G Characaters)

# VB Code

Dim objCmd As New ADODB.Command
Dim objRS As New ADODB.Recordset

Dim vXML As Variant
With objCmd
.ActiveConnection = "{Microsoft ODBC DSN \ ConnectionString}"
.CommandType = adCmdText
.CommandTimeout = 30
.CommandText = "{call MYPACKAGE.GetXML(?, {resultset 10000, OutputXML})}"
.Parameters.Append .CreateParameter("temp", adNumeric, adParamInput, , 1234) 'Input Paramneter

Set objRS = .Execute 'Load Output VARCHAR2 Array into RecordSet

vXML = ""
While Not objRS.EOF
vXML = vXML & objRS(0).Value 'Loading Large CLOB (by looped appending) into a Variant
objRS.MoveNext
Wend
End With

vXML variable has your CLOB now ....

What Say ...
Posted by 나비:D
:

Build an Online Reporting Application Using Oracle XML Publisher


by Mark Rittman

Learn how to create an online reporting environment using XML Publisher technology, step by step.

Published June 2006

Part of the Oracle Fusion Middleware family of products, Oracle XML Publisher 5.6.2 is a Java-based product that gives you the ability to define, publish, secure and schedule reports built using SQL and XML data sources. Originally developed as a technology within E-Business Suite, Oracle XML Publisher is now available for download as a stand-alone product, and can be deployed using J2EE application servers such as Oracle Application Server Containers for J2EE (OC4J) or Apache Tomcat. Best of all, XML Publisher uses familiar desktop tools such as Microsoft Word and Adobe Acrobat to define report layouts, meaning that users can design their reports in a familiar environment without having to install and learn a whole new toolset.

XML Publisher consists of a server-based reporting engine that brings together report templates, the data that you wish to report on and any language translations, and then distributes the output in standard formats such as Adobe PDF, HTML, XML, RTF or Microsoft Excel.

Figure 1

Creating a clear separation between data, layout, and interface makes it easier to report the same data in different formats, easier to maintain a library of report definitions, and more straightforward to introduce features such as multiple language translation. XML Publisher is a standalone product that, like the rest of Oracle Fusion Middleware architecture, is “hot-swappable” and integrates with any standards-based database or Java application server.

New with the 5.6.2 release of XML Publisher is XML Publisher Enterprise, a complete environment for deploying, scheduling, and securing your reports. XML Publisher Enterprise provides users with a Web portal where they can upload their report templates, publish them, and then make them available to other users and groups within the organization.

XML Publisher uses a scheduling engine based on the OpenSymphony Quartz scheduler to run and then deliver reports that can then be accessed online, via email or via a WebDAV-enabled server.

So, now that XML Publisher 5.6.2 Enterprise is available, how can you use it to build an online reporting application?

Background

In this example, you will create an online reporting environment for your organization. You will create the initial set of reports that your colleagues will use, and you users will then maintain them and create ones of their own. Key requirements are that the reporting environment is Web-based, secure, and easy for users to navigate and use, reports can be run on demand or scheduled for regular execution, and users can export the data from their reports into familiar desktop application formats such as Microsoft Excel and Adobe Acrobat.

Your initial audience for reports consists of purchasing department users, who wish to view reports on vendor invoices, and a sales manager, who wishes to analyze sales data within his Web browser and through Microsoft Excel.

In these examples, the sales data that you will report on is held in the SH sample schema shipped with Oracle9i Database and Oracle Database 10g, whilst the vendor invoices data will be provided via an XML feed from your transactional application. To create your own report layout, download the SQL query and sample of the XML file here.

Defining an SQL-based Sales Analysis Report

The first report you will create will be the sales report, using data from the SH Sample Schema. To begin the process, you open up your Web browser and log on to XML Publisher Enterprise, so that you start to put together your report definition. After entering your username and password successfully, you view the XML Publisher Enterprise home page.

Figure 2

Down the left-hand side of the Web page is a tasks pane that contains links to create a new folder or report, or upload an existing report. On the right-hand side of the page is a set of sample reports shipped with XML Publisher Enterprise.

You click on the Create a new folder link to create a folder for the reports you are about to define, and call it “Sample Reports.” Grouping reports like this makes it easy to separate them out into subject areas, and you can later on specify which users and groups are able to access individual folders and reports.

Figure 3

You then navigate to the folder that you have just created, and click on the link to create a new report, which you call “sales report.” Once the report is created, you are presented with options to view, schedule, edit or view the execution history of the report.

Figure 4

Now that you have created the report, you need to edit the definition in order to specify the data model, any parameters the report might use and the report layout. To do this, you click on the Edit link under the report title. XML Publisher Enterprise then brings up a dynamic HTML interface that presents the report definition elements in a tree view.

Figure 5

An XML Publisher report definition comprises several elements:

  • The data model, which refers to either a database query or an XML document
  • The report template, which you will define later using XML Publisher Desktop
  • Any parameters used by the report, and
  • Any lists of values for the parameter drop-down lists

These four elements collectively form the report definition, which XML Publisher then holds in XML format on the application server mid-tier.

Next, you click on the Data Model node on the report tree view, click on the New button to create a new data model, and then select the JDBC data source that connects to your database. If one does not already exist, you will need to click on the Admin link at the top of the page to define a JDBC connection.

Figure 6

Once the data source is selected, you then press the New Query Builder button to choose the data items that will be returned from your database connection. The Query Builder gives you the ability to make a selection of database tables and columns using a graphical user interface.

Figure 7

Once you have made your data selection, you then add the join conditions and any other elements you would like to add to your query and then save it to XML Publisher Enterprise.

Figure 8

Now that you have defined your data model, it is time to layout your report template.

Report templates define how your data elements are arranged on the page, and unlike ad hoc query tools such as OracleBI Discoverer your template can be completely free form and include data from multiple queries. With XML Publisher, you define your report templates using standard desktop tools such as Microsoft Word and Adobe Acrobat, and the standard download of XML Publisher 5.6.2 includes an add-in to Microsoft Word called XML Publisher Desktop that automates much of the process of setting up the template. In these examples, you will use Microsoft Word and XML Publisher Desktop, an add-in to Microsoft Word, to define your templates. (A Flash demo that illustrates this process for a Word template is available here.)

Once you have installed XML Publisher Desktop, you will see an additional toolbar menu that provides access to XML Publisher functionality. As your first report is based on data accessed via an SQL query, you access the Data menu and then select Report Wizard.

Figure 9

You then step through the wizard, specifying the SQL query used to retrieve the data, the JDBC connection details of your database, and the name of the data source that you used when working in XML Publisher Enterprise

Figure 10

Once the wizard has completed, you are then presented with the default layout for your data items.

Figure 11

You can now use the formatting features in Microsoft Word to change the format of your table, add report headers and footers, change the fonts that are used, and add your organization’s branding. Although you can remove and reorder columns within the default report layout, for this report you decide to keep with the full set of columns as you intend to export the dataset later on into Microsoft Excel for further analysis.

You decide that this report would be even more effective with a chart to accompany it. Using XML Publisher Desktop this is a simple operation that is started via the Chart menu item on the Insert menu, which will then bring up the Chart dialog.

Figure 12

Using the Chart dialog, you specify a Vertical Bar Chart with Amount Sold grouped by Product Category.

Figure 13

Now, when you view your report template, a picture of a sample chart that represents your bar chart accompanies your table.

Figure 14

After previewing this template using the Preview menu item, you then save it to your PC as an RTF file ready for uploading to XML Publisher Enterprise.

To do this, you first of all click on the Layouts node of the report tree view, then click on New, and name your report layout.

Figure 15

Then, after clicking back on the Layouts node, you select the RTF file that contains your template and upload it to XML Publisher Enterprise.

Figure 16

Finally, just to test that your report works, you save the report definition, return to the report options and click on View to run the report.

Figure 17

Defining a Vendor Invoices Template Based On XML Data

The second report you wish to produce will take its data from an XML feed from your transactional system. Like your SQL-based report, the first step in creating this report is to log on to XML Publisher Enterprise to create a new report definition, which you name “Vendor Invoices.”

Figure 18

After entering the name of the report, as with the previous report you are then presented with options to view the report, schedule it, view the history of previous executions or edit its definition.

Figure 19

Next, as before, you click on the Edit link and begin the report definition process.

Using the Web interface, you first define the location of the feed that will provide your XML data, which in this case will be accessed via HTTP from your transactional application Web server.

Figure 20

If your report uses any parameters and any lists of values, you can add them at this stage. However your report does not use any parameters and so you click on the Layouts menu item and upload the report template you defined earlier.

Then, as with the sales report, you start XML Publisher Desktop so that you can define your report template. Unlike the sales report that was based on an SQL query, the vendor invoices report is based on an XML feed, and you therefore obtain an extract of this data feed as an XML document. As an alternative to an extract XML document, which may not contain all of the data elements that you might want to include in your template, you can instead base your template on an XML schema that fully defines the elements in your report, although of course this will not contain actual data and any previews you generate will contain data structures only.

For this template, you therefore initially load in your data using the XML Document entry in the XML Publisher Desktop Data menu.

Figure 21

Once XML Publisher Desktop confirms that the document is loaded, you can use the Insert menu to layout your template. Unlike the Report Wizard you used earlier, with XML data you are initially presented with a blank page, and it is up to you to add data items to the template.

For this template, you wish to list out the invoices grouped by the vendors that your organization deals with. To do this, you select Table/Form and then Advanced… from the Insert menu, and then individually select grouping items and table rows using the Insert Table/Form dialog.

Figure 22

Once you have selected your data items and grouped by vendor details, you can then format the resulting table, add your company branding, and then preview the results as a PDF file.

Figure 23

Then, once you are happy with the layout, you upload the template file to XML Publisher Enterprise, and run the report. This time, the report will take its data from the XML feed from your transactional application. Notice how the user can change the output format from HTML to PDF, XML, Microsoft Excel and XML.

Figure 24

Analyzing Your Sales Data

Some of your users may wish to further analyze their sales data to spot opportunities and uncover hidden trends. XML Publisher 5.6.2 Enterprise comes with an online analysis facility that gives your users the ability to analyze their data using just their Web browser.

To demonstrate this functionality, you navigate back to your sales report, run the report and then click on the Analyze button at the top right-hand side of your report. XML Publisher 5.6.2 Enterprise then presents you with a pivot table style interface that lets you drag and drop data elements onto a crosstab, in a similar style to an OracleBI Discover worksheet.

Figure 25

You drag the channel description field onto the Y-axis of the crosstab, and then drop the channel class item on top of it to nest the first item within the second. You do the same with Product Subcategory and Product Category, and drop Calendar Year into the Page Items area to allow users to “page through” years of data. Finally, you add Quantity Sold to the Data Items area and view the resulting page.

Figure 26

XML Publisher indexes and “rotates” the data from your report on the application mid-tier, and therefore there’s no extra load on your database or transactional system whilst you do this online analysis.

For users who would rather do their analysis using the familiar spreadsheet tool Microsoft Excel, the Excel Analyzer button starts your local copy of Microsoft Excel, installs a plug-in if it’s not already been downloaded, and then loads your report into an Excel worksheet. Using this plug-in, you can re-query the report using new parameter values, refresh the report with new data, and base additional worksheets off this data and include it in other calculations and graphs.

Report Scheduling and Distribution

Sometimes you might wish to schedule a report for later execution, or you might wish it to execute on a regular basis and distribute the results to a group of users. You wish to distribute your vendor invoice report on a weekly basis, and so you press the Schedule button at the top of the report to set this up. Before you do this though, you will need to have defined one or more delivery options using the Admin tab of XML Publisher 5.6.2 Enterprise.

To setup your schedule, you select one or more delivery destinations, which in the case of this report is an email message to the purchasing managers in your organization.

Figure 27

Using the Web interface, you give the scheduled job a name, and an email address to send notification through if the job should fail or complete with errors. The scheduler within XML Publisher 5.6.2 Enterprise gives you the option to run the job now, once in the future, or on a regular daily, weekly or monthly basis; you set the job up to run each Monday at 07:00 hours, with the report sent to an email distribution list and to yourself as a copy.

Granting Access to Users and Groups

The requirement from your organization is that only staff within the Purchasing Department should view the Vendor Invoices report, and other reports based on purchasing information, while sales reports should be viewable only by members of the Sales Department. Your online reporting application must reflect these security choices.

Within XML Publisher 5.6.2 Enterprise, individual users can belong to one or more roles, and roles can be granted access to one or more folders. This security can be made more granular by creating subfolders within other folders, and then using the copy report and paste report feature in XML Publisher 5.6.2 Enterprise to move your reports to the relevant subfolder.

Figure 28

Once your reports are in the correct folder, you then grant access to these folders to the relevant XML Publisher groups.

Figure 29

These roles, users and permissions are held internally within XML Publisher 5.6.2 Enterprise, but can be integrated with other LDAP servers.

Enhancing Your Templates

So far you have built two reports that are fairly simple to design and understand. You have used the wizards in Microsoft Word to lay out your template, and uploaded them to XML Publisher 5.6.2 Enterprise to be run online. But what if your requirements are more complex?

Most XML Publisher templates are created as RTF files which are then processed by the XML Publisher RTF Template Parser and converted into XSL-FO. When you design your report template using Microsoft Word, the wizards add data fields and other markup to your template using XML Publisher’s simplified tags for XSL expressions. These tags associate the XML report data to your report layout. If you are familiar with XSL and prefer not to use the simplified tags, XML Publisher also supports the use of pure XSL elements in the template.

In addition to Microsoft Word’s formatting features, XML Publisher supports other advanced reporting features such as conditional formatting, dynamic data columns, running totals, and charts. If you wish to include code directly in your template, you can include any XSL element, many FO elements, and a set of SQL expressions extended by XML Publisher. For more details, see the Oracle XML Publisher Enterprise User’s Guide that contains full details on how to extend XML Publisher templates.

Conclusion

XML Publisher 5.6.2 Enterprise is a complete environment for designing, building and running reports against both XML and SQL data. Using XML Publisher 5.6.2 Enterprise, you can design report layouts using familiar tools such as Microsoft Word and Adobe Acrobat, and deliver reports to your organization’s users using a secure, user-friendly Web-based environment.


Mark Rittman is a certified Oracle Database administrator and director of consulting at SolStonePlus, an Oracle partner based in the U.K. that specializes in business intelligence and data warehousing. He is the Oracle Magazine Editors' Choice ACE of the Year 2005, is chair of the U.K. Oracle User Group Business Intelligence & Reporting Tools SIG, and runs a blog at www.rittman.net.

출처 : 오라클

<
Posted by 나비:D
:

How can return XML from a stored procedure using VB? (10762 Requests)

I've gotten quite a few requested for an example using a stored procedure instead of a template. So this example uses a regular stored procedure.

  1. Create a new EXE project in VB.
  2. Add references to MSXML 4.0 and ADO 2.6
  3. Create the stored procedure listed below.
  4. Copy the code below into your form's code. Be sure to change the connection string.

Stored Procedure

create proc employee_get
(
	@id int
)
as

	select 	FirstName, 
		LastName, 
		Title,
		Region
	from 	employees
	where	employeeid = @id
	for xml auto

go

VB Code

Dim oCmd As Command
Dim oPrm As Parameter
Dim oDom As IXMLDOMDocument2
   
Set oDom = New DOMDocument40
   
Set oCmd = New Command
oCmd.ActiveConnection = "Provider=SQLOLEDB; Data Source=; " & _
    "User ID=; Password=; Database=Northwind"
       
oCmd.CommandText = "employee_get"
oCmd.CommandType = adCmdStoredProc
    
Set oPrm = New Parameter
oPrm.Name = "@id"
oPrm.Value = "1"
oPrm.Type = adInteger
oPrm.Size = 4
oCmd.Parameters.Append oPrm
        
oCmd.Properties("Output Stream") = oDom
oCmd.Execute , , 1024

oDom.Save "c:\temp\results.xml"
    
Unload Me

Other Resources:
Returning XML in VB with a template

HOWTO: Retrieve XML Data by Using a SQL XML Query in a Visual Basic Client

HOWTO: Retrieve XML Data with a Template File from a Visual Basic Client

Posted by 나비:D
:

제목

ORACLE - SQL 레코드를 XML로 쉽게 변환하기

작성자

DEV.WON ( http://blog.naver.com/jadin1 )

작성일

2007-06-07

배포

PUBLIC (, 출처는 밝혀 주세요)

들어가기전 잡담.)

날씨가 더워지네요.. 더불어 4학년인 필자도 슬슬 졸업이 다가옵니다. 4학년1학기^^;;;

필자는 요즘 RoR에 빠졌습니다.

프레임워크 XML세팅에 슬슬 짜증이나던 찰나에, 에자일 방법론 이론에 가장 충실할거같다는 생각이 들어 접하게 된

Ruby On Rails .. Ruby의 언어적 이질감이 처음에는 압박이었으나, 모 나름대로 잼있네요..

솔직히 Java의 강력함과 오픈소스...뒤에 은근슬쩍생산성에 대한회의감이 드는 이유는 몰까요?

DB 엔티티 하나 고치게 되면 쭉이어지는 xml 설정값 , 어트리뷰트 들의 코드 수정들..ㅜㅜ

솔직히 그동안 필자는 왠지 인터프리터 방식의 스크립트에 대해 '몬가 부족하다' 혹은 '성능상 안좋을꺼야' 라고 생각했었는데요

스크립트이자, 객체지향 언어인 Ruby의 간결함과 Rails의 강력함에 매료되버렸습니다.

웹2.0 에 나름 충실한 Ajax에 대한 지원도 괜찮았구요.

나중에 시간이 되면 오라클 연동 RoR에 대해 강좌를 만들 생각입니다.

아 한참 다른데로 빠졌네요... 오늘은 MS-SQL의 SELECT ..... FOR XML AUTO 에 상응하는 오라클의 기능을 알아보도록하죠.

이게 무슨기능이냐구요? 바로 SQL 쿼리에 의해 반환된 레코드 집합을 XML로 표현하는겁니다.

요즘 프레임워크 설정부터 , 어플리케이션 인프라 Configuration , 웹서비스는 물론, Ajax,flex 등의 web rich client 등등..

XML의 사용빈도는 점점 증가 하고 있습니다.

이 시점에서 오라클에서 제공하는 XML 지원 패키지에 대해 알아보는 시간을 갖도록하죠.

편의상 짧은 어투 양해바랍니다..^^;

시작)

SELECT 절에 의해 생성된 레코드를 Java 나 pro* c , .net 등의 미들 tier 에서 별도의 XML파싱 작업을 하지않고,

오라클에서 제공하는 패키지를 이용하여 손쉽게 XML으로 표현할수 있다.

9i와 10g에서 XML을 다루는 패키지가 다르니 주의하기바란다.

SELECT * FROM PRT 라는 SQL에 의해 반환되는 레코드는 아래와 같다.

이제 필자가 작성한 10gXML제네릭 함수를 보도록하자.

(9i, 8i 사용자들은 아래의 코드에서 DBMS_XMLQUERY 부분을 XMLGEN으로 바꾸면 된다.

독자중 XMLGEN 패키지가 없는 분들은 oracle.com에서 xsu12.tar.gz 를 다운받아 압축을 푼후, xsu12.jar를

오라클 스키마에 올리도록한다.

이때 사용법은 loadjava -verbose -resolve -user scott/tiger xsu12.jar 이다. (기타 자세한 사용법은 loadjava 을 검색하라.)

(혹은 http://blog.naver.com/jadin1/70018342609이 아티클을 참고하길 바란다.)

함수코드)

-----------------------------------------------------------------------------------------

create or replace function GET_XML_RECORD
(xmlSQL IN VARCHAR2,
encodingType IN VARCHAR2 := 'UTF-8') return CLOB is



Ctx dbms_xmlquery.ctxHandle; -- SQL에서 XML로 컨버팅된 객체 핸들
xmlRecord CLOB; --리턴될 값

begin

--컨텍스트 얻어오기
Ctx := dbms_xmlquery.newContext(xmlSQL);

-- encoding 설정
dbms_xmlquery.setEncodingTag(Ctx,encodingType);

-- xml 생성
xmlRecord := dbms_xmlquery.getXML(Ctx);


RETURN xmlRecord;


end GET_XML_RECORD;
-----------------------------------------------------------------------------------------

사용예)

SELECT GET_XML_RECORD('SELECT * FROM PRT','EUC-KR') FROM DUAL;

결과값)


마지막으로 오라클 도큐먼트에서 도움이 될만한 부분 남깁니다.
DBMS_XMLQUERY패키지..

GETXML

Creates the new context, executes the query, gets the XML back and closes the context. This is a convenience function. The context doesn't have to be explicitly opened or closed. The options are described in the following table.

Syntax Description
FUNCTION getXML(  sqlQuery IN VARCHAR2,  metaType IN NUMBER := NONE) RETURN CLOB; 

This function uses a SQL query in string form.

FUNCTION getXML(  sqlQuery IN CLOB,  metaType IN NUMBER := NONE) RETURN CLOB; 

This function uses a SQL query in CLOB form.

FUNCTION getXML(  ctxHdl IN ctxType,  metaType IN NUMBER := NONE) RETURN CLOB; 

This function generates the XML document based on a SQL query used to initialize the context.

PROCEDURE getXML(  ctxHdl IN ctxType,  xDoc IN CLOB,  metaType IN NUMBER := NONE); 

This procedure generates the XML document based on the SQL query used to initialize the context.

Parameter IN / OUT Description
ctxHdl 
(IN) 

Context handle.

metaType 
(IN) 

XML metadata type (NONE, DTD, or SCHEMA).

sqlQuery 
(IN) 

SQL query.

xDoc 
(IN) 

CLOB into which to write the generated XML document.

위에서 특히나, GETXML 함수에 metaType을 지정하면 meta 정보 (DTD, Schema)가 포함되어 반환됩니다.
아주 유용하죠..
다시금 오라클의 강력함과 동시에 오라클에서 점점 B2B, EAI 에 적합한 XML Service에 비중을 많이 두는것 같은 기분이 듭니다.
그럼 부족한 강좌 끝까지 읽어주셔서 감사합니다.
<
Posted by 나비:D
:

다음 표에서는 탭 작업에 사용할 수 있는 마우스 및 키보드 바로 가기를 설명합니다.



기능 바로 가기
백그라운드에 새 탭의 링크 열기 Ctrl+클릭
포그라운드에 새 탭의 링크 열기 CTRL+SHIFT+클릭
포그라운드에 새 탭 열기 Ctrl+T 또는 탭 행의 빈 공간을 두 번 클릭
다른 탭으로 전환 CTRL+TAB 또는 CTRL+SHIFT+TAB
현재 탭 또는 열려 있는 탭이 없는 경우 현재 창 닫기 CTRL+W 또는 ALT+F4
주소 표시줄에서 포그라운드에 새 탭 열기 Alt+Enter
특정 탭 번호로 전환 CTRL+n(여기서 n은 1에서 8 사이의 숫자)
마지막 탭으로 전환 CTRL+9
다른 탭 닫기 CTRL+ALT+F4
빠른 탭 열기(미리 보기) Ctrl+Q
휠 마우스로 탭 링크 열기 마우스 휠로 링크 클릭
휠 마우스로 탭 닫기 마우스 휠로 탭 클릭
Posted by 나비:D
:
오라클 내장 함수
오라클의 함수에는 단일행 함수복수행 함수(그룹함수)가 있다.


숫자 함수(number function)
ABS ACOS ASIN ATAN
ATAN2 BITAND CEIL COS
COSH EXP FLOOR LN
LOG MOD POWER ROUND(number)
SIGN SIN SINH SQRT
TAN TANH TRUNC(number) WIDTH_BUCKET

문자 함수(character function)
CHR CONCAT INITCAP LOWER
LPAD LTRIM NLS_INITCAP NLS_LOWER
NLSSORT NLS_UPPER REPLACE RPAD
RTRIM SOUNDEX SUBSTR TRANSLATE
TREAT TRIM UPPER ASCII
INSTR LENGTH, LENGTHB, LENGTHC, LENGTH2, LENGTH4

날짜와 날짜 처리함수(date, datetime function)
ADD_MONTHS CURRENT_DATE CURRENT_TIMESTAMP DBTIMEZONE
EXTRACT(datetime) FROM_TZ LAST_DAY LOCALTIMESTAMP
MONTHS_BETWEEN NEW_TIME NEXT_DAY NUMTODSINTERVAL
NUMTOYMINTERVAL ROUND(date) SESSIONTIMEZONE SYS_EXTRACT_UTC
SYSDATE SYSTIMESTAMP TO_DSINTERVAL TO_TIMESTAMP
TO_TIMESTAMP_TZ TO_YMINTERVAL TRUNC(date) TZ_OFFSET

데이터 형변환 함수(conversion function)
ASCIISTR BIN_TO_NUM CAST CHARTOROWID
COMPOSE CONVERT DECOMPOSE HEXTORAW
NUMTODSINTERVAL NUMTOYMINTERVAL RAWTOHEX RAWTONHEX
ROWIDTOCHAR ROWIDTONCHAR TO_CHAR(character) TO_CHAR(datetime)
TO_CHAR(number) TO_CLOB TO_DATE TO_DSINTERVAL
TO_LOB TO_MULTI_BYTE TO_NCHAR(character) TO_NCHAR(datetime)
TO_NCHAR(number) TO_NCLOB TO_NUMBER TO_SINGLE_BYTE
TO_YMINTERVAL TRANSLATE ... USING UNISTR
참조로 형변환 관계표를 참조하면 편리하다.
기타함수(miscellaneous single row function)
BFILENAME COALESCE DECODE DEPTH
DUMP EMPTY_BLOB
EMPTY_CLOB
EXISTSNODE EXTRACT(XML)
EXTRACTVALUE GREATEST LEAST NLS_CHARSET_DECL_LEN
NLS_CHARSET_ID NLS_CHARSET_NAME NULLIF NVL
NVL2 PATH SYS_CONNECT_BY_PATH SYS_CONTEXT
SYS_DBURIGEN SYS_EXTRACT_UTC SYS_GUID SYS_TYPEID
SYS_XMLAGG SYS_XMLGEN UID UPDATEXML
USER USERENV VSIZE XMLAGG
XMLCOLATTVAL XMLCONCAT XMLFOREST XMLSEQUENCE
XMLTRANSFORM XMLELEMENT CASE

그룹함수 집계(Aggregate) 함수
AVG CORR COUNT COVAR_POP
COVAR_SAMP CUME_DIST DENSE_RANK FIRST
GROUP_ID GROUPING GROUPING_ID LAST
MAX MIN PERCENTILE_CONT PERCENTILE_DISC
PERCENT_RANK RANK REGR function STDDEV
STDDEV_POP STDDEV_SAMP SUM VAR_POP
VAR_SAMP VARIANCE GROUPING SETS
분석(Analytic) 함수
AVG CORR COUNT COVAR_POP
COVAR_SAMP CUME_DIST DENSE_RANK FIRST
FIRST_VALUE LAG LAST LAST_VALUE
LEAD MAX MIN NTILE
PERCENT_RANK PERCENTILE_CONT PERCENTILE_DISC RANK
RATIO_TO_REPORT REGR_(linear regression) function ROW_NUMBER STDDEV
STDDEV_POP STDDEV_SAMP SUM VAR_POP
VAR_SAMP VARIANCE TOP_N 분석

윈도우(windowing) 분석 함수

윈도우 분석함수부분 합을 계속 더해 나감, sum은 전체 합계를 구함


객체 참조 함수
DEREF MAKE_REF REF REFTOHEX VALUE
PseudoColumn을 의미하는 것
ROWIDEach row in the database has an address
ROWNUM테이블에서 select 되어진 행의 순서번호
LEVEL테이블에서 행(row)의 계층관계를 가리키는 일련번호 순서
Posted by 나비:D
:

BLOG main image
by 나비:D

공지사항

카테고리

분류 전체보기 (278)
Programming? (0)
---------------------------.. (0)
나비의삽질 (5)
Application (177)
SQL (51)
Web (27)
etc. (14)
Omnia (0)
---------------------------.. (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

달력

«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Total :
Today : Yesterday :