Jump to content

Dúvida sobre o Created Procedure


Guest MatheusT

Recommended Posts

Eu estou tendo muito problema com a seguinte pergunta: Escreva um script   que receba como argumento um número de inquirido (cid) e um número de
inquérito e devolva o inquérito completo e respetivo preenchimento (duas colunas 1a pergunta, 2a resposta)

Create Table questao(qid Int NOT NULL, enunciado varchar(50) NOT NULL, primary key (qid));

Create table grupo(qid int NOT NULL,subtitulo varchar(50) NOT NULL, primary key(qid)); 

Create Table inquerito(iid int NOT NULL, titulo varchar(50) NOT NULL, primary key(iid));

Create table aberta(qid int NOT NULL,enunciado varchar(50) NOT NULL,foreign key(qid) references questao(qid)); 

Create table fechada(qid int NOT NULL,enunciado varchar(50) NOT NULL,foreign key(qid) references questao(qid)); 

Create table opcao(oid int NOT NULL, texto varchar(50) NOT NULL,primary key(oid)); 

Create table inquirido(cid int NOT NULL, nome varchar(50) NOT NULL, email varchar(50) NOT NULL, primary key(cid)); 

Create table responde_a(resposta varchar(50) NOT NULL,qid int NOT NULL, cid int NOT NULL, foreign key(qid) references aberta(qid), foreign key(cid) references inquirido(cid));

Create table responde_f(oid int NOT NULL, qid int NOT NULL, cid int NOT NULL, foreign key(oid) references opcao(oid), foreign key(qid) references fechada(qid), foreign key(cid) references inquirido(cid));

Vem ai o meu código.

create procedure teste (@cid as int, @iid as int)
as
begin
	SELECT enunciado, resposta, enunciado, texto
	from aberta, responde_a, fechada, opcao
	where 
	
	inquerito.cid = @cid
	inquerito.iid = @iid
	and
	
	inquirido.cid=responde_a.cid and responde_a.quid=aberta.quid
	and
	inquirido.cid=responde_f.cid and responde_f.oid=opcao.oid and opcao
end

delimiter ;
Link to comment
Share on other sites

Há aqui alguma confusão.

Antes de mais, esse código não TSQL (leia-se SQL Server) é de MySQL/MariaDB.

Depois, não percebi a tua dúvida/problema/questão. Tens de colocar as tuas dúvidas de forma clara e concreta.

10 REM Generation 48K!
20 INPUT "URL:", A$
30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50
40 PRINT "404 Not Found"
50 PRINT "./M6 @ Portugal a Programar."

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.