Dear all,
I’m trying do modify an existing program launched with SQL plus.
This program allows me to display (in a csv file) a table according a model number. Thanks the command « accept nof prompt 'Numero OF :' » I can prompt the user to tap the model number that he wants to display and the rest of the program create the list in the csv file.
The modification I want to do is as follow:
I’d like the user to be able to enter multiple model number (for exemple: 55125,55126,54672) instead of just typing one, get the csv file, copy/paste the result and execute the program with another model number.
The program should be able to display all the list one after the other.
The question is, how can I do that ?
I also think about another solution, the program prompt the user to enter a model number, write it in the csv file, prompt the user to enter an other model number, write it, etc. and stop writing when the user tap “exit”.
Thank you very much for your precious help, I’m a beginners with sql and I do not know very well how to use “IF” sequence and use the data input by the user.
My program is:
set serveroutput on
set termout on
accept nof prompt 'Numero OF :'
spool c:\temp\ext_prix.csv
set serveroutput off
set termout off
set heading off
set pagesize 0
set echo off
set trimspool on
set feedback off
select REOF_RESS_CODE || ';' ||
to_char(REOF_PHOF_NUMERO_PHASE) || ';' ||
translate(to_char(nvl(REOF_TPS_PASSE,0)),'.','.') || ';' ||
translate(to_char(nvl(REOF_MT_PASSE,0)),'.','.')
from ressource_of
where reof_orfa_numero = '&nof'
union all
select stmv_arti_code || ';' ||
arti_designation || ';;' ||
translate(to_char(stmv_prix_unitaire_ue * beof_qte_besoin_ue),'.','.')|| ';;' ||
BEOF_QTE_BESOIN_UE|| ';;' ||
BEOF_CUMUL_QTE_SORTIE_UE
from stock_mouvement, article , besoin_of
where arti_code = stmv_arti_code
and stmv_orfa_numero = '&nof'
and stmv_nmst_code in ('OF-SOR-CPT','OF/SOR/CPT')
and STMV_CENT_CODE != 'ELEC'
and beof_orfa_numero = stmv_orfa_numero
and beof_arti_code = stmv_arti_code
group by stmv_arti_code,
arti_designation,
stmv_prix_unitaire_ue,
BEOF_QTE_BESOIN_UE,
BEOF_CUMUL_QTE_SORTIE_UE
;
spool off
exit
And the csv files look like:
| 132 | 5 | 0 | 0 | | | | |
| 132 | 10 | 0 | 0 | | | | |
| 132 | 12 | 0 | 0 | | | | |
| 132 | 13 | 0 | 0 | | | | |
| 399 | 14 | 7.5 | 892.5 | | | | |
| 323 | 18 | 0 | 0 | | | | |
| 323 | 19 | 0 | 0 | | | | |
| 323 | 20 | 57.95 | 6896.05 | | | | |
| 323 | 30 | 0.75 | 89.25 | | | | |
| 347 | 40 | 0 | 0 | | | | |
| 399 | 60 | 8 | 952 | | | | |
| 399 | 65 | 0 | 0 | | | | |
| 399 | 70 | 8 | 952 | | | | |
| 323 | 80 | 6.25 | 743.75 | | | | |
| 323 | 90 | 3 | 357 | | | | |
| 320 | 100 | 0 | 0 | | | | |
| 347 | 110 | 0 | 0 | | | | |
| 10.2067 | Produit 1 | | 13357.4291 | | 2 | | 2 |
| 45.1773 | Produit 2 | | 61284.9258 | | 2 | | 2 |
| 100.0447 | Produit 3 | | 2.2826 | | 2 | | 2 |
| 100.0473 | Produit 4 | | 4.230522 | | 2 | | 2 |
| 100.0489 | Produit 5 | | 8.7306 | | 2 | | 2 |
| 110.0008 | Produit 6 | | 0.475274 | | 2 | | 2 |
| 110.001 | Produit 7 | | 0.8826 | | 2 | | 2 |
| 110.0012 | Produit 8 | | 1.718928 | | 2 | | 2 |
| 116.2 | Produit 9 | | 0.628272 | | 12 | | 12 |
| 120.0007 | Produit 10 | | 0.142448 | | 2 | | 2 |
| 120.0009 | Produit 11 | | 0.209774 | | 2 | | 2 |
| 120.0011 | Produit 12 | | 0.38725 | | 2 | | 2 |
| 120.2007 | Produit 13 | | 0.1318 | | 2 | | 2 |
| 120.2009 | Produit 14 | | 0.222826 | | 2 | | 2 |
| 120.201 | Produit 15 | | 0.91 | | 2 | | 2 |
| 157.0059 | Produit 16 | | 15.41304 | | 2 | | 2 |
| 157.006 | Produit 17 | | 23.633856 | | 2 | | 2 |
| 157.008 | Produit 18 | | 15.633746 | | 2 | | 2 |
| 169.0037 | Produit 19 | | 25.492101 | | 1 | | 1 |
| 185.0027 | Produit 20 | | 0.254668 | | 2 | | 2 |
| 185.0035 | Produit 21 | | 6.9 | | 2 | | 2 |
| 185.0075 | Produit 22 | | 3.5 | | 2 | | 2 |
| 208.5232 | Produit 23 | | 9.301786 | | 1 | | 1 |
| 545.0567 | Produit 24 | | 122 | | 2 | | 2 |
| 545.0568 | Produit 25 | | 126.482018 | | 2 | | 2 |
| 800B0082 | Produit 26 | | 479.93728 | | 2 | | 2 |
| 800B0082 | Produit 27 | | 5279.31008 | | 22 | | 22 |
| TD | Produit 28 | | 1922 | | 2 | | 2 |
Thank you very much in advance.