ORA-06550 an INTO clause is espected in this SELECT statement

rguillen

Member²
I using Delphi 7 Enterprease Edition a DOA 3.4.6.4 and Oracle Enreprise Edition 8.1.7.0.0
With Unicode Character Set
My Session in property BytesPerCharacters is set to bcAutoDetect.

when I try the execute the folled query
GeneralQ.SQL.Add('BEGIN');
GeneralQ.SQL.Add(' SELECT * FROM BARD.B_RBCURPERMISOS WHERE USUARIO = BARD;');
GeneralQ.SQL.Add('END;');
Try
GeneralQ.Execute;
Except
On E:EOracleError do ShowMessage(E.Message);
End;

I receive the followed message:
ORA-06550 an INTO clause is espected in this SELECT statement

Can you tell me what is my problem?
 
Seems that you need to use double quotes to define "Bard" as text value; otherwise you need to define "BARD" as string variable and must contains the value that you are looking.
 
RDiaz, Thank for your help, but now have the next error: PLS-00201 identifier BARD must be declared.

I try this
'begin
SELECT * FROM BARD.B_RBCURPERMISOS WHERE USUARIO = "BARD";
end; '

and this
'begin
SELECT * FROM BARD.B_RBCURPERMISOS WHERE USUARIO = 'BARD';
end; '

with TOracleQuery

thank's for help me !

Originally posted by RDiaz:
Seems that you need to use double quotes to define "Bard" as text value; otherwise you need to define "BARD" as string variable and must contains the value that you are looking.
 
You'll have to remove the BEGIN, END and semi-colon after the select statement if you just want to execute it and fetch the results. The statement should be:

GeneralQ.SQL.Text := 'SELECT * FROM BARD.B_RBCURPERMISOS WHERE USUARIO = ''BARD''';

------------------
Marco Kalter
Allround Automations
 
Marco Kalter, Thanck you for your help, the query run succesfully.

Marco can I run a procedure and select sentence in the same query? for example

begin
seguridad.getderechos('BARD', '172.19.41.100');
SELECT * FROM BARD.B_RBCURPERMISOS WHERE USUARIO = 'BARD';
end;
 
You cannot execute a select statement like that in PL/SQL, because you need to do something with the results. You can use a select into with some bind variables if there is just one row returned. If mulitple rows are returned, you can open a cursor instead:
Code:
begin
  seguridad.getderechos('BARD', '172.19.41.100');
  open :v_cursor for 'SELECT * FROM BARD.B_RBCURPERMISOS WHERE USUARIO = ''BARD''';
end;
Now you can declare :v_cursor as a cursor variable, which can subsequently be used in your application. If you are using a TOracleDataSet, it will automatically fetch the records from the cursor. For more information, see the "Cursor variables" section in the User's Guide or help file.

------------------
Marco Kalter
Allround Automations
 
Back
Top