• Hi Guest: Welcome to TRIBE, the online home of TRIBE MAGAZINE. If you'd like to post here, or reply to existing posts on TRIBE, you first have to register. Join us!

Anybody know PL/SQL?

the_fornicator

TRIBE Member
So it's been a while since I've made a PL/SQL script and was wondering if anybody can help me out. It's pretty basic, but I don't know the syntax.

Purpose: I want to write a script that loops in a PL/SQL block. In that block/loop, I wish to continually re-assign a variable with user input (in a user-friendly manner) and do stuff with that variable.

For instance.

<Start Script>

declare
*declare some stuff*

begin

loop <condition>
*take in user_input*
*do stuff*

end loop;

end;
/

*undefine stuff*

<End Script>

I'm pretty sure that you can't use an 'ACCEPT' inside the actual block (between the begin and end).

I could just leave the variable with a '&' and have the ghetto prompt do the task, but again, I want it to look nice and user friendly.

Any clues?

Thanks in advance,
W
 
Last edited:
Cannabis Seed Wedding Bands

the_fornicator

TRIBE Member
If anybody is wondering, it's impossible to assign a variable more than one value inside a PL/SQL block.

If you don't assign a variable a value and put a '&' or '&&' in front of the variable, if the variable is in a loop, you are only able to assign it a value once and only once.

So whatever mashup I had going on up there, not gonna happen. I created a bash script instead. Much easier.
 

~atp~

TRIBE Member
I also actually deleted my post because I looked back at some PL/SQL (have not done any PL/SQL scripting in a year or two) and noticed that I re-assign vars within a block ... which led to confusion, and a subsequent meltdown of various logic gates inside my brain. But yah, imperative languages (ie. procedural) are the ones most of are used to, functional languages are declarative, of which XSLT and SQL belong. However, I did a bit of googling to refresh myself on what PL/SQL does and does not allow (because it is really declarative at its core, with procedural-like extensions) and it seems that there should not be any issue with what the fornicator is asking to do above.
 
tribe cannabis accessories silver grinders

the_fornicator

TRIBE Member
Haven't done PL/SQL in a while myself, but from what I found, you can re-assign a variable a values several times in the procedural block so long as it's from one element to another (cursor to whatever, etc., etc), but I couldn't find a way to continually re-assign a variable values within a loop from user input.

tricky business I tell you.
 
Top