• Nenhum resultado encontrado

Guião para criar aplicações simples em APEX (parte I) Guide to create simple Apex applications (part I)

N/A
N/A
Protected

Academic year: 2021

Share "Guião para criar aplicações simples em APEX (parte I) Guide to create simple Apex applications (part I)"

Copied!
32
0
0

Texto

(1)

Guião para criar aplicações simples em APEX (parte I)

Guide to create simple Apex applications (part I)

O guião que se segue usará uma base de dados que decorre do seguinte DER:

The following script will use a database from the following DER:

Ao qual correpondem as seguintes tabelas: Corresponding to the following tables:

(2)

Socio=(num_socio, nome_socio, bi_socio,data_nsc_socio, morada_socio,

tlf_socio, sexo_socio)

Genero=(cod_genero, nome_genero)

Editora=(cod_editora, nome_editora)

Actor=(cod_actor, nome_actor)

Realizador=(cod_realizador, nome_realizador)

Filme=(cod_filme, nome_filme, ano_filme, preço_dia_filme,

dias_sem_multa_filme, multa_dia_filme, cod_genero, cod_editora)

Filme_actor=(cod_filme,cod_actor)

Filme_realizador=(cod_filme,cod_realizador)

Copia=(cod_filme,num_copia)

Aluguer=(cod_filme,num_copia,data_aluguer, num_socio, data_prev_dev_aluguer)

Devolucao=(cod_filme, num_copia, data_aluguer, num_socio,

data_devolucao, estado_devolucao)

Estão também disponíveis sequências que foram criadas com os seguintes comandos SQL: Also available are sequences that were created with the following SQL commands:

create sequence seq_socio increment by 1 start with 1; create sequence seq_genero increment by 1 start with 1; create sequence seq_editora increment by 1 start with 1; create sequence seq_filme increment by 1 start with 1; create sequence seq_actor increment by 1 start with 1; create sequence seq_realizador increment by 1 start with 1;

Assim, para entrar no APEX, aceda ao seguinte endereço : So, to enter the APEX, go to the following address:

(3)

Em que nnnnn deve ser substituído pelo número de aluno. / where nnnnn must be substituted by the number of the student.

Wnnnnn é a identificação dum workspace que está ligado ao user SQL IBDnnnnn

previamente criado e já usado em ambiente SQL. Por outro lado, unnnnn identifica um user Apex particular (o aluno). Este user está ligado ao workspace Wnnnnn.

Wnnnnn is the ID of a workspace that is connected to the SQL user IBDnnnnn previously created and already used in SQL environment. On the other hand, unnnnn identifies a particular Apex user (the student). This user is connected to the Wnnnnn workspace.

A partir de agora, apenas por razões de conveniência, neste guião será usado “jfs” em vez do número em nnnnn. Assim, onde surgir a string “jfs” neste guião, deverá surgir no contexto na interação com a iterface APEX, para cada aluno, o seu número; nalguns casos precedido pelo prefixo “IBD”.

From now on, just for the sake of convenience, this guide will use "jfs" instead of the number in nnnnn. Thus, whenever the string "jfs" appears in this guide, the student number should appear in the context of the interaction with APEX; in some cases it will be preceded by the prefix "IBD".

(4)

Depois de entrar verá / after entering you will see:

Depois clique em App Builder e verá:/ Then click on App Builder and you see:

Uma aplicação Apex assenta numa coleção de páginas ligadas usando tabs, buttons e links hypertext.

An Apex application lies on a collection of linked pages using tabs, buttons and hypertext links.

(5)

Escolha Desktop e Next / choose Desktop and Next

Em vez de “Schema JFS” deverá ver “Schema IBDnnnnn”. Em Name indique um nome para a sua aplicação; neste guia vamos usar o nome AppVideoClub. Deixe os outros campos como estão e clique em Next.

(6)

Instead of "Schema JFS" you should see "Schema IBDnnnnn". In Name enter a name for your application; in this guide we will use the name AppVideoClub. Leave the other fields as they are and click Next.

A primeira página, chamada Home – se quisermos podemos mudar-lhe o nome – é do tipo

Blank (destinada a página menú)

The first page, named Home – if we want we can change this name – is of type Blank (it will be the menu page).

Clique Next /Click Next

(7)
(8)

Clique em Create Application / Click Create Application

Vamos agora criar outra página; clique em Create Page

(9)

Selecione Report e clique em Next / select Report and click Next

Basicamente, uma página do tipo Report serve para mostrar conteúdos de tabelas, views ou resultados de queries; nesta página não é permitido alterar dados da base de dados.

Basically, a Report page is used to display table contents, views, or query results; on this page it is not allowed to change data from the database.

(10)

Depois selecione Interactive Report e Click Next / Then select Interactive Report and Click Next

(11)

Vamos tratar do report das editoras disponíveis na tabela editora. Como está na figura acima, dê o nome Editora à página, e escolha Breadcrumb para que esta página fique ligada à página inicial Parent Entry. Assim, à frente de Parent Key deverá selecionar Home, que funionará como página menú da aplicação. Nessa página Home existirá uma entrada para aceder a este Report, entrada essa que aqui deverá indicar ao preencher Entry Name com o nome Editora. Depois clique em Next.

Let's look at the Editora (publisher) report available in the editora table. As it is in the figure above, give the Editora name to the page, and choose Breadcrumb so that this page is linked to the Parent Entry home page. So, ahead of Parent Key you should se-lect Home, which will work as the application menu. On this Home page there will be an entry to access this Report, which entry you enter here when filling in Entry Name with the name Editora. Then click Next.

(12)

Agora preencha como na figura acima e clique Next. Now fill in as in the picture above and click Next.

(13)

Depois há que indicar em Souce Type que a fonte do report é do tipo Table e selecionar a tabela Editora . Clique no botão >> para selecionar todos os atributos da tabela; depois Next. Then you have to indicate in Souce Type that the source of the report is of Table type and select the table Editora. Click >> to select all attributes from the table; then Next. Depois clique em Application nnn / Then click Application nnn

(14)

Agora entre na aplicação com os seus user e password / Now enter in your application

with your user and password

(15)

E verá o conteúdo da tabela / and you will see the table content

Pode agora, por exemplo, clicar em Actions, escolher Filter e indicar uma condição como no exemplo abixo

You can click on Actions, select Filter and indicate a condition as in the example below

(16)

Criação de um report sobre junção de tabelas

Building a report on a join of tables.

(17)
(18)

E depois interactive Report / and then Interactive Report

Em seguida aceite o número da página, indique Filme como nome na nova página e como nome da entrada. Preencha o resto dos campos como se indica. Depois faça Next

Then accept the page number, enter Filme as the name on the new page and entry. Fill the rest of the fields as indicated. Then do Next.

(19)

Em seguida indique que vai ligar esta nova página ao menú Home e faça Next Then indicate that you will link this new page to the Home menu and click Next

(20)

Depois indique o nome da tabela (Filme) e clique em Create After indicating the name of the table (Filme) click on Create

(21)

You can now click Save and Run Page to see this page working.

Assim, este é o resultado do SQL interno que é guiado pelo conjunto de atributos na tabela Filme. Para além dos outros atributos, são mostrados os códigos de editora e de género, que são valores núméricos que não permitem uma leitura digamos “natural e imediata” como a que se conseguiria se em vez deles, estivessem os nomes da editora e do género,

respetivamente. Em face desta contingência, vamos contornar o problema. Clique em Edit

Page n (o número desta última página).

Thus, this is the result of the internal SQL that is guided by the set of attributes in table Filme, which shows in addition to the other attributes, the editora and género codes, which are numeric values that do not allow a reading to say "natural and immediate" as that would be obtained if the names of the editora and the género were present, instead of the codes. In face of this contingency, we will work around the problem. Click Edit Page n (the number of this last page)

Agora, na zona Content Body, clique em Filme e verá à direita o código SQL que gerou a leitura do conteúdo da tabela Filme (seta vermelha).

Now, in the zone Content Body, click on Filme and you will see the SQL code that showed the table Filme content (red arrow).

(22)

Agora substitua aquele código SQL pelo seguinte, cuja alteração usa no report do Filme os nomes da editora e do género em vez dos respetivos códigos que são de leitura, à partida, não entendível.

Now replace that SQL code with the following, which uses in the Filme report, the names of the editora and the género instead of their codes that are not easily readable.

select nome_filme as nome,ano_filme as ano,preco_dia_filme as "preco dia",dias_sem_multa_filme as "dias sem multa",multa_dia_filme as "multa

dia",nome_genero as genero,nome_editora as editorafrom filme natural inner join editora natural inner join genero

(23)

Junto à zona do código escrito de SQL, por cima e à direita (seta vermelaha), click em Code

Editor – SQL Query para obter uma janela onde pode escrever ou alterar o novo códigon SQL.

Depois clique em OK para validar. Se houver erros, emende e volte a clicar em Ok.

Next to the area of the written SQL code, above and to the right (red arraw), click Code Editor - SQL Query to get a window where you can write or change the new SQL code. Then click OK to validate. If there are errors, amend and click OK again.

(24)

Quando não hover erros, corra a página para ver este resultado onde os códigos e os nomes dos atritutos foram visualmente “substituídos” por forma a permitir uma compreensão plena. When there are no errors, run the page to see this result where the codes and names of the attributes have been visually “replaced” in order to allow a full understanding.

Criar uma página Form para inserir e modificar dados

Create a Form page to insert and modify data

(25)

Selecione Form / select Form

(26)

Dê nomes ao Report e ao Form, e dê indicação de que quer que haja uma entrada no menú em Home para estas páginas, como indicado acima

Name the Report and the Form, and indicate that you want an entry in the Home menu for these pages, as indicated above.

(27)
(28)

Na janela anterior escolha a tabela sobre a qual vai incidir este Report; neste caso é socio. Depois clique em Next.

In the previous window choose the table on which this report will focus; in this case it is socio. Then click Next.

Agora, tal como se mostra no quadro de cima, escolha “select Primary Key Columns”, carregue em >> para incluir no forms todas os atributos da tabela, aceite

NUM_SOCIO

como chave e escolha “Existing sequence” como forma de gerar um novo número para cada futuro novo tuplo na tabela socio. Depois faça Create.

Now, as shown in the table above, choose "select Primary Key Columns", click on >> to include all attributes of the table in the form, accept NUM_SOCIO as the key and choose "Existing sequence" as a way to generate a new number for each future new tuple in socio table. Then click Create.

(29)

De seguida, caso não tenha indicado anteriormente o nome da sequência a usar para a

geração dos valores para a chave NUM_SOCIO, faça o seguinte: edite a última página (esta do

Forms) e, clicando em Get Pk (na zona Page Processing) verá à direita o código SQL que deverá

alterar através dum clique no canto superior direito que lhe dará acesso à seguinte janela de

edição (setas a vermelho):

Then, if you did not previously indicate the name of the sequence to use for generating the values for the NUM_SOCIO key, do the following: edit the last page (this one from Forms) and clicking Get Pk (in the Page Processing zone) to the right the SQL code that you will have to change through a click in the upper right corner that will give you ac-cess to the following editing window (see arrows in red):

(30)

Depois faça OK e, se não houver erros de edição, corra a página. Then click OK and, if there are no editing errors, run the page.

Agora, para criar um novo socio, vamos preencher os campos dele, excepto o número de sócio que, por ser chave, optámos pela sua geração automática através de sequência, como foi dito atrás. Depois clicar Create.

Nota: por vezes a palavra sócio é aqui escrita sem acento por se referir à tabela,cuja designação não incluiu o acento. O mesmo se passa com género.

Now, to create a new socio (member), we will fill in its fields except the socio number that, because it is the key, we have chosen to be generated automatically. Then click Create.

(31)

E deverá ver o resultado da inserção deste novo socio And you should see the result of inserting this new socio.

Socio cujos valores dos atributos pode alterar ou apagar clicando primeiro no lapis de edição à esquerda (seta vermelha).

Socio whose attribute values can be changed or deleted by first clicking on the edit pencil on the left (see red arrow).

(32)

Joaquim F Ferreira da Silva Abril de 2019

Referências

Documentos relacionados

borar plano de rotas acessíveis, compatível com o plano diretor no qual está inserido, que disponha sobre os passeios públicos a serem implantados ou reformados pelo poder

Tabela 2 - Valores médios, médias e diferenças mínimas significativas (DMS) da produtividade, do teor de água , do teste de germinação e dos testes de vigor (PC - primeira contagem

The limestone caves in South Korea include a variety of speleothems such as soda straw, stalactite, stalagmite, column, curtain (and bacon sheet), cave coral,

issa se elevava chammejante de luz, acima do nivel, em que as outras nações se achavam, pelo esforço incessante e persistente de um dos seus mais dilectos

Neste trabalho o objetivo central foi a ampliação e adequação do procedimento e programa computacional baseado no programa comercial MSC.PATRAN, para a geração automática de modelos

[r]

Caso o cliente compareça na loja com um cartão que esteja sem assinatura, exija a apresentação de um documento de identificação com foto. Solicite que o cliente assine o

Manuel Castells, em Para além da caridade – Responsabilidade social no interesse da em- presa na nova economia, acrescenta ao debate a questão da responsabilidade social das empresas