python - How to I read input from a file and use it in an sqlplus query? -


i trying

   select customer_id, order_id order_table purchase_id = 10 or     purchase_id = 25 or     ...    purchase_id = 25432; 

since query big, running variety of problems... if run entire query in single line, running error:

sp2-0027: input long (> 2499 characters) - line ignored 

if split query multiple lines, query gets corrupted, due interference line numbers printed each line of entered query. if disable line numbers, sql> prompt @ each line troubling me.

same error if run query text file sql> @query.sql (i did not face such issues mysql in past sqlplus now).

i not expert in shell-script nor in python. of great if can pointers on how can put purchase_ids in text file, 1 purchase_id per line , supply sqlplus query @ script-runtime.

i did sufficient research, still appreciate pointers well.

1) syntax change:

try use 'in (10,25,2542, ...)' instead of series of 'or'. can reduce size of sql statement

2) logic change:

syntax may delay inevitable, exception still occur if there lot of id exclude.

2a)

a straight-forward fix break query down batches. can issue select query per 50 purchase ids until ids covered.

2b)

or can more generalised way retrieve same query result. let's assume want see list of 'unconfirmed order'. instead of using set of purchase ids in clause, can add boolean field 'confirmed' order_table , select based on criteria.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -