1

The problem is that from the query result in the database:

cur1 = con.cursor()
result1 = ("SELECT DDATE FROM TABLE(NULL)")
cur1.execute(result1)
result1 = cur1.fetchone()

Result from the query - 43949.0

need put the result in the next query, replacing the first two "NULL" values ​​in it, which select:

cur = con.cursor()
POS = (SELECT ST1,ST2 FROM SOMETABLE(**NULL**, **NULL**, NULL, NULL)")
cur.execute(POS)
POS = cur.fetchall()

The result should be a successful request like this: POS = (SELECT ST1,ST2 FROM SOMETABLE(43949.0, 43949.0, NULL, NULL)")

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Emil
  • 15
  • 3
  • Be aware, these are not tables, they are selectable stored procedures. Tables don't have parameters. – Mark Rotteveel May 11 '20 at 13:23
  • In any case, you need to parameterize your query, and pass the parameter values on execute. See https://fdb.readthedocs.io/en/v2.0/usage-guide.html#executing-sql-statements – Mark Rotteveel May 11 '20 at 13:25
  • Thanks for answering . Yes, you're right, these are stored procedures. I am new to programming and it was a little difficult for me to write correctly. Could not give an example of use for my case. I read the document. Did I understand correctly that it is impossible to transfer the result from one procedure to another procedure? And from the table to the procedure is it possible? – Emil May 11 '20 at 14:02
  • you should do something like this: https://bobby-tables.com/python – Arioch 'The May 12 '20 at 09:42

1 Answers1

0

If you want to execute a second statement with input from the first statement, you can use a parameterized statement, and pass parameters from the first to the second in your python code.

For example, something like this:

cur = con.cursor()
cur.execute('select output1 from step1(null)')
result1 = cur.fetchone()

cur.execute('select output1, output2 from step2(?, ?, null, null)', (result1[0], result1[0]))
result2 = cur.fetchall()

Alternatively, you can join the stored procedures together to do this in one query. For example:

select s2.*
from step1(null) s1
cross join step2(s1.output1, s1.output1, null, null) s2

Contrary to normal tables, using a cross join with a stored procedure does not produce a cross-product, but instead behaves as a lateral join.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197